Skip to content

Commit

Permalink
Show FQMN for tests in console
Browse files Browse the repository at this point in the history
Closes #2741
  • Loading branch information
krmahadevan committed May 13, 2022
1 parent 6b2e466 commit 2be448a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Current
7.6.0
Fixed: GITHUB-2741: Show fully qualified name of the test instead of just the function name for better readability of test output.(Krishnan Mahadevan)
Fixed: GITHUB-2726: @AfterClass config method is executed for EACH @Test method when parallel == methods (Krishnan Mahadevan)
Fixed: GITHUB-2752: TestListener is being lost when implenting both IClassListener and ITestListener (Krishnan Mahadevan)
New: GITHUB-2724: DataProvider: possibility to unload dataprovider class, when done with it (Dzmitry Sankouski)
Expand Down
8 changes: 8 additions & 0 deletions testng-core-api/src/main/java/org/testng/internal/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,14 @@ public static String detailedMethodName(ITestNGMethod method, boolean fqn) {
return tempName + (fqn ? method.toString() : method.getMethodName());
}

public static String detailedMethodName(ITestNGMethod method) {
String tempName = annotationFormFor(method);
if (!tempName.isEmpty()) {
tempName += " ";
}
return tempName + method.getQualifiedName();
}

/**
* Given a TestNG method, returns the corresponding annotation based on the method type
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void logResults(ITestContext context) {

logResult(
"FAILED CONFIGURATION",
Utils.detailedMethodName(tr.getMethod(), false),
Utils.detailedMethodName(tr.getMethod()),
tr.getMethod().getDescription(),
stackTrace,
tr.getParameters(),
Expand All @@ -61,7 +61,7 @@ private void logResults(ITestContext context) {
for (ITestResult tr : results) {
logResult(
"SKIPPED CONFIGURATION",
Utils.detailedMethodName(tr.getMethod(), false),
Utils.detailedMethodName(tr.getMethod()),
tr.getMethod().getDescription(),
null,
tr.getParameters(),
Expand Down Expand Up @@ -129,7 +129,7 @@ private void logResults(ITestContext context) {
private void logResult(String status, ITestResult tr, String stackTrace) {
logResult(
status,
tr.getName(),
tr.getMethod().getQualifiedName(),
tr.getMethod().getDescription(),
stackTrace,
tr.getParameters(),
Expand Down
4 changes: 3 additions & 1 deletion testng-core/src/test/java/test/reports/ReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ public void reportCreatedWithNullParameter() {
System.setOut(new PrintStream(systemOutCapture));
tng.run();
System.setOut(previousOut);
String actual = systemOutCapture.toString();

Assert.assertTrue(
systemOutCapture.toString().contains("PASSED: testMethod(null, \"Bazinga!\")"));
actual.contains(
"PASSED: test.reports.ReportTest$NullParameter.testMethod(null, \"Bazinga!\")"));
}
}

0 comments on commit 2be448a

Please sign in to comment.