简体   繁体   English

Maven 在某些组中运行测试

[英]Maven run tests in some groups

I have got such 3 groups (3 tests) in my testng project code, for example:我的 testng 项目代码中有这样的 3 个组(3 个测试),例如:

groups = {"iOS", "Android", "Sync"})

groups = {"iOS", "Sync"})

groups = {"Android", "Sync"})

How can I run all tests which contain some groups, for example: "Android" AND "Sync"?如何运行包含某些组的所有测试,例如:“Android”“同步”?

If I run:如果我运行:

mvn clean test -PAndroid -Dgroups=Android,Sync

I will run all 3 tests because this syntax works: "Android" OR "Sync", but I need only the first and the third test to be run.我将运行所有 3 个测试,因为此语法有效:“Android”“同步”,但我只需要运行第一个和第三个测试。

Why dont you try a tag expression Android&Sync为什么不试试标签表达式Android&Sync

https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions

This might require some single or double quotes on your command line这可能需要在命令行上使用一些单引号或双引号

(perhaps "-Dgroups=Android&Sync" - though I havent tried it.) (也许是"-Dgroups=Android&Sync" ——虽然我还没有尝试过。)

You can try using by creating the profiles of your groups in maven.您可以通过在 maven 中创建您的组的配置文件来尝试使用。

or或者

You it like this- Dgroups='Andriod', -Dgroups='sync'你喜欢这个 - Dgroups='Andriod', -Dgroups='sync'

Another way is, exclude IOS group, use this (note excluded vs exclude).另一种方法是,排除IOS组,使用这个(注意排除与排除)。 here is docs 这是文档

mvn test -DexcludedGroups==IOS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM