use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class TestCaseStepHelperTest method testWriteCachedStepsError.
@Test
public void testWriteCachedStepsError() throws Throwable {
Path tcFile = getResource("stephelper/tc.js");
TestSuite testSuite = mock(TestSuite.class);
TestCase tc = mock(TestCase.class);
when(tc.getTcFile()).thenReturn(tcFile);
when(tc.getSteps()).thenReturn(Arrays.asList(new TestCaseStepBuilder("step_warning").withState(TestCaseStepState.WARNING).build(), new TestCaseStepBuilder("step_ok").withState(TestCaseStepState.OK).build(), new TestCaseStepBuilder("step_not_started_1").build(), new TestCaseStepBuilder("step_not_started_2").build()));
when(testSuite.getTestCases()).thenReturn(Collections.singletonMap("1", tc));
TestCaseStepHelper.writeCachedStepDefinitions(testSuite);
Path cacheFile = getResource(CACHEFILE_NAME);
assertTrue(Files.exists(cacheFile));
assertEquals(FileUtils.readFileToString(cacheFile.toFile(), Charset.forName("UTF-8")), "step_warning\nstep_ok\nstep_not_started_1\nstep_not_started_2\n");
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testSaveExceptionsInStep.
@Test
public void testSaveExceptionsInStep() throws Exception {
TestSuite ts = new TestSuite();
when(loader.getTestSuite()).thenReturn(ts);
TestCase tc = new TestCase(null, null);
when(loader.getCurrentTestCase()).thenReturn(tc);
TestCaseStep step = new TestCaseStep();
when(loader.getCurrentTestCaseStep()).thenReturn(step);
testling.saveException(new SakuliException("test"));
assertNull(ts.getException());
assertNull(tc.getException());
assertEquals(step.getException().getMessage(), "test");
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testGetAllExceptions.
@Test
public void testGetAllExceptions() throws Exception {
TestSuite ts = new TestSuite();
ts.addException(new SakuliException("bla"));
TestCase tc = new TestCase(null, null);
tc.addException(new SakuliException("bla2"));
ts.addTestCase(tc);
TestCaseStep step = new TestCaseStep();
step.addException(new SakuliException("bla3"));
tc.addStep(step);
List<Throwable> allExceptions = SakuliExceptionHandler.getAllExceptions(ts);
assertEquals(allExceptions.size(), 3);
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testContainsExceptionsCase.
@Test
public void testContainsExceptionsCase() throws Exception {
TestSuite ts = new TestSuite();
TestCase tc = new TestCase(null, null);
tc.addException(new SakuliException("bla2"));
ts.addTestCase(tc);
TestCaseStep step = new TestCaseStep();
tc.addStep(step);
assertTrue(SakuliExceptionHandler.containsException(ts));
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method setUp.
private void setUp() throws Exception {
expectedScreenshotPath = Paths.get(screenShotFolder + "test.jpg");
when(screenshotActionsMock.takeScreenshot(anyString(), any(Path.class))).thenReturn(expectedScreenshotPath);
when(loader.getScreenshotActions()).thenReturn(screenshotActionsMock);
testCase = new TestCase("testling", "1234_");
HashMap<String, TestCase> testCases = new HashMap<>();
testCases.put(testCase.getId(), testCase);
testSuite = new TestSuite();
testSuite.setState(TestSuiteState.RUNNING);
ReflectionTestUtils.setField(testSuite, "testCases", testCases);
when(loader.getActionProperties()).thenReturn(actionProperties);
when(actionProperties.isTakeScreenshots()).thenReturn(true);
when(loader.getSakuliProperties()).thenReturn(sakuliProperties);
when(sakuliProperties.isSuppressResumedExceptions()).thenReturn(false);
when(loader.getSahiReport()).thenReturn(sahiReport);
when(loader.getTestSuite()).thenReturn(testSuite);
when(loader.getCurrentTestCase()).thenReturn(testCase);
}
Aggregations