use of gherkin.formatter.model.Match in project cucumber-jvm by cucumber.
the class JavaStepDefinitionTest method does_not_throw_ambiguous_when_nothing_is_ambiguous.
@Test
public void does_not_throw_ambiguous_when_nothing_is_ambiguous() throws Throwable {
backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
Reporter reporter = new Reporter() {
@Override
public void before(Match match, Result result) {
throw new UnsupportedOperationException();
}
@Override
public void result(Result result) {
if (result.getError() != null) {
throw new RuntimeException(result.getError());
}
}
@Override
public void after(Match match, Result result) {
throw new UnsupportedOperationException();
}
@Override
public void match(Match match) {
}
@Override
public void embedding(String mimeType, byte[] data) {
}
@Override
public void write(String text) {
}
};
runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
Tag tag = new Tag("@foo", 0);
Set<Tag> tags = asSet(tag);
runtime.runBeforeHooks(reporter, tags);
Step step = new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null);
runtime.runStep("some.feature", step, reporter, ENGLISH);
assertTrue(defs.foo);
assertFalse(defs.bar);
}
use of gherkin.formatter.model.Match in project cucumber-jvm by cucumber.
the class Runtime method runHookIfTagsMatch.
private void runHookIfTagsMatch(HookDefinition hook, Reporter reporter, Set<Tag> tags, boolean isBefore) {
if (hook.matches(tags)) {
String status = Result.PASSED;
Throwable error = null;
Match match = new Match(Collections.<Argument>emptyList(), hook.getLocation(false));
stopWatch.start();
try {
hook.execute(scenarioResult);
} catch (Throwable t) {
error = t;
status = isPending(t) ? "pending" : Result.FAILED;
addError(t);
skipNextStep = true;
} finally {
long duration = stopWatch.stop();
Result result = new Result(status, duration, error, DUMMY_ARG);
addHookToCounterAndResult(result);
if (isBefore) {
reporter.before(match, result);
} else {
reporter.after(match, result);
}
}
}
}
use of gherkin.formatter.model.Match in project cucumber-jvm by cucumber.
the class JUnitReporterTest method after_with_pending_exception_non_strict.
@Test
public void after_with_pending_exception_non_strict() {
createNonStrictReporter();
createDefaultRunNotifier();
Result result = mock(Result.class);
Match match = mock(Match.class);
when(result.getStatus()).thenReturn("Pending");
when(result.getError()).thenReturn(new PendingException());
EachTestNotifier executionUnitNotifier = mock(EachTestNotifier.class);
jUnitReporter.executionUnitNotifier = executionUnitNotifier;
jUnitReporter.after(match, result);
jUnitReporter.finishExecutionUnit();
verify(executionUnitNotifier).fireTestIgnored();
}
use of gherkin.formatter.model.Match in project cucumber-jvm by cucumber.
the class JUnitReporterTest method forward_calls_to_reporter_interface_methods.
@Test
public void forward_calls_to_reporter_interface_methods() throws Exception {
Match match = mock(Match.class);
Result result = mockResult();
ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner();
String mimeType = "mimeType";
byte[] data = new byte[] { 1 };
String text = "text";
Reporter reporter = mock(Reporter.class);
jUnitReporter = new JUnitReporter(reporter, mock(Formatter.class), false, new JUnitOptions(Collections.<String>emptyList()));
jUnitReporter.startExecutionUnit(executionUnitRunner, mock(RunNotifier.class));
jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
jUnitReporter.before(match, result);
jUnitReporter.step(mockStep());
jUnitReporter.match(match);
jUnitReporter.embedding(mimeType, data);
jUnitReporter.write(text);
jUnitReporter.result(result);
jUnitReporter.after(match, result);
verify(reporter).before(match, result);
verify(reporter).match(match);
verify(reporter).embedding(mimeType, data);
verify(reporter).write(text);
verify(reporter).result(result);
verify(reporter).after(match, result);
}
use of gherkin.formatter.model.Match in project cucumber-jvm by cucumber.
the class JUnitReporterTest method before_with_pending_exception_strict.
@Test
public void before_with_pending_exception_strict() {
createStrictReporter();
createDefaultRunNotifier();
Result result = mock(Result.class);
Match match = mock(Match.class);
when(result.getStatus()).thenReturn("Pending");
when(result.getError()).thenReturn(new PendingException());
EachTestNotifier executionUnitNotifier = mock(EachTestNotifier.class);
jUnitReporter.executionUnitNotifier = executionUnitNotifier;
jUnitReporter.before(match, result);
verifyAddFailureWithPendingException(executionUnitNotifier);
}
Aggregations