Is it possible to perform logging into reports

feature-request

#1

Is it possible to perform logging into reports(ex: When multiple expect are used and details of each needs to be checked i.e. actual vs expected values)
Also, can the reports be saved into a different format other than .xml ( Ex: .pdf) directly


#2

Hi @lohitN,

can you elaborate on what you’re meaning with “perform logging” exactly? Is it like you wan’t to log custom messages into the test result? If that is the case this article about using Log4J might be of help. But I guess you had something different on your mind.

With regards to exports, what different types would you be looking for?


#3

Thanks for your reply.
We are using protractor with typescript for automating the UI tests with Webtestit.

Regarding ‘perform logging’, currently the reports generated after the runs contain the following
1.Test suite( i.e. Test case name/description mentioned inside IT )
2.Date & time
3.Duration
4.Failures( i.e. Success or Failure).

Using console.log(’…’) , more details can be visualized under ‘LOG’.
Similarly,if we need to visualize more details in the generated report, how can this be achieved.

We have already tried reporter.log but error is that ranorex is not supported.


#4

So essentially you would want to have your console.logs, or whatever alternative is used, shown in the reports testsuite when expanded along the error message? Is this also needed for the success case, means when opening a succeeding testcase to still be able to see the logs?

Also lets make sure I did understand you properly about the logs. You are referring to logs that you’ve written inside your tests not the ones from the actual site tested right?

I haven’t seen reporter.log yet in Protractor but I know that one from TestNG. Console.log should do it. The only problem is as I’m seeing is that we didn’t turn on log collection by default. Meanwhile for you to test open your projects protractor-helpers.js file, search for the place where JUnitXmlReporter is instantiated (should be around line 79) and change it to this:

const junitReporter = new jasmineReporters.JUnitXmlReporter({
      savePath: 'temp-reports/',
      consolidateAll: true,
      captureStdout: true,  // <------- this is the new entry
      filePrefix: `${session.getId()}-${TEST_REPORT_FILENAME}`
});

When you run tests, containing console.log calls now and open the resulting report in a normal text-editor, you should see a section <system-out>...</system-out> inside your testcase.

What we’re going to do is to create a new story for our backlog to turn that feature on by default, so it behaves just like the TestNG/Java template, and update our reports to contain a section (perhaps even toggle-able but thats what our designer will decide) inside the testcases.


#5
  1. Yes! the console logs needs to be shown in the reports when expanded along the error message and this would also be needed for the success case too( i.e. when opening a succeeding testcase)
  2. Your understanding is right here since we are referring to the logs which have been written inside our tests.
  3. Meanwhile, we have added this line( captureStdout: true ) inside the protractor-helpers.js file
    This inturn is adding the details in the xml report.
    When we save the report from Webtestit in .pdf format, the details cannot be seen currently when opened in pdf viewer and this would be nice to have.
    Thanks for your support!

#6

Great, thanks for the feedback @lohitN.

This is definitely going to be another great improvement for the Ranorex Webtestit report, looking forward to implementing it.