Can I run a specific testng test group via maven?
Asked Answered
B

3

31

I have several testng test groups, e.g. group1,group2,group3... These are defined in my pom.xml and all get run when I execute "mvn test". What do I need to run to only execute one group without having to modify the groups configured in the pom.xml.

i.e mvn test group2 mvn test group1 mvn test group3

Bowstring answered 27/5, 2010 at 15:42 Comment(0)
S
55

Try

mvn test -Dgroups=group3,group2
Schreiner answered 27/5, 2010 at 15:52 Comment(1)
Is there any way to run tests having BOTH group3 and group2?Aleurone
A
7

I came across this question while looking how to disable particular test group and Radadiya's answer confused me a bit.

To run particular groups use this, as mentioned by Eugene Kuleshov. docs

mvn test -Dgroups=group1,group2

But to exclude some group, use this (note excluded vs exclude). docs .

mvn test -DexcludedGroups=group3,group4
Adorne answered 25/5, 2018 at 10:55 Comment(0)
R
2

You can include and exclude specific group during maven test execution.

(1) Include Specific Groups

mvn clean test -DincludeGroups=TestGroup1,TestGroup2

(2) Exclude Specific Groups

mvn clean test -DexcludeGroups=TestGroup3,TestGroup4
Radix answered 14/3, 2018 at 16:52 Comment(2)
See Mikalai's post below with links to maven documentation.Cascarilla
includeGroups doesn't seem to exist. Use the suggested groupsEshman

© 2022 - 2024 — McMap. All rights reserved.