Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to execlude somes test in option of command line #3200

1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Fixed: GITHUB-3122: Update JCommander to 1.83 (Antoine Dessaigne)
Fixed: GITHUB-3135: assertEquals on arrays - Failure message is missing information about the array index when an array element is unexpectedly null or non-null (Albert Choi)
Fixed: GITHUB-3140: assertEqualsDeep on Sets - Deep comparison was using the wrong expected value
Fixed: GITHUB-3189: Incorrect number of ignored tests displayed in the XML results
Fixed: GITHUB-3196: support to execlude somes 'test' in option of command line

7.10.2
Fixed: GITHUB-3117: ListenerComparator doesn't work (Krishnan Mahadevan)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I try to revert the update of README.md, it still shows there is one line have update.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![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)

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.

### Release Notes
* [7.10.0](https://groups.google.com/g/testng-users/c/6DmFaKUjIxY)
* [7.9.0](https://groups.google.com/g/testng-users/c/nN7LkuZWO48)
Expand Down Expand Up @@ -142,4 +141,4 @@ gpg: Good signature from "Krishnan Mahadevan (krmahadevan-key) <krishnan.mahadev
For more details regarding keys please refer:

* [Verifying Signature](https://infra.apache.org/release-signing.html#verifying-signature)
* [How to Trust Imported GPG Keys](https://classroom.anir0y.in/post/blog-how-to-trust-imported-gpg-keys/)
* [How to Trust Imported GPG Keys](https://classroom.anir0y.in/post/blog-how-to-trust-imported-gpg-keys/)
3 changes: 2 additions & 1 deletion testng-core-api/src/main/java/org/testng/xml/XmlTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.testng.xml;

import java.util.*;
import java.util.regex.Pattern;
import org.testng.TestNGException;
import org.testng.collections.Lists;
import org.testng.collections.Maps;
Expand Down Expand Up @@ -624,6 +625,6 @@ public XmlGroups getXmlGroups() {
* @return <code>true</code> if the current test's name matches with any of the given names.
*/
public boolean nameMatchesAny(List<String> names) {
return names.contains(getName());
return names.stream().allMatch(regex -> Pattern.matches(regex, getName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public final class TestNamesMatcher {
private final List<XmlSuite> cloneSuites = Lists.newArrayList();
private final List<String> matchedTestNames = Lists.newArrayList();
private final List<XmlTest> matchedTests = Lists.newArrayList();
private final List<String> missedTestNames = Lists.newArrayList();
private final List<XmlTest> missedTests = Lists.newArrayList();
private final List<String> testNames;
private final boolean ignoreMissedTestNames;

Expand Down Expand Up @@ -87,9 +89,6 @@ public boolean validateMissMatchedTestNames() {
}

public List<String> getMissedTestNames() {
List<String> missedTestNames = Lists.newArrayList();
missedTestNames.addAll(testNames);
missedTestNames.removeIf(matchedTestNames::contains);
return missedTestNames;
}

Expand All @@ -110,6 +109,9 @@ private XmlSuite cloneIfSuiteContainTestsWithNamesMatchingAny(XmlSuite suite) {
tests.add(xt);
matchedTestNames.add(xt.getName());
matchedTests.add(xt);
} else {
missedTestNames.add(xt.getName());
missedTests.add(xt);
}
}
if (tests.isEmpty()) {
Expand Down
8 changes: 8 additions & 0 deletions testng-core/src/test/java/org/testng/xml/XmlTestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public void testNameMatchesAny() {
assertThat(xmlTest.nameMatchesAny(Collections.singletonList("test2"))).isFalse();
}

@Test(description = "GITHUB-3196")
public void testNameMatchesAnyWithRegex() {
XmlSuite xmlSuite = createDummySuiteWithTestNamesAs("test1");
XmlTest xmlTest = xmlSuite.getTests().get(0);
assertThat(xmlTest.nameMatchesAny(Collections.singletonList("^(test1$).*"))).isTrue();
assertThat(xmlTest.nameMatchesAny(Collections.singletonList("^(?!test1$).*,"))).isFalse();
}

@Test(dataProvider = "dp", description = "GITHUB-1716")
public void testNullOrEmptyParameter(Map<String, String> data) {
XmlTest test = createXmlTest("suite", "test", Issue1716TestSample.class);
Expand Down