Skip to content

Commit 57af52c

Browse files
author
dr29abrt
committed
#2974: Add overrideGroupsFromCliInParentChildXml test
1 parent 91a003a commit 57af52c

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package test.cli.github2974;
2+
3+
import java.util.List;
4+
import org.testng.Assert;
5+
import org.testng.CommandLineArgs;
6+
import org.testng.TestNG;
7+
import org.testng.annotations.Test;
8+
import test.SimpleBaseTest;
9+
10+
public class OverrideGroupsCliTest extends SimpleBaseTest {
11+
12+
@Test(description = "GITHUB-2974")
13+
public void overrideGroupsFromCliInParentChildXml() {
14+
TestNG testNG =
15+
new TestNG(false) {
16+
{
17+
CommandLineArgs args = new CommandLineArgs();
18+
args.groups = "override_group";
19+
args.suiteFiles = List.of(getPathToResource("2974/parent.xml"));
20+
configure(args);
21+
}
22+
};
23+
testNG.run();
24+
Assert.assertTrue(TwoGroupsTest.NAMES.contains("must run"));
25+
Assert.assertFalse(TwoGroupsTest.NAMES.contains("must not run"));
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package test.cli.github2974;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import org.testng.annotations.Test;
6+
7+
public class TwoGroupsTest {
8+
9+
public static final List<String> NAMES = new ArrayList<>();
10+
11+
@Test(groups = {"override_group"})
12+
public void test1() {
13+
NAMES.add("must run");
14+
}
15+
16+
@Test(groups = {"default_group"})
17+
public void test2() {
18+
NAMES.add("must not run");
19+
}
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
2+
<suite name="child">
3+
4+
<test name="Tests inherit groups from parent xml">
5+
<classes>
6+
<class name="test.cli.github2974.TwoGroupsTest"/>
7+
</classes>
8+
</test>
9+
</suite>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
2+
<suite name="parent suite with default group" parallel="methods" thread-count="1">
3+
4+
<groups>
5+
<run>
6+
<include name="default_group"/>
7+
</run>
8+
</groups>
9+
<suite-files>
10+
<suite-file path="child.xml"/>
11+
</suite-files>
12+
</suite>

testng-core/src/test/resources/testng.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<class name="test.github765.ExcludeSyntheticMethodsFromTemplateCallsTest"/>
110110
<class name="test.github1405.TestExclusionOfMainMethod"/>
111111
<class name="test.cli.CliTest"/>
112+
<class name="test.cli.github2974.OverrideGroupsCliTest"/>
112113
<class name="test.thread.ParallelSuiteTest"/>
113114
<class name="test.simple.IncludedExcludedTest" />
114115
<class name="test.reports.ReportTest" />

0 commit comments

Comments
 (0)