Search in sources :

Example 1 with LightningTest

use of uk.co.automatictester.lightning.tests.LightningTest in project lightning by automatictester.

the class JUnitReporter method generateJUnitReport.

public void generateJUnitReport() {
    Node rootElement = doc.appendChild(getTestsuite());
    for (LightningTest test : testSet.getTests()) {
        rootElement.appendChild(getTestcase(test));
    }
    saveReportToDisk();
}
Also used : Node(org.w3c.dom.Node) LightningTest(uk.co.automatictester.lightning.tests.LightningTest)

Example 2 with LightningTest

use of uk.co.automatictester.lightning.tests.LightningTest in project lightning by automatictester.

the class JUnitReporterTest method testGetFailedTestcase.

@Test
public void testGetFailedTestcase() {
    LightningTest test = mock(LightningTest.class);
    when(test.getResult()).thenReturn(TestResult.FAIL);
    when(test.getName()).thenReturn("some name");
    when(test.getTestExecutionReport()).thenReturn("some content");
    when(test.getActualResultDescription()).thenReturn("some message");
    when(test.getType()).thenReturn("some type");
    Element testcase = new JUnitReporter().getTestcase(test);
    assertThat(testcase.getTagName(), equalTo("testcase"));
    assertThat(testcase.getAttribute("time"), equalTo("0"));
    assertThat(testcase.getAttribute("name"), equalTo("some name"));
    assertThat(testcase.getTextContent(), equalTo("some content"));
    assertThat(testcase.getElementsByTagName("failure").item(0).getAttributes().item(0).toString(), equalTo("message=\"some message\""));
    assertThat(testcase.getElementsByTagName("failure").item(0).getAttributes().item(1).toString(), equalTo("type=\"some type\""));
}
Also used : Element(org.w3c.dom.Element) JUnitReporter(uk.co.automatictester.lightning.ci.JUnitReporter) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) Test(org.testng.annotations.Test)

Example 3 with LightningTest

use of uk.co.automatictester.lightning.tests.LightningTest in project lightning by automatictester.

the class JUnitReporterTest method testGetErrorTestcase.

@Test
public void testGetErrorTestcase() {
    LightningTest test = mock(LightningTest.class);
    when(test.getResult()).thenReturn(TestResult.ERROR);
    when(test.getName()).thenReturn("some name");
    when(test.getTestExecutionReport()).thenReturn("some content");
    when(test.getActualResultDescription()).thenReturn("some message");
    when(test.getType()).thenReturn("some type");
    Element testcase = new JUnitReporter().getTestcase(test);
    assertThat(testcase.getTagName(), equalTo("testcase"));
    assertThat(testcase.getAttribute("time"), equalTo("0"));
    assertThat(testcase.getAttribute("name"), equalTo("some name"));
    assertThat(testcase.getTextContent(), equalTo("some content"));
    assertThat(testcase.getElementsByTagName("error").item(0).getAttributes().item(0).toString(), equalTo("message=\"some message\""));
    assertThat(testcase.getElementsByTagName("error").item(0).getAttributes().item(1).toString(), equalTo("type=\"some type\""));
}
Also used : Element(org.w3c.dom.Element) JUnitReporter(uk.co.automatictester.lightning.ci.JUnitReporter) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) Test(org.testng.annotations.Test)

Example 4 with LightningTest

use of uk.co.automatictester.lightning.tests.LightningTest in project lightning by automatictester.

the class JUnitReporterTest method testGetPassedTestcase.

@Test
public void testGetPassedTestcase() {
    LightningTest test = mock(LightningTest.class);
    when(test.getResult()).thenReturn(TestResult.PASS);
    when(test.getName()).thenReturn("some name");
    Element testcase = new JUnitReporter().getTestcase(test);
    assertThat(testcase.getTagName(), equalTo("testcase"));
    assertThat(testcase.getAttribute("time"), equalTo("0"));
    assertThat(testcase.getAttribute("name"), equalTo("some name"));
}
Also used : Element(org.w3c.dom.Element) JUnitReporter(uk.co.automatictester.lightning.ci.JUnitReporter) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) Test(org.testng.annotations.Test)

Aggregations

LightningTest (uk.co.automatictester.lightning.tests.LightningTest)4 Test (org.testng.annotations.Test)3 Element (org.w3c.dom.Element)3 JUnitReporter (uk.co.automatictester.lightning.ci.JUnitReporter)3 Node (org.w3c.dom.Node)1