forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testng-team#2974: Add tests for groups/excludedGroups cli parameters
- Loading branch information
dr29abrt
committed
Sep 1, 2023
1 parent
91a003a
commit 97dd348
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
testng-core/src/test/java/test/cli/github2974/OverrideGroupsCliTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package test.cli.github2974; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.testng.Assert; | ||
import org.testng.CommandLineArgs; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
import org.testng.TestNG; | ||
import org.testng.annotations.Test; | ||
import test.SimpleBaseTest; | ||
|
||
public class OverrideGroupsCliTest extends SimpleBaseTest { | ||
|
||
private static class NameCollector implements ITestListener { | ||
List<String> names = new ArrayList<>(); | ||
|
||
@Override | ||
public void onTestSuccess(ITestResult result) { | ||
names.add(result.getName()); | ||
} | ||
} | ||
|
||
@Test(description = "GITHUB-2974") | ||
public void overrideIncludeGroupsFromCliInParentChildXml() { | ||
TestNG testNG = | ||
new TestNG(false) { | ||
{ | ||
CommandLineArgs args = new CommandLineArgs(); | ||
args.groups = "override_group"; | ||
args.suiteFiles = List.of(getPathToResource("2974/parent_include.xml")); | ||
configure(args); | ||
} | ||
}; | ||
NameCollector collector = new NameCollector(); | ||
testNG.addListener(collector); | ||
testNG.run(); | ||
Assert.assertTrue(collector.names.contains("overrideTest")); | ||
Assert.assertFalse(collector.names.contains("defaultTest")); | ||
} | ||
|
||
@Test(description = "GITHUB-2974") | ||
public void overrideExcludeGroupsFromCliInParentChildXml() { | ||
TestNG testNG = | ||
new TestNG(false) { | ||
{ | ||
CommandLineArgs args = new CommandLineArgs(); | ||
args.excludedGroups = "override_group"; | ||
args.suiteFiles = List.of(getPathToResource("2974/parent_exclude.xml")); | ||
configure(args); | ||
} | ||
}; | ||
NameCollector collector = new NameCollector(); | ||
testNG.addListener(collector); | ||
testNG.run(); | ||
Assert.assertTrue(collector.names.contains("defaultTest")); | ||
Assert.assertFalse(collector.names.contains("overrideTest")); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
testng-core/src/test/java/test/cli/github2974/TwoGroupsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package test.cli.github2974; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class TwoGroupsTest { | ||
|
||
@Test(groups = "override_group") | ||
public void overrideTest() {} | ||
|
||
@Test(groups = "default_group") | ||
public void defaultTest() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
<exclude name="default_group"/> | ||
</run> | ||
</groups> | ||
<suite-files> | ||
<suite-file path="child.xml"/> | ||
</suite-files> | ||
</suite> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters