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());
}
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));
}
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());
}
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());
}
Aggregations