Skip to content

Commit c6c8360

Browse files
committed
[Core] Implement TeamCity output format plugin
This plugin inserts markers that can be picked up by IDEA and Teamcity. These in turn can then use this information to display a test tree and show the output grouped by scenario. This is plugin is nessesary because Intelij keeps using reflection to extract more information from the plugin system then what would normally be available. By substituting the CucumberJvm[1-5]SMFormatter with this plugin we avoid runtime errors. Unfortunately the teamcity format is poorly documented[1]. Reverse engingeering[2][3] the format from the plugin yields some information but the exact function is rather opaque. 1. https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-MessageFlowId 2. https://github.com/JetBrains/intellij-community/tree/master/plugins/cucumber-jvm-formatter5/src/org/jetbrains/plugins/cucumber/java/run 3. https://github.com/mpkorstanje/intellij-community/blob/master/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run
1 parent de3f234 commit c6c8360

File tree

19 files changed

+629
-69
lines changed

19 files changed

+629
-69
lines changed

core/src/main/java/io/cucumber/core/options/PluginOption.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.cucumber.core.plugin.PrettyFormatter;
1313
import io.cucumber.core.plugin.ProgressFormatter;
1414
import io.cucumber.core.plugin.RerunFormatter;
15+
import io.cucumber.core.plugin.TeamCityPlugin;
1516
import io.cucumber.core.plugin.TestNGFormatter;
1617
import io.cucumber.core.plugin.TimelineFormatter;
1718
import io.cucumber.core.plugin.UnusedStepsSummaryPrinter;
@@ -44,15 +45,16 @@ public class PluginOption implements Options.Plugin {
4445
put("timeline", TimelineFormatter.class);
4546
put("unused", UnusedStepsSummaryPrinter.class);
4647
put("usage", UsageFormatter.class);
48+
put("teamcity", UsageFormatter.class);
4749
}};
4850

4951
// Refuse plugins known to implement the old API
50-
private static final HashMap<String, Class<? extends Plugin>> OLD_INTELLIJ_IDEA_PLUGIN_CLASSES = new HashMap<String, Class<? extends Plugin>>() {{
51-
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatter", PrettyFormatter.class);
52-
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter", PrettyFormatter.class);
53-
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter", PrettyFormatter.class);
54-
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm4SMFormatter", PrettyFormatter.class);
55-
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter", PrettyFormatter.class);
52+
private static final HashMap<String, Class<? extends Plugin>> INCOMPATIBLE_INTELLIJ_IDEA_PLUGIN_CLASSES = new HashMap<String, Class<? extends Plugin>>() {{
53+
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatter", TeamCityPlugin.class);
54+
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter", TeamCityPlugin.class);
55+
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter", TeamCityPlugin.class);
56+
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm4SMFormatter", TeamCityPlugin.class);
57+
put("org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter", TeamCityPlugin.class);
5658
}};
5759

5860
private final String pluginString;
@@ -76,9 +78,9 @@ public static PluginOption parse(String pluginArgumentPattern) {
7678
}
7779

7880
private static Class<? extends Plugin> parsePluginName(String pluginName) {
79-
Class<? extends Plugin> oldApiPlugin = OLD_INTELLIJ_IDEA_PLUGIN_CLASSES.get(pluginName);
81+
Class<? extends Plugin> oldApiPlugin = INCOMPATIBLE_INTELLIJ_IDEA_PLUGIN_CLASSES.get(pluginName);
8082
if (oldApiPlugin != null) {
81-
log.warn(() -> "Incompatible IntelliJ IDEA Plugin detected. Falling back to pretty formatter");
83+
log.debug(() -> "Incompatible IntelliJ IDEA Plugin detected. Falling back to teamcity plugin");
8284
return oldApiPlugin;
8385
}
8486

0 commit comments

Comments
 (0)