Search in sources :

Example 31 with TestSuite

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

the class Icinga2OutputBuilderTest method testBuildCritical.

@Test
public void testBuildCritical() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.CRITICAL_IN_SUITE).withCriticalTime(100).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" critical (120.00s/crit 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 32 with TestSuite

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

the class Icinga2OutputBuilderTest method testBuildWarningInCase.

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

Example 33 with TestSuite

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

the class Icinga2OutputBuilderTest method testBuildErrorInStep.

@Test
public void testBuildErrorInStep() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.ERRORS).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliException("MY-TEST-ERROR-IN-STEP")).buildExample())).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP'. (Last suite run: 17.08.14 14:02:00)\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) SakuliException(org.sakuli.exceptions.SakuliException) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test)

Example 34 with TestSuite

use of org.sakuli.datamodel.TestSuite 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 35 with TestSuite

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

the class TestCaseStepHelperTest method testWriteCachedStepsError.

@Test
public void testWriteCachedStepsError() throws Throwable {
    Path tcFile = getResource("stephelper/tc.js");
    TestSuite testSuite = mock(TestSuite.class);
    TestCase tc = mock(TestCase.class);
    when(tc.getTcFile()).thenReturn(tcFile);
    when(tc.getSteps()).thenReturn(Arrays.asList(new TestCaseStepBuilder("step_warning").withState(TestCaseStepState.WARNING).build(), new TestCaseStepBuilder("step_ok").withState(TestCaseStepState.OK).build(), new TestCaseStepBuilder("step_not_started_1").build(), new TestCaseStepBuilder("step_not_started_2").build()));
    when(testSuite.getTestCases()).thenReturn(Collections.singletonMap("1", tc));
    TestCaseStepHelper.writeCachedStepDefinitions(testSuite);
    Path cacheFile = getResource(CACHEFILE_NAME);
    assertTrue(Files.exists(cacheFile));
    assertEquals(FileUtils.readFileToString(cacheFile.toFile(), Charset.forName("UTF-8")), "step_warning\nstep_ok\nstep_not_started_1\nstep_not_started_2\n");
}
Also used : Path(java.nio.file.Path) TestSuite(org.sakuli.datamodel.TestSuite) TestCase(org.sakuli.datamodel.TestCase) TestCaseStepBuilder(org.sakuli.datamodel.builder.TestCaseStepBuilder) BaseTest(org.sakuli.BaseTest) Test(org.testng.annotations.Test)

Aggregations

TestSuite (org.sakuli.datamodel.TestSuite)41 Test (org.testng.annotations.Test)34 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)21 BaseTest (org.sakuli.BaseTest)15 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)15 TestCase (org.sakuli.datamodel.TestCase)13 SakuliException (org.sakuli.exceptions.SakuliException)7 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 TestCaseStep (org.sakuli.datamodel.TestCaseStep)6 Path (java.nio.file.Path)5 Date (java.util.Date)5 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)2 SakuliInitException (org.sakuli.exceptions.SakuliInitException)2 FileNotFoundException (java.io.FileNotFoundException)1 Entry (java.util.Map.Entry)1 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 DateTime (org.joda.time.DateTime)1 Matchers.anyString (org.mockito.Matchers.anyString)1 LoggerTest (org.sakuli.LoggerTest)1