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");
}
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));
}
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");
}
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();
}
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);
}
Aggregations