trivago / cluecumber

Clear and concise reporting for the Cucumber BDD JSON format.
https://www.softwaretester.blog
Apache License 2.0
268 stars 89 forks source link

Query: How to add custom log steps in cluecumber reports for failed steps #342

Closed SayyedaNousheen closed 3 months ago

SayyedaNousheen commented 3 months ago

I need to add custom logs, like mention the step failed or print in the report custom element name which was not found which is understandable by all. As of now we have the error stack trace which is very technical.

Solution

  1. If any scenario fails, I want to print the exact element that caused the failure and which functionality was failed because of it, like printing a custom message.
  2. Step level custom logging feature would be great.

Alternates tried

  1. I tried using Assertions and passed failure message in that, but still doesn't get displayed on the report
  2. I tried scenario.log() in after hooks
  3. Tried Reporter.addStep()
bischoffdev commented 3 months ago

If you want to show any custom information like screenshots, html attachment, messages, you need to attach it to the current Cucumber scenario.

For example, if you use Cucumber JVM, you can use the attach method in two "flavors":

    public void attach(byte[] data, String mediaType, String name) {
        this.delegate.attach(data, mediaType, name);
    }

    public void attach(String data, String mediaType, String name) {
        this.delegate.attach(data, mediaType, name);
    }

Please keep in mind that Cluecumber relies on data that is included in the Cucumber JSON files, so there is no way to attach something to Cluecumber only. It has to come from Cucumber.