Skip to content

Commit adb5ca2

Browse files
author
enztngh
committed
GITHUB-3196: support to execlude somes 'test' in option of command line
1 parent e8b8bf3 commit adb5ca2

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Sonarqube Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=org.testng%3Atestng&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.testng%3Atestng)
55

66
Documentation available at [TestNG's main web site](https://testng.org). Visit [TestNG Documentation's GitHub Repo](https://github.com/testng-team/testng-team.github.io) to contribute to it.
7+
78
### Release Notes
89
* [7.10.0](https://groups.google.com/g/testng-users/c/6DmFaKUjIxY)
910
* [7.9.0](https://groups.google.com/g/testng-users/c/nN7LkuZWO48)
@@ -39,7 +40,7 @@ Always make sure your issue is happening on the latest TestNG version. Bug repor
3940

4041
### Have you considered sending a pull request instead of filing an issue?
4142
The best way to report a bug is to provide the TestNG team with a full test case reproducing the issue.
42-
Maybe you can write a runnable test case (check the `src/test/` folder for examples) and propose it in a pull request
43+
Maybe you can write a runnable test case (check the `src/test/` folder for examples) and propose it in a pull request
4344
Don't worry if the CI fails because it is the expected behavior.
4445
This pull request will be a perfect start to find the fix :)
4546

@@ -48,12 +49,12 @@ Refer our [Contributing](.github/CONTRIBUTING.md) section for detailed set of st
4849

4950
### We encourage pull requests that:
5051

51-
* Add new features to TestNG (or)
52-
* Fix bugs in TestNG
52+
* Add new features to TestNG (or)
53+
* Fix bugs in TestNG
54+
55+
If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
56+
[TestNG-dev](https://groups.google.com/forum/#!forum/testng-dev) before you spend time working on it.
5357

54-
If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
55-
[TestNG-dev](https://groups.google.com/forum/#!forum/testng-dev) before you spend time working on it.
56-
5758
### GPG Keys
5859

5960
#### Getting the keys

testng-core-api/src/main/java/org/testng/xml/XmlTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,6 @@ public XmlGroups getXmlGroups() {
625625
* @return <code>true</code> if the current test's name matches with any of the given names.
626626
*/
627627
public boolean nameMatchesAny(List<String> names) {
628-
return names.stream().allMatch(regex -> Pattern.matches(regex, getName()));
628+
return names.stream().anyMatch(regex -> Pattern.matches(regex, getName()));
629629
}
630630
}

testng-core/src/main/java/org/testng/xml/internal/TestNamesMatcher.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.testng.xml.internal;
22

33
import java.util.List;
4+
import java.util.regex.Pattern;
45
import org.testng.TestNGException;
56
import org.testng.collections.Lists;
67
import org.testng.log4testng.Logger;
@@ -21,8 +22,6 @@ public final class TestNamesMatcher {
2122
private final List<XmlSuite> cloneSuites = Lists.newArrayList();
2223
private final List<String> matchedTestNames = Lists.newArrayList();
2324
private final List<XmlTest> matchedTests = Lists.newArrayList();
24-
private final List<String> missedTestNames = Lists.newArrayList();
25-
private final List<XmlTest> missedTests = Lists.newArrayList();
2625
private final List<String> testNames;
2726
private final boolean ignoreMissedTestNames;
2827

@@ -89,6 +88,12 @@ public boolean validateMissMatchedTestNames() {
8988
}
9089

9190
public List<String> getMissedTestNames() {
91+
List<String> missedTestNames = Lists.newArrayList();
92+
missedTestNames.addAll(testNames);
93+
missedTestNames.removeIf(regex ->
94+
matchedTestNames.stream()
95+
.anyMatch(testName -> Pattern.matches(regex, testName))
96+
);
9297
return missedTestNames;
9398
}
9499

@@ -109,9 +114,6 @@ private XmlSuite cloneIfSuiteContainTestsWithNamesMatchingAny(XmlSuite suite) {
109114
tests.add(xt);
110115
matchedTestNames.add(xt.getName());
111116
matchedTests.add(xt);
112-
} else {
113-
missedTestNames.add(xt.getName());
114-
missedTests.add(xt);
115117
}
116118
}
117119
if (tests.isEmpty()) {

0 commit comments

Comments
 (0)