Cucumber for Java: do not skip failed hooks when the tree of tests built

The fix creates a node for failed hook.

IDEA-185206 Cucumber plugin seems not to include asserts of @After Hooks
This commit is contained in:
Andrey Vokin
2018-03-10 19:25:01 +01:00
parent 46124c7fa6
commit 38afc7d6bb
@@ -128,7 +128,14 @@ public class CucumberJvm2SMFormatter implements Formatter {
private static void handleTestStepFinished(TestStepFinished event) {
if (event.testStep.isHook()) {
return;
if (event.result.getStatus() == FAILED) {
outCommand(String.format(TEMPLATE_TEST_STARTED, getCurrentTime(), "", getStepName(event.testStep)));
outCommand(String.format(TEMPLATE_TEST_FAILED, getCurrentTime(), "",
escape(event.result.getErrorMessage()), getStepName(event.testStep), ""));
} else {
return;
}
}
if (event.result.getStatus() == PASSED) {
// write nothing
@@ -174,7 +181,13 @@ public class CucumberJvm2SMFormatter implements Formatter {
}
private static String getStepName(TestStep step) {
return escape(step.getStepText());
String stepName;
if (step.isHook()) {
stepName = "Hook: " + step.getHookType().toString();
} else {
stepName = step.getStepText();
}
return escape(stepName);
}
private static void outCommand(String s) {