Search in sources :

Example 46 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)

Example 47 with TestCase

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

the class TestCaseAction method initWarningAndCritical.

private void initWarningAndCritical(int warningTime, int criticalTime) {
    TestCase currentTestCase = loader.getCurrentTestCase();
    String errormsg = TestDataEntityHelper.checkWarningAndCriticalTime(warningTime, criticalTime, currentTestCase.toStringShort());
    if (errormsg != null) {
        handleException(errormsg);
    } else {
        //if everything is ok set the times
        currentTestCase.setWarningTime(warningTime);
        currentTestCase.setCriticalTime(criticalTime);
    }
}
Also used : TestCase(org.sakuli.datamodel.TestCase)

Example 48 with TestCase

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

the class AbstractPerformanceDataBuilder method addTestCasePerformanceData.

/**
     * Generates the performance data for assigned {@link TestCase}s as an {@link String}.
     *
     * @param data      already produced performance data
     * @param testCases {@link SortedSet} of {@link TestCase}s
     * @return formatted payload string
     */
protected static String addTestCasePerformanceData(String data, SortedSet<TestCase> testCases) {
    int i = 1;
    for (TestCase tc : testCases) {
        OutputState tcOutputState = OutputState.lookupSakuliState(tc.getState());
        String prefix = String.format("c_%03d", i);
        data = addPerformanceDataRow(data, prefix + "__state", String.valueOf(tcOutputState.getErrorCode()), null, null);
        data = addPerformanceDataRow4Threshold(data, prefix, tc.getWarningTime(), tc.getCriticalTime());
        final String caseName = prefix + "_" + tc.getId();
        if (tc.getState() != null && tc.getState().isFinishedWithoutErrors()) {
            data = addPerformanceDataRow(data, caseName, tc.getDuration(), tc.getWarningTime(), tc.getCriticalTime());
        } else {
            //add data performance data with unknown state
            data = addUnknownPerformanceDataRow(data, caseName);
        }
        data = addTestCaseStepPerformanceData(data, tc.getStepsAsSortedSet(), i);
        i++;
    }
    return data;
}
Also used : TestCase(org.sakuli.datamodel.TestCase)

Example 49 with TestCase

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

the class RegionImpl method resolveTakeScreenshotFolder.

static Path resolveTakeScreenshotFolder(String filename, BaseActionLoader loader) {
    Path path = Paths.get(filename);
    if (path.isAbsolute()) {
        return path;
    }
    TestCase currentTestCase = loader.getCurrentTestCase();
    Path folderPath = currentTestCase != null ? currentTestCase.getTcFile() : null;
    if (folderPath == null || !Files.exists(folderPath)) {
        LOGGER.warn("The test case folder could be found => Fallback: Use test suite folder!");
        folderPath = loader.getTestSuite().getTestSuiteFolder();
    }
    return folderPath.resolve(filename);
}
Also used : Path(java.nio.file.Path) 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