Search in sources :

Example 16 with TestCase

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

the class BaseActionLoaderTest method testInit.

@Test
public void testInit() throws Exception {
    String testCaseId = "xyz";
    when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId));
    when(sahiProxyProperties.isRequestDelayActive()).thenReturn(true);
    when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true);
    testling.init(testCaseId, ".");
    verify(exceptionHandler, never()).handleException(any(Exception.class));
    verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "true");
}
Also used : TestCase(org.sakuli.datamodel.TestCase) IOException(java.io.IOException) SakuliException(org.sakuli.exceptions.SakuliException) Test(org.testng.annotations.Test)

Example 17 with TestCase

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

the class NagiosOutputBuilderTest method testFormatTestCaseTableStateMessageWithScreenshotOnylInTestCase.

@Test
public void testFormatTestCaseTableStateMessageWithScreenshotOnylInTestCase() throws Exception {
    Path screenshotPath = Paths.get(NagiosOutputBuilder.class.getResource("computer.png").toURI());
    String htmlTemplate = "<tr valign=\"top\"><td class=\"%s\">%s<\\/td><\\/tr>";
    GearmanProperties properties = MonitoringPropertiesTestHelper.initMock(mock(GearmanProperties.class));
    TestCase testCase = new TestCaseExampleBuilder().withState(TestCaseState.ERRORS).withId("case-error").withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliExceptionWithScreenshot("STEP-EXCEPTION-MESSAGE", screenshotPath)).buildExample())).buildExample();
    String regex = String.format(htmlTemplate, "serviceCRITICAL", "\\[CRIT\\] case \"case-error\" EXCEPTION: " + "STEP \"step_for_unit_test\": STEP-EXCEPTION-MESSAGE" + "<div.* src=\"data:image\\/png;base64,.*><\\/div>");
    BaseTest.assertRegExMatch(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), regex);
}
Also used : Path(java.nio.file.Path) GearmanProperties(org.sakuli.services.forwarder.gearman.GearmanProperties) TestCase(org.sakuli.datamodel.TestCase) SakuliExceptionWithScreenshot(org.sakuli.exceptions.SakuliExceptionWithScreenshot) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 18 with TestCase

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

the class TestSuiteHelperTest method testInit.

@Test
public void testInit() throws Throwable {
    TestSuiteProperties testProps = TestSuitePropertiesTestUtils.getTestProps(this.getClass(), "valid", "suite_id_001");
    HashMap<String, TestCase> result = TestSuiteHelper.loadTestCases(testProps);
    assertEquals(1, result.size());
    //tests if onyl the valid testcase are in the suite, with there right names
    TestCase tc = result.values().iterator().next();
    assertEquals("http://localhost:8080", tc.getStartUrl());
    assertEquals(tc.getName(), "validTestCase");
    assertEquals(tc.getId(), "validTestCase");
    assertEquals(tc.getId(), result.keySet().iterator().next());
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TestSuiteProperties(org.sakuli.datamodel.properties.TestSuiteProperties) Test(org.testng.annotations.Test)

Example 19 with TestCase

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

the class SakuliExceptionHandlerTest method testContainsExceptionsStep.

@Test
public void testContainsExceptionsStep() throws Exception {
    TestSuite ts = new TestSuite();
    TestCase tc = new TestCase(null, null);
    ts.addTestCase(tc);
    TestCaseStep step = new TestCaseStep();
    step.addException(new SakuliException("bla3"));
    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 20 with TestCase

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

the class TestCaseExampleBuilder method buildExample.

@Override
public TestCase buildExample() {
    TestCase testCase = new TestCase(name, id);
    testCase.setState(state);
    testCase.setStartDate(startDate);
    testCase.setStopDate(stopDate);
    testCase.setWarningTime(warningTime);
    testCase.setCriticalTime(criticalTime);
    testCase.addException(exception);
    testCase.setTcFile(testCaseFile);
    testCase.setStartUrl(startURL);
    testCase.setLastURL(lastURL);
    testCase.setSteps(steps);
    if (creationDate != null) {
        testCase.setCreationDate(creationDate);
    }
    return testCase;
}
Also used : TestCase(org.sakuli.datamodel.TestCase)

Aggregations

TestCase (org.sakuli.datamodel.TestCase)49 Test (org.testng.annotations.Test)33 BaseTest (org.sakuli.BaseTest)20 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)14 Path (java.nio.file.Path)13 TestSuite (org.sakuli.datamodel.TestSuite)13 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)11 DateTime (org.joda.time.DateTime)8 TestCaseStep (org.sakuli.datamodel.TestCaseStep)8 TreeSet (java.util.TreeSet)7 IOException (java.io.IOException)5 Date (java.util.Date)5 SakuliException (org.sakuli.exceptions.SakuliException)5 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)5 GearmanProperties (org.sakuli.services.forwarder.gearman.GearmanProperties)4 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)3 DaoTestCase (org.sakuli.services.forwarder.database.dao.DaoTestCase)2 DaoTestCaseStep (org.sakuli.services.forwarder.database.dao.DaoTestCaseStep)2 SqlLobValue (org.springframework.jdbc.core.support.SqlLobValue)2 File (java.io.File)1