File tree 6 files changed +55
-3
lines changed
main/java/org/testng/xml/internal
testng-core-api/src/main/java/org/testng/xml 6 files changed +55
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Fixed: GITHUB-3122: Update JCommander to 1.83 (Antoine Dessaigne)
6
6
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)
7
7
Fixed: GITHUB-3140: assertEqualsDeep on Sets - Deep comparison was using the wrong expected value
8
8
Fixed: GITHUB-3189: Incorrect number of ignored tests displayed in the XML results
9
+ Fixed: GITHUB-3196: support to execlude somes tests in option of command line
9
10
10
11
7.10.2
11
12
Fixed: GITHUB-3117: ListenerComparator doesn't work (Krishnan Mahadevan)
Original file line number Diff line number Diff line change @@ -142,4 +142,4 @@ gpg: Good signature from "Krishnan Mahadevan (krmahadevan-key) <krishnan.mahadev
142
142
For more details regarding keys please refer:
143
143
144
144
* [Verifying Signature](https://infra.apache.org/release-signing.html#verifying-signature)
145
- * [How to Trust Imported GPG Keys](https://classroom.anir0y.in/post/blog-how-to-trust-imported-gpg-keys/)
145
+ * [How to Trust Imported GPG Keys](https://classroom.anir0y.in/post/blog-how-to-trust-imported-gpg-keys/)
Original file line number Diff line number Diff line change 1
1
package org .testng .xml ;
2
2
3
3
import java .util .*;
4
+ import java .util .regex .Pattern ;
4
5
import org .testng .TestNGException ;
5
6
import org .testng .collections .Lists ;
6
7
import org .testng .collections .Maps ;
@@ -624,6 +625,15 @@ public XmlGroups getXmlGroups() {
624
625
* @return <code>true</code> if the current test's name matches with any of the given names.
625
626
*/
626
627
public boolean nameMatchesAny (List <String > names ) {
627
- return names .contains (getName ());
628
+ return names .contains (getName ())
629
+ || names .stream ()
630
+ .anyMatch (
631
+ regex -> {
632
+ if (regex .startsWith ("/" ) && regex .endsWith ("/" )) {
633
+ String trimmedRegex = regex .substring (1 , regex .length () - 1 );
634
+ return Pattern .matches (trimmedRegex , getName ());
635
+ }
636
+ return false ;
637
+ });
628
638
}
629
639
}
Original file line number Diff line number Diff line change 1
1
package org .testng .xml .internal ;
2
2
3
3
import java .util .List ;
4
+ import java .util .regex .Pattern ;
4
5
import org .testng .TestNGException ;
5
6
import org .testng .collections .Lists ;
6
7
import org .testng .log4testng .Logger ;
@@ -89,7 +90,18 @@ public boolean validateMissMatchedTestNames() {
89
90
public List <String > getMissedTestNames () {
90
91
List <String > missedTestNames = Lists .newArrayList ();
91
92
missedTestNames .addAll (testNames );
92
- missedTestNames .removeIf (matchedTestNames ::contains );
93
+ missedTestNames .removeIf (
94
+ regex ->
95
+ matchedTestNames .contains (regex )
96
+ || matchedTestNames .stream ()
97
+ .anyMatch (
98
+ name -> {
99
+ if (regex .startsWith ("/" ) && regex .endsWith ("/" )) {
100
+ String trimmedRegex = regex .substring (1 , regex .length () - 1 );
101
+ return Pattern .matches (trimmedRegex , name );
102
+ }
103
+ return false ;
104
+ }));
93
105
return missedTestNames ;
94
106
}
95
107
Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ public void testNameMatchesAny() {
20
20
assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("test2" ))).isFalse ();
21
21
}
22
22
23
+ @ Test (description = "GITHUB-3196" )
24
+ public void testNameMatchesAnyWithRegex () {
25
+ XmlSuite xmlSuite = createDummySuiteWithTestNamesAs ("test1" );
26
+ XmlTest xmlTest = xmlSuite .getTests ().get (0 );
27
+ assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("/^(test1$).*/" ))).isTrue ();
28
+ assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("/^(?!test1$).*/" ))).isFalse ();
29
+ }
30
+
23
31
@ Test (dataProvider = "dp" , description = "GITHUB-1716" )
24
32
public void testNullOrEmptyParameter (Map <String , String > data ) {
25
33
XmlTest test = createXmlTest ("suite" , "test" , Issue1716TestSample .class );
Original file line number Diff line number Diff line change @@ -170,6 +170,27 @@ public void testOverrideExcludedMethodsSuiteExclusions() {
170
170
verifyTests ("Failed" , failed , tla .getFailedTests ());
171
171
}
172
172
173
+ @ Test (description = "GITHUB-2407" )
174
+ public void testSpecificTestNamesWithRegexCommandLineExclusions () {
175
+ String [] args =
176
+ new String [] {
177
+ "src/test/resources/testnames/main-suite.xml" ,
178
+ "-log" ,
179
+ "0" ,
180
+ "-d" ,
181
+ OutputDirectoryPatch .getOutputDirectory (),
182
+ "-testnames" ,
183
+ "/^testGroup1.*/"
184
+ };
185
+
186
+ TestNG .privateMain (args , tla );
187
+
188
+ String [] passed = {"sampleOutputTest1" };
189
+ String [] failed = {};
190
+ verifyTests ("Passed" , passed , tla .getPassedTests ());
191
+ verifyTests ("Failed" , failed , tla .getFailedTests ());
192
+ }
193
+
173
194
private void verifyTests (String title , String [] expected , List <ITestResult > found ) {
174
195
175
196
Assertions .assertThat (found .stream ().map (ITestResult ::getName ).toArray (String []::new ))
You can’t perform that action at this time.
0 commit comments