From 38afc7d6bb36d3a077ffad7c10610e6cbcacd9d6 Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Sat, 10 Mar 2018 19:22:28 +0100 Subject: [PATCH] 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 --- .../java/run/CucumberJvm2SMFormatter.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2SMFormatter.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2SMFormatter.java index 71bd25700993..8f5865884627 100644 --- a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2SMFormatter.java +++ b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2SMFormatter.java @@ -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) {