How to add parameter information to report


#1

I have several test cases running with a bunch of parameters from a dataprovider. So each test method gets executed for every set of parameters. That works pretty well so far.
All executions are shown in the report view. Unfortunately there is just the method name displayed. At least if a test failes it would be helpful to get some additional information beside the method name. Also for successfully runs some more information would be nice. Is there a way to add text to that output?


#2

Hello maxmustermann
If a test fails, you should get a more detailed error message, with a stack trace and a screenshot is automatically taken on the fail point. Are you getting some different fail descriptions? And for the passed test runs, you would like to have some custom text and information? You can check out this topic about customizing your report templates.


#3

Hi @smatijas ,

I made a test fail to show what I mean (using a search term which results in an empty list):

The stack trace is not helpful in that case. In the screenshot I could see (for that particular case) whats going wrong. It would make things much easier if I could add parameter information to the report output. I will check the customizing topic.


#4

Hi again,
I tried a custom solution based on this approach:

My custom listener works well and prints the parameter value to console like that:

System.out.println("+++" + myAdditionalOutput + “+++”);

I can see the correct output in the console window when running from Webtestit. But there is no <system-out> tag in the report xml source code so I can not access the value in template file. Up to here this was an promising apporach.

How can I transfer the string from the listener and make it accessible in the report (test-case.hbs template).


#5

Hello @maxmustermann! Unfortunately, this approach will only work only on the failed tests cases as described in the topic. For your request regarding adding parameters information the passed test cases reports, I will contact the team and we will discuss this manner further and let you know!


#6

Thank you. But the <system-out> tag is also on failed test cases missing in the report files. I tried the logging in several methods (onTestFailure, onTestSuccess, onTestStart). Console ouput was always as expected, but nothing to see in report xml. Maybe there were changes since older Webtestit versions.


#7

Hello @maxmustermann!

Could you try out this:
Download the java data-driven sample from the welcome screen.
Add the following to the test

class LoginPage extends TestNgTestBase implements ITest {

private ThreadLocal<String> testName = new ThreadLocal<>();

@BeforeMethod
public void BeforeMethod(Method method, Object[] testData) {
    testName.set(String.format("%s [Username: '%s'; Pass: '%s']", method.getName(), testData[0], testData[1]));
}

@Override
public String getTestName() {
    return testName.get();
} 

// Providing the previously created Data Provider that will be used in the test
@Test(dataProvider = "Credentials", dataProviderClass = CredentialsDataProvider.class)
. . .

You can format the string however you want, and this way your custom information should be shown in both, the failed and the passed test case reports.

Edit: The Java data-driven sample project has been updated and now contains the above-mentioned method, so you can try it out :slight_smile:


#8

Hi @smatijas,
thanks, you made my day :slight_smile: That works perfectly fine:

So my evaluation finished successfully and I decided to buy the tool. Hope you guys at Ranorex keep improving that helpful product. Thanks for the great support!


#9

@maxmustermann Thank you, more good features are coming, stay tuned :slight_smile: