You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a plugin which process Envelope and may generate exceptions. Depending on the Envelope content, the exceptions are rethrowed or swallowed by Cucumber:
publicclassMyPluginPluginimplementsEventListener, Plugin {
privatefinalEventHandler<Envelope> testParameterTypeHandler = (event) -> {
if (event.getParameterType().isPresent()) {
thrownewRuntimeException("getParameterType");// will be swallowed
} elseif (event.getStepDefinition().isPresent()) {
thrownewRuntimeException("getStepDefinition");// will be swallowed
} elseif (event.getGherkinDocument().isPresent()) {
thrownewRuntimeException("getGherkinDocument");// will be swallowed
} elseif (event.getTestCaseStarted().isPresent()) {
thrownewRuntimeException("getTestCaseStarted");// will be swallowed
} elseif (event.getTestRunFinished().isPresent()) {
//throw new RuntimeException("getTestRunFinished"); // not swallowed
}
};
publicvoidsetEventPublisher(EventPublishereventPublisher) {
eventPublisher.registerHandlerFor(Envelope.class, this.testParameterTypeHandler);
}
}
Note: this is not the real plugin, just a minimalistic one designed to show the problem.
✅ What did you expect to see?
I expect the exceptions generated by the plugin are all rethrown and not swallowed.
📦 Which tool/library version are you using?
Cucumber Java 7.12.0
🔬 How could we reproduce it?
Steps to reproduce the behavior:
create a plugin with the code above
add the plugin to the run configuration of any project which uses Cucumber
run the test with the plugin
no exception is raised
📚 Any additional context?
As a workaround, I currently keep the generated exception aside and throw it when the Envelope contains a TestRunFinished event:
publicclassMyPluginPluginimplementsEventListener, Plugin {
RuntimeExceptionruntimeException = null;
privatefinalEventHandler<Envelope> testParameterTypeHandler = (event) -> {
if (event.getParameterType().isPresent()) {
runtimeException = newRuntimeException("getParameterType");// will be swallowed
} elseif (event.getStepDefinition().isPresent()) {
runtimeException = newRuntimeException("getStepDefinition");// will be swallowed
} elseif (event.getGherkinDocument().isPresent()) {
runtimeException = newRuntimeException("getGherkinDocument");// will be swallowed
} elseif (event.getTestCaseStarted().isPresent()) {
runtimeException = newRuntimeException("getTestCaseStarted");// will be swallowed
} elseif (event.getTestRunFinished().isPresent()) {
//throw new RuntimeException("getTestRunFinished"); // not swallowedif (runtimeException != null) {
throwruntimeException;
}
}
};
publicvoidsetEventPublisher(EventPublishereventPublisher) {
eventPublisher.registerHandlerFor(Envelope.class, this.testParameterTypeHandler);
}
}
The text was updated successfully, but these errors were encountered:
👓 What did you see?
Let's say I have a plugin which process
Envelope
and may generate exceptions. Depending on theEnvelope
content, the exceptions are rethrowed or swallowed by Cucumber:Note: this is not the real plugin, just a minimalistic one designed to show the problem.
✅ What did you expect to see?
I expect the exceptions generated by the plugin are all rethrown and not swallowed.
📦 Which tool/library version are you using?
Cucumber Java 7.12.0
🔬 How could we reproduce it?
Steps to reproduce the behavior:
📚 Any additional context?
As a workaround, I currently keep the generated exception aside and throw it when the
Envelope
contains aTestRunFinished
event:The text was updated successfully, but these errors were encountered: