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

时间:2022-04-05 22:55:32

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.

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

I've tried to use the following syntax:

我试过使用以下语法:

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!

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

Any help here will be greatly appreciated.

任何帮助将非常感谢。

1 个解决方案

#1


23  

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"

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.

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

I hope this helps.

我希望这有帮助。

#1


23  

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"

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.

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

I hope this helps.

我希望这有帮助。