Search in sources :

Example 1 with TestCaseStepState

use of org.sakuli.datamodel.state.TestCaseStepState in project sakuli by ConSol.

the class CommonResultServiceImplTest method testSaveAllResults.

@Test(dataProvider = "states")
public void testSaveAllResults(TestSuiteState testSuiteState, TestCaseState testCaseState, String stateOutputRegex) throws Exception {
    TestCaseStepState stepState = TestCaseStepState.WARNING;
    TestSuite testSuite = new TestSuiteExampleBuilder().withId("LOG_TEST_SUITE").withState(testSuiteState).withException(testSuiteState.isError() ? new SakuliException("TEST") : null).withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(stepState).buildExample())).withState(testCaseState).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Path logfile = Paths.get(properties.getLogFile());
    testling.saveAllResults();
    String lastLineOfLogFile = getLastLineOfLogFile(logfile, testSuiteState.isError() ? 42 : 39);
    List<String> regExes = getValidationExpressions(testSuiteState, testCaseState, stepState, stateOutputRegex, "TEST");
    List<String> strings = Arrays.asList(lastLineOfLogFile.split("\n"));
    Iterator<String> regExIterator = regExes.iterator();
    verifyOutputLines(strings, regExIterator);
}
Also used : Path(java.nio.file.Path) TestSuite(org.sakuli.datamodel.TestSuite) SakuliException(org.sakuli.exceptions.SakuliException) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestCaseStepState(org.sakuli.datamodel.state.TestCaseStepState) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) LoggerTest(org.sakuli.LoggerTest)

Aggregations

Path (java.nio.file.Path)1 LoggerTest (org.sakuli.LoggerTest)1 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)1 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)1 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)1 TestSuite (org.sakuli.datamodel.TestSuite)1 TestCaseStepState (org.sakuli.datamodel.state.TestCaseStepState)1 SakuliException (org.sakuli.exceptions.SakuliException)1 Test (org.testng.annotations.Test)1