Select cucumber.api.cli.Main 的另一个参赛者?

Select a different runner for cucumber.api.cli.Main?

从 Cucumber 的命令行 (cucumber.api.cli.Main) 开始测试时,是否可以 define/specify 一个 运行ner? 我这样做的原因是我可以在 Jenkins 中生成 xml 报告并将结果推送到 ALM Octane。

我有点继承了这个项目,它使用 gradle 做一个 javaexect 并调用 cucumber.api.cli.Main 我知道在使用 JUnit 运行ner + maven(或仅 JUnit 运行ner)时可以使用 @RunWith(OctaneCucumber.class) 执行此操作,否则该标记将被忽略。我有带有该标签的自定义 运行ner,但是当我从 cucumber.api.cli.Main 运行 时,我找不到使用它 运行 的方法,我的标签就被忽略了。

@Grasshopper 的建议并不完全奏效,但它让我找到了正确的方向。

我没有将代码添加为插件,而是通过创建 cucumber.api.cli.Main 的副本来 "hack/load" octane 报告程序,将其用作 运行 cli 的基础命令并稍微更改 run 方法并在 运行 时间添加插件。需要这样做是因为插件在其构造函数中需要相当多的参数。可能不是完美的解决方案,但它让我可以保留最初的 gradle 构建过程。

public static byte run(String[] argv, ClassLoader classLoader) throws IOException {
    RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv)));

    ResourceLoader resourceLoader = new MultiLoader(classLoader);
    ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);

    //====================Added the following lines ================
    //Hardcoded runner(?) class. If its changed, it will need to be changed here also
    OutputFile outputFile = new OutputFile(Main.class);
    runtimeOptions.addPlugin(new HPEAlmOctaneGherkinFormatter(resourceLoader, runtimeOptions.getFeaturePaths(), outputFile));
    //==============================================================

    runtime.run();

    return runtime.exitStatus();
}