Search in sources :

Example 1 with TestResultMessage

use of org.guvnor.common.services.shared.test.TestResultMessage in project drools-wb by kiegroup.

the class ScenarioRunnerServiceTest method testRunEmptyScenario.

@Test
public void testRunEmptyScenario() throws Exception {
    initKieSession();
    TestScenarioResult result = service.run("userName", makeScenario("test.scenario"), new KieModule());
    assertNotNull(result);
    ArgumentCaptor<TestResultMessage> argumentCaptor = ArgumentCaptor.forClass(TestResultMessage.class);
    verify(defaultTestResultMessageEvent).fire(argumentCaptor.capture());
    assertEquals("userName", argumentCaptor.getValue().getIdentifier());
}
Also used : TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 2 with TestResultMessage

use of org.guvnor.common.services.shared.test.TestResultMessage in project drools-wb by kiegroup.

the class ScenarioRunnerService method run.

private void run(final String identifier, final ScenarioRunner4JUnit scenarioRunner, final Event<TestResultMessage> testResultMessageEvent) {
    final List<org.guvnor.common.services.shared.test.Failure> failures = new ArrayList<org.guvnor.common.services.shared.test.Failure>();
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new RunListener() {

        @Override
        public void testAssumptionFailure(Failure failure) {
            failures.add(failureToFailure(failure));
        }
    });
    Result result = jUnitCore.run(scenarioRunner);
    failures.addAll(failuresToFailures(result.getFailures()));
    testResultMessageEvent.fire(new TestResultMessage(identifier, result.getRunCount(), result.getRunTime(), failures));
}
Also used : JUnitCore(org.junit.runner.JUnitCore) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) ArrayList(java.util.ArrayList) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) ScenarioUtil.failureToFailure(org.drools.workbench.screens.testscenario.backend.server.ScenarioUtil.failureToFailure) Failure(org.junit.runner.notification.Failure)

Example 3 with TestResultMessage

use of org.guvnor.common.services.shared.test.TestResultMessage in project drools-wb by kiegroup.

the class ScenarioRunnerServiceTest method testRunSeveralScenarios.

@Test
public void testRunSeveralScenarios() throws Exception {
    initKieSession();
    Path path = mock(Path.class);
    ArrayList<Scenario> scenarios = new ArrayList<Scenario>();
    scenarios.add(makeScenario("test1.scenario"));
    scenarios.add(makeScenario("test2.scenario"));
    scenarios.add(makeScenario("test3.scenario"));
    when(scenarioLoader.loadScenarios(path)).thenReturn(scenarios);
    service.runAllTests("userName", path);
    ArgumentCaptor<TestResultMessage> argumentCaptor = ArgumentCaptor.forClass(TestResultMessage.class);
    verify(defaultTestResultMessageEvent).fire(argumentCaptor.capture());
    assertEquals("userName", argumentCaptor.getValue().getIdentifier());
}
Also used : Path(org.uberfire.backend.vfs.Path) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) ArrayList(java.util.ArrayList) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 4 with TestResultMessage

use of org.guvnor.common.services.shared.test.TestResultMessage in project drools-wb by kiegroup.

the class ScenarioRunnerServiceTest method testScenario.

private void testScenario(String scenarioName, boolean isExpectedSuccess) throws Exception {
    final KieModule module = mock(KieModule.class);
    final URL scenarioResource = getClass().getResource(scenarioName);
    final Path scenarioPath = PathFactory.newPath(scenarioResource.getFile(), scenarioResource.toURI().toString());
    final Scenario scenario = testEditorService.load(scenarioPath);
    assertFalse(scenario.wasSuccessful());
    final TestScenarioResult result = service.run("userName", scenario, module);
    assertEquals(isExpectedSuccess, scenario.wasSuccessful());
    assertEquals(isExpectedSuccess, result.getScenario().wasSuccessful());
    verify(defaultTestResultMessageEvent).fire(testResultMessageCaptor.capture());
    final TestResultMessage resultMessage = testResultMessageCaptor.getValue();
    assertEquals(isExpectedSuccess, resultMessage.getFailures().size() == 0);
    assertEquals(isExpectedSuccess, resultMessage.wasSuccessful());
}
Also used : Path(org.uberfire.backend.vfs.Path) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) KieModule(org.kie.workbench.common.services.shared.project.KieModule) URL(java.net.URL) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Aggregations

TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)4 TestScenarioResult (org.drools.workbench.screens.testscenario.model.TestScenarioResult)3 ArrayList (java.util.ArrayList)2 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)2 Test (org.junit.Test)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 Path (org.uberfire.backend.vfs.Path)2 URL (java.net.URL)1 ScenarioUtil.failureToFailure (org.drools.workbench.screens.testscenario.backend.server.ScenarioUtil.failureToFailure)1 JUnitCore (org.junit.runner.JUnitCore)1 Result (org.junit.runner.Result)1 Failure (org.junit.runner.notification.Failure)1 RunListener (org.junit.runner.notification.RunListener)1