Skip to content

Commit 874f368

Browse files
committed
Log skip reason when data provider returns no data
Closes #2563
1 parent f93a9dc commit 874f368

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Current
2+
Fixed: GITHUB-2563: Skip test if its data provider provides no data (Krishnan Mahadevan)
23
Fixed: GITHUB-2535: TestResult.getEndMillis() returns 0 for skipped configuration - after upgrading testng to 7.0 + (Krishnan Mahadevan)
34
Fixed: GITHUB-2638: "[WARN] Ignoring duplicate listener" appears when running .xml suite with <listeners> and <suite-files> (Krishnan Mahadevan)
45
Fixed: GITHUB-1297: Passed configuration methods appear in testng-failed.xml, when failure was after passed test (Dzmitry Sankouski)

testng-core-api/src/main/java/org/testng/internal/Utils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public static void error(String errorMessage) {
240240
}
241241

242242
public static void warn(String warnMsg) {
243-
LOG.warn("[Warning] " + warnMsg);
243+
LOG.warn(warnMsg);
244244
}
245245

246246
/* Tokenize the string using the separator. */

testng-core/src/main/java/org/testng/internal/Parameters.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,13 @@ public static ParameterHolder handleParameters(
800800
public boolean hasNext() {
801801
if (index == 0 && !parameters.hasNext() && !hasWarn) {
802802
hasWarn = true;
803-
Utils.log(
804-
"",
805-
2,
806-
"Warning: the data provider '"
807-
+ dataProviderMethod.getName()
808-
+ "' returned an empty array or iterator, so this test is not doing anything");
803+
String msg =
804+
String.format(
805+
"The test method '%s' will be skipped since its "
806+
+ "data provider '%s' "
807+
+ "returned an empty array or iterator. ",
808+
testMethod.getQualifiedName(), dataProviderMethod.getName());
809+
Utils.warn(msg);
809810
}
810811
return parameters.hasNext();
811812
}

0 commit comments

Comments
 (0)