use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.
the class AbstractPerformanceDataBuilderTest method testGetPerformanceDataWithPreParsedSteps.
@Test
public void testGetPerformanceDataWithPreParsedSteps() throws Exception {
Date startDate = new GregorianCalendar(2014, 14, 7, 13, 0).getTime();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 120)).withWarningTime(100).withCriticalTime(150).withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withState(TestCaseState.WARNING_IN_STEP).withId("case-warning").withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 20)).withWarningTime(19).withCriticalTime(25).withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withName("step1").withState(TestCaseStepState.WARNING).withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 10)).withWarningTime(9).buildExample(), new TestCaseStepBuilder("step2_not_started").withState(TestCaseStepState.INIT).build())).buildExample())).buildExample();
testSuiteExample.refreshState();
assertEquals(AbstractPerformanceDataBuilder.getTestSuitePerformanceData(testSuiteExample), "suite__state=1;;;; " + "suite__warning=100s;;;; " + "suite__critical=150s;;;; " + "suite_sakuli-123=120.00s;100;150;; " + "c_001__state=1;;;; " + "c_001__warning=19s;;;; " + "c_001__critical=25s;;;; " + "c_001_case-warning=20.00s;19;25;; " + "s_001_001_step1=10.00s;9;;; " + "s_001_002_step2_not_started=U;;;;");
}
use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.
the class CacheHandlingResultServiceImplTest method init.
@BeforeMethod
public void init() {
testSuite = new TestSuiteExampleBuilder().withId("LOG_TEST_SUITE").withState(TestSuiteState.ERRORS).withException(new SakuliException("TEST")).buildExample();
exceptionHandler = Mockito.mock(SakuliExceptionHandler.class);
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
ReflectionTestUtils.setField(testling, "exceptionHandler", exceptionHandler);
}
use of org.sakuli.builder.TestSuiteExampleBuilder 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);
}
use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.
the class AbstractOutputBuilderTest method testFormatTestSuiteStateMessageOK.
@Test
public void testFormatTestSuiteStateMessageOK() throws Exception {
Date startDate = new Date();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.OK).withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 120)).buildExample();
String result = testling.formatTestSuiteSummaryStateMessage(testSuiteExample, properties.getTemplateSuiteSummary());
String lastRun = AbstractOutputBuilder.dateFormat.format(testSuiteExample.getStopDate());
assertEquals(result, "[OK] Sakuli suite \"sakuli-123\" ok (120.00s). (Last suite run: " + lastRun + ")");
}
use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.
the class AbstractOutputBuilderTest method testFormatTestSuiteStateMessageException.
@Test
public void testFormatTestSuiteStateMessageException() throws Exception {
Date startDate = new Date();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.ERRORS).withStartDate(startDate).withException(new SakuliException("TEST-ERROR")).withStopDate(DateUtils.addSeconds(startDate, 120)).buildExample();
String result = testling.formatTestSuiteSummaryStateMessage(testSuiteExample, properties.getTemplateSuiteSummary());
String lastRun = AbstractOutputBuilder.dateFormat.format(testSuiteExample.getStopDate());
assertEquals(result, "[CRIT] Sakuli suite \"sakuli-123\" (120.00s) EXCEPTION: 'TEST-ERROR'. (Last suite run: " + lastRun + ")");
}
Aggregations