Java 使用JUNIT5运行Cucumber功能文件时无法对其进行筛选

Java 使用JUNIT5运行Cucumber功能文件时无法对其进行筛选,java,gradle,cucumber,junit5,cucumber-java,Java,Gradle,Cucumber,Junit5,Cucumber Java,我能够与cucumber+JUnit5+Gradle组合并行运行cucumber特性文件。但无法过滤需要运行的功能文件 我的功能文件位于“com.automation.runners”路径下的资源文件夹下。并且,@cumber类也位于包名处,但位于java文件夹下; 使用此配置,我可以运行所有功能文件,但我只希望运行一个功能文件 我在“junit platform.properties”中有一个条目cucumber.features=com/automation/runners/Demo.fea

我能够与cucumber+JUnit5+Gradle组合并行运行cucumber特性文件。但无法过滤需要运行的功能文件

我的功能文件位于“com.automation.runners”路径下的资源文件夹下。并且,@cumber类也位于包名处,但位于java文件夹下; 使用此配置,我可以运行所有功能文件,但我只希望运行一个功能文件

我在“junit platform.properties”中有一个条目cucumber.features=com/automation/runners/Demo.feature。但这个解决方案对我不起作用。请帮帮我

如果查看,您将看到
cucumber.features
未列为支持的属性之一。如果您阅读了以下内容:

*某些生成工具不支持
*{@link org.junit.platform.engine.DiscoverySelectors}由使用
*黄瓜。作为一项工作,Cucumber将扫描带注释的
*为要素文件初始化并执行它们。
因此,您的所有功能都将被执行

要运行单个功能,您可以使用with
--select file
或。两者都可以使用

package.com.example;
导入org.junit.platform.engine.DiscoverySelectors;
导入org.junit.platform.launcher.launcher;
导入org.junit.platform.launcher.LauncherDiscoveryRequest;
导入org.junit.platform.launcher.core.launchersdiscoveryRequestBuilder;
导入org.junit.platform.launcher.core.LauncherFactory;
公共类RunSingleFile{
公共静态void main(字符串…参数){
Launcher Launcher=LauncherFactory.create();
LauncherDiscoveryRequest=LauncherDiscoveryRequestBuilder.request()
.selectors(DiscoverySelectors.selectFile(“path/to/my.feature”))
.build();
执行(请求);
}
}

非常感谢Korstanje的帮助!