Search in sources :

Example 1 with TestCase

use of org.sonar.api.test.TestCase in project sonarqube by SonarSource.

the class GenericTestExecutionReportParser method parseTestCase.

private void parseTestCase(SMInputCursor cursor, MutableTestPlan testPlan) throws XMLStreamException {
    checkElementName(cursor, "testCase");
    MutableTestCase testCase = testPlan.addTestCase(mandatoryAttribute(cursor, NAME_ATTR));
    TestCase.Status status = TestCase.Status.OK;
    testCase.setDurationInMs(longValue(mandatoryAttribute(cursor, DURATION_ATTR), cursor, DURATION_ATTR, 0));
    SMInputCursor child = cursor.descendantElementCursor();
    if (child.getNext() != null) {
        String elementName = child.getLocalName();
        if (SKIPPED.equals(elementName)) {
            status = TestCase.Status.SKIPPED;
        } else if (FAILURE.equals(elementName)) {
            status = TestCase.Status.FAILURE;
        } else if (ERROR.equals(elementName)) {
            status = TestCase.Status.ERROR;
        }
        if (TestCase.Status.OK != status) {
            testCase.setMessage(mandatoryAttribute(child, MESSAGE_ATTR));
            testCase.setStackTrace(child.collectDescendantText());
        }
    }
    testCase.setStatus(status);
}
Also used : SMInputCursor(org.codehaus.staxmate.in.SMInputCursor) MutableTestCase(org.sonar.api.test.MutableTestCase) MutableTestCase(org.sonar.api.test.MutableTestCase) TestCase(org.sonar.api.test.TestCase)

Aggregations

SMInputCursor (org.codehaus.staxmate.in.SMInputCursor)1 MutableTestCase (org.sonar.api.test.MutableTestCase)1 TestCase (org.sonar.api.test.TestCase)1