Maven 运行黄瓜特定的功能文件或文件夹黄瓜、文件夹、功能、文件

2023-09-08 10:19:32 作者:孤独留给我

如何使用 maven 命令行中的黄瓜功能选项.在充满功能(测试)的树中,我试图只运行单个功能.就我而言 - 所选文件夹中的所有功能文件.

How is it possible to use the cucumber feature option from maven command line. Of a tree full of features (tests), I'm trying to run only individual features. In my case - all feature files in a selected folder.

我尝试使用以下语法:

mvn install -Dcucumber.options="classpath:com/company/regression/features/administration/"

它运行所有测试.没有错误,也没有评论.我尝试了其他几个选项,但都没有奏效!

It runs all tests. No errors and no comments. I tried several other options and none worked!

我们将不胜感激.

推荐答案

我改变了方法,决定改用标签.现在,我运行一个命令,告诉我要使用哪些标签,并确保在功能文件的开头放置一个特殊标签.我的命令现在看起来像:

I changed my approach, and decided to use tags instead. Now, I run a command that tells me which tags to use and I make sure to put a special tag at the beginning of the feature file. My command now looks like:

mvn install -Dcucumber.options="--tags @runThis --tags ~@ignore --format json-pretty:target/cucumber-report-myReport.json --format html:target/cucumber-html-report-myReport"

我放的标签是 @runThis 而 ~@ignore 是告诉黄瓜 not 运行 @ignore 标签.我还为每次运行创建了不同的报告,因此 Jenkins cucumber 插件可以从所有不同的运行中创建一个报告,并且它们不会相互覆盖.

The tag I put is @runThis and the ~@ignore is to tell cucumber not to run the @ignore tags. I also create a different report for each run, so Jenkins cucumber plugin can create a single report from all the different runs and they don't overwrite each other.

我希望这会有所帮助.

 
精彩推荐
图片推荐