Skip to content

Commit

Permalink
#2974: Add overrideGroupsFromCliInParentChildXml test
Browse files Browse the repository at this point in the history
  • Loading branch information
dr29abrt committed Aug 31, 2023
1 parent 91a003a commit 57af52c
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package test.cli.github2974;

import java.util.List;
import org.testng.Assert;
import org.testng.CommandLineArgs;
import org.testng.TestNG;
import org.testng.annotations.Test;
import test.SimpleBaseTest;

public class OverrideGroupsCliTest extends SimpleBaseTest {

@Test(description = "GITHUB-2974")
public void overrideGroupsFromCliInParentChildXml() {
TestNG testNG =
new TestNG(false) {
{
CommandLineArgs args = new CommandLineArgs();
args.groups = "override_group";
args.suiteFiles = List.of(getPathToResource("2974/parent.xml"));
configure(args);
}
};
testNG.run();
Assert.assertTrue(TwoGroupsTest.NAMES.contains("must run"));
Assert.assertFalse(TwoGroupsTest.NAMES.contains("must not run"));
}
}
20 changes: 20 additions & 0 deletions testng-core/src/test/java/test/cli/github2974/TwoGroupsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package test.cli.github2974;

import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.Test;

public class TwoGroupsTest {

public static final List<String> NAMES = new ArrayList<>();

@Test(groups = {"override_group"})
public void test1() {
NAMES.add("must run");
}

@Test(groups = {"default_group"})
public void test2() {
NAMES.add("must not run");
}
}
9 changes: 9 additions & 0 deletions testng-core/src/test/resources/2974/child.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="child">

<test name="Tests inherit groups from parent xml">
<classes>
<class name="test.cli.github2974.TwoGroupsTest"/>
</classes>
</test>
</suite>
12 changes: 12 additions & 0 deletions testng-core/src/test/resources/2974/parent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="parent suite with default group" parallel="methods" thread-count="1">

<groups>
<run>
<include name="default_group"/>
</run>
</groups>
<suite-files>
<suite-file path="child.xml"/>
</suite-files>
</suite>
1 change: 1 addition & 0 deletions testng-core/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<class name="test.github765.ExcludeSyntheticMethodsFromTemplateCallsTest"/>
<class name="test.github1405.TestExclusionOfMainMethod"/>
<class name="test.cli.CliTest"/>
<class name="test.cli.github2974.OverrideGroupsCliTest"/>
<class name="test.thread.ParallelSuiteTest"/>
<class name="test.simple.IncludedExcludedTest" />
<class name="test.reports.ReportTest" />
Expand Down

0 comments on commit 57af52c

Please sign in to comment.