Skip to content

Commit

Permalink
Restore testnames when using suites in suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Aldrin committed Jan 13, 2022
1 parent 55e8e52 commit d9a0ec1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,5 +1,6 @@
Current
7.6.0
Fixed: GITHUB-2709: Testnames not working together with suites in suite (Martin Aldrin)
Fixed: GITHUB-2637: Upgrade to JDK11 as the minimum JDK requirements(Krishnan Mahadevan)

7.5
Expand Down
6 changes: 5 additions & 1 deletion testng-core/src/main/java/org/testng/JarFileUtils.java
Expand Up @@ -95,7 +95,11 @@ private boolean testngXmlExistsInJar(File jarFile, List<String> classes) throws
TestNamesMatcher testNamesMatcher = new TestNamesMatcher(suite, testNames);
List<String> missMatchedTestname = testNamesMatcher.getMissMatchedTestNames();
if (!missMatchedTestname.isEmpty()) {
throw new TestNGException("The test(s) <" + missMatchedTestname + "> cannot be found.");
throw new TestNGException(
"The test(s) <"
+ missMatchedTestname
+ "> cannot be found in suite: "
+ suite.getName());
}
suites.addAll(testNamesMatcher.getSuitesMatchingTestNames());
} else {
Expand Down
6 changes: 4 additions & 2 deletions testng-core/src/main/java/org/testng/TestNG.java
Expand Up @@ -353,7 +353,8 @@ private Collection<XmlSuite> processCommandLineArgs(Collection<XmlSuite> allSuit
TestNamesMatcher testNamesMatcher = new TestNamesMatcher(s, m_testNames);
List<String> missMatchedTestname = testNamesMatcher.getMissMatchedTestNames();
if (!missMatchedTestname.isEmpty()) {
throw new TestNGException("The test(s) <" + missMatchedTestname + "> cannot be found.");
throw new TestNGException(
"The test(s) <" + missMatchedTestname + "> cannot be found, in suite: " + s.getName());
}
result.addAll(testNamesMatcher.getSuitesMatchingTestNames());
}
Expand Down Expand Up @@ -420,7 +421,8 @@ public void initializeSuitesAndJarFile() {
new JarFileUtils(getProcessor(), m_xmlPathInJar, m_testNames, m_parallelMode);

Collection<XmlSuite> allSuites = utils.extractSuitesFrom(jarFile);
m_suites.addAll(processCommandLineArgs(allSuites));
allSuites.stream().forEach(s -> processParallelModeCommandLineArgs(s));
m_suites.addAll(allSuites);
}

/** @param threadCount Define the number of threads in the thread pool. */
Expand Down
2 changes: 1 addition & 1 deletion testng-core/src/test/java/org/testng/JarFileUtilsTest.java
Expand Up @@ -55,7 +55,7 @@ public void testWithNoTestNames() throws MalformedURLException {
@Test(
expectedExceptions = TestNGException.class,
expectedExceptionsMessageRegExp =
"\nThe test\\(s\\) <\\[testng-tests-child11\\]> cannot be found.")
"\nThe test\\(s\\) <\\[testng-tests-child11\\]> cannot be found in suite: testng-tests-suite")
public void testWithInvalidTestNames() throws MalformedURLException {
JarFileUtils utils = newJarFileUtils(Collections.singletonList("testng-tests-child11"));
runTest(
Expand Down

0 comments on commit d9a0ec1

Please sign in to comment.