use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.
the class ScenarioRunnerService method runAllTests.
@Override
public void runAllTests(final String identifier, final Path path, final Event<TestResultMessage> customTestResultEvent) {
try {
final List<Scenario> scenarios = scenarioLoader.loadScenarios(path);
ScenarioRunner4JUnit scenarioRunner = new ScenarioRunner4JUnit(scenarios, getKSessions(path, scenarios), getMaxRuleFirings());
run(identifier, scenarioRunner, customTestResultEvent);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.drools.workbench.models.testscenarios.shared.Scenario in project drools-wb by kiegroup.
the class ScenarioRunnerServiceTest method makeScenario.
private Scenario makeScenario(String name) {
Scenario scenario = new Scenario();
scenario.setName(name);
return scenario;
}
use of org.drools.workbench.models.testscenarios.shared.Scenario 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.drools.workbench.models.testscenarios.shared.Scenario 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