Search in sources :

Example 36 with TestSuite

use of org.sakuli.datamodel.TestSuite 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");
}
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 37 with TestSuite

use of org.sakuli.datamodel.TestSuite 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);
}
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 38 with TestSuite

use of org.sakuli.datamodel.TestSuite 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));
}
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 39 with TestSuite

use of org.sakuli.datamodel.TestSuite 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);
}
Also used : Path(java.nio.file.Path) TestSuite(org.sakuli.datamodel.TestSuite) TestCase(org.sakuli.datamodel.TestCase) Matchers.anyString(org.mockito.Matchers.anyString)

Example 40 with TestSuite

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

the class AbstractOutputBuilderTest method testFormatTestSuiteStateMessageUnknown.

@Test
public void testFormatTestSuiteStateMessageUnknown() throws Exception {
    TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.RUNNING).withStopDate(null).buildExample();
    String result = testling.formatTestSuiteSummaryStateMessage(testSuiteExample, properties.getTemplateSuiteSummary());
    assertEquals(result, "[UNKN] Sakuli suite \"sakuli-123\" suite still running. (Last suite run: xx)");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

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