Search in sources :

Example 16 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class SakuliExceptionHandlerTest method testSaveExceptionsInCase.

@Test
public void testSaveExceptionsInCase() throws Exception {
    TestSuite ts = new TestSuite();
    when(loader.getTestSuite()).thenReturn(ts);
    TestCase tc = new TestCase(null, null);
    when(loader.getCurrentTestCase()).thenReturn(tc);
    testling.saveException(new SakuliException("test"));
    assertNull(ts.getException());
    assertEquals(tc.getException().getMessage(), "test");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCase(org.sakuli.datamodel.TestCase) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 17 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class SakuliExceptionHandlerTest method testContainsExceptionsSuite.

@Test
public void testContainsExceptionsSuite() throws Exception {
    TestSuite ts = new TestSuite();
    ts.addException(new SakuliException("bla"));
    TestCase tc = new TestCase(null, null);
    ts.addTestCase(tc);
    TestCaseStep step = new TestCaseStep();
    tc.addStep(step);
    assertTrue(SakuliExceptionHandler.containsException(ts));
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCase(org.sakuli.datamodel.TestCase) TestCaseStep(org.sakuli.datamodel.TestCaseStep) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 18 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class SakuliExceptionHandlerTest method testSaveExceptionsInSuite.

@Test
public void testSaveExceptionsInSuite() throws Exception {
    TestSuite ts = new TestSuite();
    when(loader.getTestSuite()).thenReturn(ts);
    testling.saveException(new SakuliException("test"));
    assertEquals(ts.getException().getMessage(), "test");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 19 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class InitializingServiceHelperTest method testInvokeAllResultServices.

@Test
public void testInvokeAllResultServices() throws Exception {
    assertEquals(BeanLoader.loadMultipleBeans(InitializingService.class).size(), 3);
    DatabaseInitializingServiceImpl databaseService = BeanLoader.loadBean(DatabaseInitializingServiceImpl.class);
    doNothing().when(databaseService).initTestSuite();
    GearmanInitializingServiceImpl gearmanService = BeanLoader.loadBean(GearmanInitializingServiceImpl.class);
    doNothing().when(gearmanService).initTestSuite();
    TestSuite testSuite = BeanLoader.loadBean(TestSuite.class);
    testSuite.setState(null);
    testSuite.setStartDate(null);
    InitializingServiceHelper.invokeInitializingServcies();
    assertEquals(testSuite.getState(), TestSuiteState.RUNNING);
    assertTrue(testSuite.getStartDate().before(new DateTime().plusMillis(100).toDate()));
    verify(databaseService).initTestSuite();
    verify(gearmanService).initTestSuite();
}
Also used : GearmanInitializingServiceImpl(org.sakuli.services.forwarder.gearman.GearmanInitializingServiceImpl) TestSuite(org.sakuli.datamodel.TestSuite) DatabaseInitializingServiceImpl(org.sakuli.services.forwarder.database.DatabaseInitializingServiceImpl) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 20 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class NagiosOutputBuilderTest method testGetStatusSummary.

@Test
public void testGetStatusSummary() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").buildExample())).buildExample();
    String lastRun = AbstractOutputBuilder.dateFormat.format(testSuite.getStopDate());
    String expectedHTML = "[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: " + lastRun + ")\\\\n" + String.format(ScreenshotDiv.STYLE_TEMPLATE, testling.getOutputScreenshotDivWidth()) + "<table style=\"border-collapse: collapse;\">" + "<tr valign=\"top\">" + "<td class=\"serviceOK\">[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: " + lastRun + ")" + "</td>" + "</tr>" + "<tr valign=\"top\">" + "<td class=\"serviceOK\">[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok</td>" + "</tr>" + "</table>";
    String statusSummary = testling.getStatusSummary(testSuite, gearmanProperties);
    assertEquals(statusSummary, expectedHTML);
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    ReflectionTestUtils.setField(testling, "gearmanProperties", gearmanProperties);
    NagiosOutput output = testling.build();
    String substringStatusSummary = output.getOutputString().substring(0, output.getOutputString().indexOf("|"));
    assertEquals(substringStatusSummary, expectedHTML);
}
Also used : NagiosOutput(org.sakuli.services.forwarder.gearman.model.NagiosOutput) TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Aggregations

TestSuite (org.sakuli.datamodel.TestSuite)41 Test (org.testng.annotations.Test)34 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)21 BaseTest (org.sakuli.BaseTest)15 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)15 TestCase (org.sakuli.datamodel.TestCase)13 SakuliException (org.sakuli.exceptions.SakuliException)7 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 TestCaseStep (org.sakuli.datamodel.TestCaseStep)6 Path (java.nio.file.Path)5 Date (java.util.Date)5 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)2 SakuliInitException (org.sakuli.exceptions.SakuliInitException)2 FileNotFoundException (java.io.FileNotFoundException)1 Entry (java.util.Map.Entry)1 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 DateTime (org.joda.time.DateTime)1 Matchers.anyString (org.mockito.Matchers.anyString)1 LoggerTest (org.sakuli.LoggerTest)1