如何解决如何使用 Cucumber 运行时的试运行通过标签名称获取场景名称
我们正在将我们的自动化框架从 info.cukes 迁移到 io.cucumber。 以下实现是使用 info.cukes runtimeoptions 完成的,并且效果很好。
List<String> arguments = new ArrayList<>();
arguments.add(".featureFile");
arguments.add("--tags");
arguments.add(tagValue);
arguments.add("--dry-run");
arguments.add("--strict");
final String[] argv = arguments.toArray(new String[0]);
log.debug("Argument value for Dry Run: "+argv);
List<String> scenarioNames = new LinkedList<>();
try {
RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<>(Arrays.asList(argv)));
MultiLoader resourceLoader = new MultiLoader(this.getClass().getClassLoader());
List<CucumberFeature> features = runtimeOptions.cucumberFeatures(resourceLoader);
for (int i = 0; i < features.size(); i++)
for (int j = 0; j < features.get(i).getFeatureElements().size(); j++)
scenarioNames.add(features.get(i).getFeatureElements().get(j).getGherkinModel().getName());
现在我已经尝试了 io.cucumber runtimeoptions 中的以下选项,但是,它不根据提供的标签值检索所有功能文件详细信息。
//从cli创建runtimeOptions https://github.com/cucumber/cucumber-jvm/blob/ad17c7416f64a9427d7cec3e362e2eb267560b2c/core/src/main/java/io/cucumber/core/cli/Main.java
io.cucumber.core.options.RuntimeOptions runOptions = this.runTimeOptionIoCucumber(argv);;
FeatureParser featureParser = new FeatureParser(() -> new CommonFunction().getUUID());
FeaturePathFeatureSupplier featureFile = new FeaturePathFeatureSupplier(() -> Thread.currentThread().getContextClassLoader(),runOptions,featureParser);
List<Feature> featuresNew = featureFile.get();
注意:不是在寻找带有钩子的解决方案
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。