Search in sources :

Example 6 with TestSet

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

use of uk.co.automatictester.lightning.TestSet in project lightning by automatictester.

the class TestSetReporterTest method testPrintTestSetExecutionSummaryReportForPass.

@Test
public void testPrintTestSetExecutionSummaryReportForPass() {
    String expectedResult = String.format("============= EXECUTION SUMMARY =============%n" + "Tests executed:    15%n" + "Tests passed:      15%n" + "Tests failed:      0%n" + "Tests errors:      0%n" + "Test set status:   Pass");
    TestSet testSet = mock(TestSet.class);
    when(testSet.getTestCount()).thenReturn(15);
    when(testSet.getPassCount()).thenReturn(15);
    when(testSet.getFailCount()).thenReturn(0);
    when(testSet.getErrorCount()).thenReturn(0);
    String output = new TestSetReporter(testSet).getTestSetExecutionSummaryReport();
    assertThat(output, containsString(expectedResult));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TestSet(uk.co.automatictester.lightning.TestSet) Test(org.testng.annotations.Test)

Example 8 with TestSet

use of uk.co.automatictester.lightning.TestSet in project lightning by automatictester.

the class TestSetReporterTest method testPrintTestSetExecutionSummaryReportForFail.

@Test
public void testPrintTestSetExecutionSummaryReportForFail() {
    String expectedResult = String.format("============= EXECUTION SUMMARY =============%n" + "Tests executed:    15%n" + "Tests passed:      14%n" + "Tests failed:      1%n" + "Tests errors:      0%n" + "Test set status:   FAIL");
    TestSet testSet = mock(TestSet.class);
    when(testSet.getTestCount()).thenReturn(15);
    when(testSet.getPassCount()).thenReturn(14);
    when(testSet.getFailCount()).thenReturn(1);
    when(testSet.getErrorCount()).thenReturn(0);
    String output = new TestSetReporter(testSet).getTestSetExecutionSummaryReport();
    assertThat(output, containsString(expectedResult));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TestSet(uk.co.automatictester.lightning.TestSet) Test(org.testng.annotations.Test)

Example 9 with TestSet

use of uk.co.automatictester.lightning.TestSet in project lightning by automatictester.

the class TestSetReporterTest method testPrintTestSetExecutionSummaryReportForIgnore.

@Test
public void testPrintTestSetExecutionSummaryReportForIgnore() {
    String expectedResult = String.format("============= EXECUTION SUMMARY =============%n" + "Tests executed:    15%n" + "Tests passed:      14%n" + "Tests failed:      0%n" + "Tests errors:      1%n" + "Test set status:   FAIL");
    TestSet testSet = mock(TestSet.class);
    when(testSet.getTestCount()).thenReturn(15);
    when(testSet.getPassCount()).thenReturn(14);
    when(testSet.getFailCount()).thenReturn(0);
    when(testSet.getErrorCount()).thenReturn(1);
    String output = new TestSetReporter(testSet).getTestSetExecutionSummaryReport();
    assertThat(output, containsString(expectedResult));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TestSet(uk.co.automatictester.lightning.TestSet) Test(org.testng.annotations.Test)

Example 10 with TestSet

use of uk.co.automatictester.lightning.TestSet in project lightning by automatictester.

the class CliTestRunner method runTests.

private static void runTests() {
    long testSetExecStart = System.currentTimeMillis();
    File xmlFile = params.verify.getXmlFile();
    File jmeterCsvFile = params.verify.getJmeterCsvFile();
    File perfmonCsvFile = params.verify.getPerfmonCsvFile();
    LightningXMLFileReader xmlFileReader = new LightningXMLFileReader();
    xmlFileReader.readTests(xmlFile);
    List<ClientSideTest> clientSideTests = xmlFileReader.getClientSideTests();
    List<ServerSideTest> serverSideTests = xmlFileReader.getServerSideTests();
    testSet = new TestSet(clientSideTests, serverSideTests);
    jmeterTransactions = new JMeterCSVFileReader().getTransactions(jmeterCsvFile);
    if (params.verify.isPerfmonCsvFileProvided()) {
        perfMonDataEntries = new PerfMonDataReader().getDataEntires(perfmonCsvFile);
        testSet.executeServerSideTests(perfMonDataEntries);
    }
    testSet.executeClientSideTests(jmeterTransactions);
    testSet.printTestExecutionReport();
    new TestSetReporter(testSet).printTestSetExecutionSummaryReport();
    long testSetExecEnd = System.currentTimeMillis();
    long testExecTime = testSetExecEnd - testSetExecStart;
    logger.info("Total execution time:    {}ms", testExecTime);
    if (testSet.getFailCount() + testSet.getErrorCount() != 0) {
        exitCode = 1;
    }
}
Also used : ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest) ServerSideTest(uk.co.automatictester.lightning.tests.ServerSideTest) TestSetReporter(uk.co.automatictester.lightning.reporters.TestSetReporter) JMeterCSVFileReader(uk.co.automatictester.lightning.readers.JMeterCSVFileReader) PerfMonDataReader(uk.co.automatictester.lightning.readers.PerfMonDataReader) LightningXMLFileReader(uk.co.automatictester.lightning.readers.LightningXMLFileReader) File(java.io.File) TestSet(uk.co.automatictester.lightning.TestSet)

Aggregations

TestSet (uk.co.automatictester.lightning.TestSet)10 Test (org.testng.annotations.Test)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ClientSideTest (uk.co.automatictester.lightning.tests.ClientSideTest)5 ServerSideTest (uk.co.automatictester.lightning.tests.ServerSideTest)5 TestSetReporter (uk.co.automatictester.lightning.reporters.TestSetReporter)4 PerfMonDataEntries (uk.co.automatictester.lightning.data.PerfMonDataEntries)3 JMeterCSVFileReader (uk.co.automatictester.lightning.readers.JMeterCSVFileReader)3 LightningXMLFileReader (uk.co.automatictester.lightning.readers.LightningXMLFileReader)3 PerfMonDataReader (uk.co.automatictester.lightning.readers.PerfMonDataReader)3 File (java.io.File)2 Scanner (java.util.Scanner)1 Element (org.w3c.dom.Element)1 JUnitReporter (uk.co.automatictester.lightning.ci.JUnitReporter)1 JMeterCSVS3ObjectReader (uk.co.automatictester.lightning.lambda.readers.JMeterCSVS3ObjectReader)1 LightningXMLS3ObjectReader (uk.co.automatictester.lightning.lambda.readers.LightningXMLS3ObjectReader)1 PerfMonS3ObjectDataReader (uk.co.automatictester.lightning.lambda.readers.PerfMonS3ObjectDataReader)1 LightningTest (uk.co.automatictester.lightning.tests.LightningTest)1 PassedTransactionsTest (uk.co.automatictester.lightning.tests.PassedTransactionsTest)1