如何在 jenkins 中执行之前将黄瓜标签作为参数传递并在测试运行器文件中更新?



我是 Jenkins 的新手,想从 Jenkins 传递一个像 cucumber tag 这样的参数,它应该在测试运行器文件中动态更新,然后应该开始执行。请分享我的代码或屏幕截图。

除了 UnknownBeast 之外,在 Cucumber v6 及更高版本中,您不能再将cucumber.options与字符串等命令行一起使用。相反,您必须使用单个属性。

mvn test -Dcucumber.filter.tags="(@cucumber or @gherkin) and not @salad"

支持的属性包括:

cucumber.ansi-colors.disabled=  # true or false. default: false                     
cucumber.execution.dry-run=     # true or false. default: false 
cucumber.execution.limit=       # number of scenarios to execute (CLI only).  
cucumber.execution.order=       # lexical, reverse, random or random:[seed] (CLI only). default: lexical
cucumber.execution.strict=      # true or false. default: false.
cucumber.execution.wip=         # true or false. default: false.
cucumber.features=              # command separated paths to feature files. example: path/to/example.feature, path/to/other.feature  
cucumber.filter.name=           # regex. example: .*Hello.*
cucumber.filter.tags=           # tag expression. example: @smoke and not @slow 
cucumber.glue=                  # comma separated package names. example: com.example.glue  
cucumber.plugin=                # comma separated plugin strings. example: pretty, json:path/to/report.json
cucumber.object-factory=        # object factory class name. example: com.example.MyObjectFactory
cucumber.snippet-type=          # underscore or camelcase. default: underscore

从 https://github.com/cucumber/cucumber-jvm/tree/master/core#properties-environment-variables-system-options

如果你想运行与标签关联的测试用例,这就是我们指定的方式:mvn test -Dcucumber.options="–tags @tag Name">

所以你可以做什么,在 Jenkins 作业中设置参数,然后你可以使用上面的 maven 命令执行测试脚本。因此,标签名称将来自您在 Jenkins 作业中设置的参数。

最新更新