Search in sources :

Example 21 with TestSuiteExampleBuilder

use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildWarningInSuite.

@Test
public void testBuildWarningInSuite() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.WARNING_IN_SUITE).withId("TEST-SUITE-ID").withWarningTime(100).withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[WARN] Sakuli suite \"TEST-SUITE-ID\" warning (120.00s/warn at 100s). (Last suite run: 17.08.14 14:02:00)\n" + "[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 22 with TestSuiteExampleBuilder

use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.

the class AbstractOutputBuilderTest method testFormatTestSuiteStateMessageUnknown.

@Test
public void testFormatTestSuiteStateMessageUnknown() throws Exception {
    TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.RUNNING).withStopDate(null).buildExample();
    String result = testling.formatTestSuiteSummaryStateMessage(testSuiteExample, properties.getTemplateSuiteSummary());
    assertEquals(result, "[UNKN] Sakuli suite \"sakuli-123\" suite still running. (Last suite run: xx)");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 23 with TestSuiteExampleBuilder

use of org.sakuli.builder.TestSuiteExampleBuilder in project sakuli by ConSol.

the class AbstractPerformanceDataBuilderTest method testGetPerformanceData.

@Test
public void testGetPerformanceData() 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(Arrays.asList(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 TestCaseStepExampleBuilder().withName("step2").withState(TestCaseStepState.OK).withStartDate(DateUtils.addSeconds(startDate, 11)).withStopDate(DateUtils.addSeconds(startDate, 19)).withWarningTime(10).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.OK).withId("case with no steps").withStartDate(DateUtils.addSeconds(startDate, 25)).withStopDate(DateUtils.addSeconds(startDate, 40)).withWarningTime(0).withCriticalTime(0).withTestCaseSteps(null).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=8.00s;10;;; " + "c_002__state=0;;;; " + "c_002_case_with_no_steps=15.00s;;;;");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) BaseTest(org.sakuli.BaseTest) Test(org.testng.annotations.Test)

Aggregations

TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)23 TestSuite (org.sakuli.datamodel.TestSuite)21 Test (org.testng.annotations.Test)21 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)15 SakuliException (org.sakuli.exceptions.SakuliException)8 BaseTest (org.sakuli.BaseTest)6 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 Date (java.util.Date)3 Path (java.nio.file.Path)2 NagiosOutput (org.sakuli.services.forwarder.gearman.model.NagiosOutput)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 LoggerTest (org.sakuli.LoggerTest)1 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)1 TestCaseStepState (org.sakuli.datamodel.state.TestCaseStepState)1 SakuliActionException (org.sakuli.exceptions.SakuliActionException)1 SakuliExceptionHandler (org.sakuli.exceptions.SakuliExceptionHandler)1 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)1 NagiosCachedCheckResult (org.sakuli.services.forwarder.gearman.model.NagiosCachedCheckResult)1