File tree 5 files changed +45
-5
lines changed
main/java/org/testng/xml/internal
testng-core-api/src/main/java/org/testng/xml
5 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +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 'test' in option of command line
9
+ Fixed: GITHUB-3196: support to execlude somes tests in option of command line
10
10
11
11
7.10.2
12
12
Fixed: GITHUB-3117: ListenerComparator doesn't work (Krishnan Mahadevan)
Original file line number Diff line number Diff line change @@ -625,6 +625,15 @@ public XmlGroups getXmlGroups() {
625
625
* @return <code>true</code> if the current test's name matches with any of the given names.
626
626
*/
627
627
public boolean nameMatchesAny (List <String > names ) {
628
- return names .stream ().anyMatch (regex -> Pattern .matches (regex , 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
+ });
629
638
}
630
639
}
Original file line number Diff line number Diff line change @@ -91,7 +91,17 @@ public List<String> getMissedTestNames() {
91
91
List <String > missedTestNames = Lists .newArrayList ();
92
92
missedTestNames .addAll (testNames );
93
93
missedTestNames .removeIf (
94
- regex -> matchedTestNames .stream ().anyMatch (testName -> Pattern .matches (regex , testName )));
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
+ }));
95
105
return missedTestNames ;
96
106
}
97
107
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ public void testNameMatchesAny() {
24
24
public void testNameMatchesAnyWithRegex () {
25
25
XmlSuite xmlSuite = createDummySuiteWithTestNamesAs ("test1" );
26
26
XmlTest xmlTest = xmlSuite .getTests ().get (0 );
27
- assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("^(test1$).*" ))).isTrue ();
28
- assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("^(?!test1$).*, " ))).isFalse ();
27
+ assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("/ ^(test1$).*/ " ))).isTrue ();
28
+ assertThat (xmlTest .nameMatchesAny (Collections .singletonList ("/ ^(?!test1$).*/ " ))).isFalse ();
29
29
}
30
30
31
31
@ Test (dataProvider = "dp" , description = "GITHUB-1716" )
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