Search in sources :

Example 1 with JUnitReporter

use of uk.co.automatictester.lightning.ci.JUnitReporter 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 2 with JUnitReporter

use of uk.co.automatictester.lightning.ci.JUnitReporter 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 3 with JUnitReporter

use of uk.co.automatictester.lightning.ci.JUnitReporter in project lightning by automatictester.

the class LightningMojo method saveJunitReport.

private void saveJunitReport() {
    JUnitReporter jUnitReporter = new JUnitReporter();
    jUnitReporter.setTestSet(testSet);
    jUnitReporter.generateJUnitReport();
}
Also used : JUnitReporter(uk.co.automatictester.lightning.ci.JUnitReporter)

Example 4 with JUnitReporter

use of uk.co.automatictester.lightning.ci.JUnitReporter in project lightning by automatictester.

the class JUnitReporterTest method testGetTestsuite.

@Test
public void testGetTestsuite() {
    TestSet testSet = mock(TestSet.class);
    when(testSet.getTestCount()).thenReturn(3);
    when(testSet.getErrorCount()).thenReturn(1);
    when(testSet.getFailCount()).thenReturn(1);
    JUnitReporter jUnitReporter = new JUnitReporter();
    jUnitReporter.setTestSet(testSet);
    Element testsuite = jUnitReporter.getTestsuite();
    assertThat(testsuite.getTagName(), equalTo("testsuite"));
    assertThat(testsuite.getAttribute("tests"), equalTo("3"));
    assertThat(testsuite.getAttribute("errors"), equalTo("1"));
    assertThat(testsuite.getAttribute("failures"), equalTo("1"));
    assertThat(testsuite.getAttribute("time"), equalTo("0"));
    assertThat(testsuite.getAttribute("name"), equalTo("Lightning"));
}
Also used : JUnitReporter(uk.co.automatictester.lightning.ci.JUnitReporter) Element(org.w3c.dom.Element) TestSet(uk.co.automatictester.lightning.TestSet) LightningTest(uk.co.automatictester.lightning.tests.LightningTest) Test(org.testng.annotations.Test)

Example 5 with JUnitReporter

use of uk.co.automatictester.lightning.ci.JUnitReporter 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

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