diff --git a/karate-core/src/main/java/com/intuit/karate/core/Step.java b/karate-core/src/main/java/com/intuit/karate/core/Step.java index 47566b77a..4a7215710 100644 --- a/karate-core/src/main/java/com/intuit/karate/core/Step.java +++ b/karate-core/src/main/java/com/intuit/karate/core/Step.java @@ -43,12 +43,22 @@ public class Step { private Table table; public String getDebugInfo() { - String scenarioName = StringUtils.trimToNull(scenario.getName()); - String message = "feature: " + scenario.getFeature().getRelativePath(); - if (scenarioName != null) { - message = message + ", scenario: " + scenarioName; - } - return message + ", line: " + line; + String message = "feature: "; + + if(isBackground()) { + String featureName = StringUtils.trimToNull(feature.getName()); + message += feature.getRelativePath(); + if (featureName != null) { + message = message + ", feature: " + featureName; + } + } else { + String scenarioName = StringUtils.trimToNull(scenario.getName()); + message = "feature: " + scenario.getFeature().getRelativePath(); + if (scenarioName != null) { + message += ", scenario: " + scenarioName; + } + } + return message + ", line: " + line; } public boolean isPrint() {