Forum

Welcome to the community! Register below to add topics and replies.

Please or Register to create posts and topics.

Added utility function for customized logging

Current reporting

Proving sufficient information in reports when you have a test failure is crucial. The way we've designed it is that we try to provide as much information as possible in the Cucumber reports, such as

  • Screenshots on element action failures
  • The action link that failed
  • Timestamp
  • Relevant data values

By providing this, we expect this will be enough information to find the issue. If it's still not sufficient, we also provide log-style reporting out of the box, which shows all action executions presented in sequence, and additional performance logs. 

Custom reporting

In some cases, we have noticed that the information in the Cucumber reports are insufficient. One typical case is that some data that is relevant to the test isn't presented, or some other factor (such as a previous test condition) wasn't captured. We are therefore introducing a way to add data into the log for potential failures. The functions are

  • $util.setLogData(): Clears the log buffer and adds new log entry
  • $util.addLogData(): Adds a log entry
  • $util.cleanLogData(): Clears the log buffer

These functions can be used either with data or static values. To add a static log value use

$util.addLogData({datakey1:"Some information that needs to be captured"}); 
$util.addLogData({datakey2:"Some other info"});

$test.tmp = "Tmp data that is important";
$util.addLogData($test.tmp);

The resulting Cucumber report inside the screenshot will be

To add logging for a variable, add 

$util.addLogData({datakey1:"Some information that needs to be captured"}); 
$util.addLogData({datakey2:"Some other info"}); 

$test.tmp = "Tmp data that is important"; 
$util.addLogData($test.tmp);

The resulting Cucumber report inside the screenshot will be

In order to make sure that the log buffer doesn't grow to large we provide both $util.cleanLogdata() and $util.setLogData() which can be used in an equivalent fashion

$util.addLogData({datakey1:"This is first line of log buffer"}); 
$util.addLogData({datakey2:"This is second line of log buffer"});

$util.cleanLogData();
$util.addLogData({datakey3:"Cleaned buffer. This is first line of log buffer"}); 

or

$util.addLogData({datakey1:"This is first line of log buffer"}); 
$util.addLogData({datakey2:"This is second line of log buffer"});

$util.setLogData({datakey3:"Cleaned log buffer. This is first line of log buffer"}); 

The resulting screenshot will only show the last line as expected

We hope this can help you be more effective in troubleshooting any errors! Let us know what you think.

 

 

 

Thanks Mats! Very valuable feature.

You mentioned that this data is visible in the Cucumber reports. Does it appear as well in the runner logs (visible from the jenkins console) and in the HTML reports?

If I understand correctly the functions don't take as argument a simple string, therefore I wonder if it is possible and how, to add new lines to simplify the reading.

Create your account for free!

No credit card required.