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

Show FQMN for tests in console #2758

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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!\")"));
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use another separator symbol between class and method (didn't find if a standard symbol exists)

Copy link
Member Author

Choose a reason for hiding this comment

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

@juherr - Is there any issue with using . as the separator here? It seems to be the standard symbol. Even IntelliJ uses that, when you right click a method and say Copy / Paste Special > Copy reference. Wouldn't it confuse users if we ended up introducing something else as the separator ?

Copy link
Member

Choose a reason for hiding this comment

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

OK. That's fine

}
}