Search in sources :

Example 31 with TestCase

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

the class NagiosOutputBuilder method getStatusSummary.

/**
     * Generates the displayed overview data for the nagios server as an {@link String}.
     *
     * @param testSuite finshed {@link TestSuite}
     * @return formatted payload string
     */
protected String getStatusSummary(TestSuite testSuite, GearmanProperties properties) {
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.remove(formatTestSuiteSummaryStateMessage(testSuite, properties.getTemplateSuiteSummary()), "\n")).append(NagiosOutput.DETAILS_SEPARATOR).append(String.format(ScreenshotDiv.STYLE_TEMPLATE, getOutputScreenshotDivWidth())).append(TABLE_HEADER).append(StringUtils.remove(formatTestSuiteTableStateMessage(testSuite, properties.getTemplateSuiteTable()), "\n"));
    for (TestCase tc : testSuite.getTestCasesAsSortedSet()) {
        sb.append(formatTestCaseTableStateMessage(tc, properties.lookUpTemplate(tc.getState())));
    }
    sb.append(TABLE_FOOTER);
    return sb.toString();
}
Also used : TestCase(org.sakuli.datamodel.TestCase)

Example 32 with TestCase

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

the class Icinga2OutputBuilder method build.

@Override
public String build() {
    StringBuilder sb = new StringBuilder();
    sb.append(formatTestSuiteSummaryStateMessage(testSuite, properties.getTemplateSuiteSummary())).append(ICINGA_SEPARATOR);
    for (TestCase tc : testSuite.getTestCasesAsSortedSet()) {
        String template = properties.lookUpTemplate(tc.getState());
        String result = replacePlaceHolder(template, getTextPlaceholder(tc));
        LOGGER.debug("{{xxx}} patterns in template '{}' replaced with message '{}'", template, result);
        sb.append(result);
    }
    return sb.toString();
}
Also used : TestCase(org.sakuli.datamodel.TestCase)

Example 33 with TestCase

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

the class RegionImplTest method testResolveTakeScreenshotFolderFallback.

@Test
public void testResolveTakeScreenshotFolderFallback() throws Exception {
    TestCase tc = mock(TestCase.class);
    Path examplePath = Paths.get(BaseTest.TEST_FOLDER_PATH + File.separator + "NO_tc.js");
    when(tc.getTcFile()).thenReturn(examplePath);
    when(loader.getCurrentTestCase()).thenReturn(tc);
    TestSuite ts = mock(TestSuite.class);
    when(ts.getTestSuiteFolder()).thenReturn(Paths.get(BaseTest.TEST_FOLDER_PATH));
    when(loader.getTestSuite()).thenReturn(ts);
    Path result = RegionImpl.resolveTakeScreenshotFolder("test", loader);
    assertEquals(result.toString(), Paths.get(BaseTest.TEST_FOLDER_PATH) + File.separator + "test");
    verify(loader).getTestSuite();
    verify(loader).getCurrentTestCase();
}
Also used : Path(java.nio.file.Path) TestSuite(org.sakuli.datamodel.TestSuite) TestCase(org.sakuli.datamodel.TestCase) BaseTest(org.sakuli.BaseTest) Test(org.testng.annotations.Test)

Example 34 with TestCase

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

the class RhinoAspectTest method testDoTestCaseActionLog.

@Test
public void testDoTestCaseActionLog() throws Exception {
    initMocks();
    BaseActionLoader loader = mock(BaseActionLoader.class);
    TestCase sampleTc = new TestCase("test", "testID");
    when(loader.getCurrentTestCase()).thenReturn(sampleTc);
    TestCaseAction testAction = new TestCaseAction();
    ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class);
    testAction.init("testID", 3, 4, "imagefolder1", "imagefolder2");
    assertLastLine(logFile, testAction.getClass().getSimpleName(), LogLevel.INFO, "\"test case [" + sampleTc.getActionValueString() + "]\" TestCaseAction.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]");
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TestCaseAction(org.sakuli.actions.TestCaseAction) BaseActionLoader(org.sakuli.loader.BaseActionLoader) Test(org.testng.annotations.Test)

Example 35 with TestCase

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

the class TestSuiteExampleBuilder method buildExample.

public TestSuite buildExample() {
    TestSuite testSuite = new TestSuite();
    testSuite.setName("Unit Test Sample Test Suite");
    testSuite.setId(id);
    testSuite.setStartDate(startDate);
    testSuite.setStopDate(stopDate);
    testSuite.setWarningTime(warningTime);
    testSuite.setCriticalTime(criticalTime);
    testSuite.setState(state);
    testSuite.setHost(host);
    testSuite.setBrowserInfo("Firefox Test Browser");
    testSuite.addException(exception);
    testSuite.setTestSuiteFolder(folder);
    testSuite.setBrowserInfo(browserInfo);
    for (TestCase testCase : testCases) {
        testSuite.addTestCase(testCase.getId(), testCase);
    }
    return testSuite;
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) 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