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

Possibility to not show "Before" and "After" steps in report for each scenario? #282

Closed
Ryxmedia opened this issue Jan 5, 2016 · 15 comments

Comments

@Ryxmedia
Copy link

Ryxmedia commented Jan 5, 2016

Hi,

I just included the newest version and have seen, that the "Before" and "After" methods are shown in the report.
This blows up my reports by a lot. Especially, because all of them are always shown for each scenario.

Would it be possible to not show them at all?

@damianszczepanik
Copy link
Owner

Show me your report so I can understand the problem

@Ryxmedia
Copy link
Author

Ryxmedia commented Jan 8, 2016

I have like 20 different .java test classes which are "glued" together.
Lets say 10 of there classes have @before and @after steps.

If execute my tests for just 1 scenario, all 10 @before and @after steps are shown for the scenario.

In the report it looks something like this for EVERY scenario:

Feature: Search
@PRIORITY_HIGH
Before ClassXY1.name(Scenario)
Before ClassXY2.name(Scenario)
Before ClassXY3.name(Scenario)
Before ClassXY4.name(Scenario)
Before ClassXY5.name(Scenario)
Before ClassXY6.name(Scenario)
Before ClassXY7.name(Scenario)
Before ClassXY8.name(Scenario)
Before ClassXY9.name(Scenario)
Before ClassXY10.name(Scenario)
Scenario: Search
Given... 02s 305ms
And... 01s 014ms
When... 02s 430ms
Then... 260ms
After ClassXY11.name()
After ClassXY12.name()
After ClassXY13.name()
After ClassXY14.name()
After ClassXY15.name()
After ClassXY16.name()
After ClassXY17.name()
After ClassXY18.name()
After ClassXY19.name()
After ClassXY20.name()

I have to use @before and @after for some of my classes, because I use Cucumber together with Selenium.

@damianszczepanik
Copy link
Owner

I think your case is quite specific and most users have 1-3 before/after cases and they wish to see them (in case of failure). I wonder what would be the compromise for all users...

@wpsouto
Copy link

wpsouto commented Feb 3, 2016

First congratulations for the brilliant project is helping me a lot.
Also find useful this option.
I use "@before" and "@after" to "Printscreen" and do not need this information in the report.
My .json attached

cucumber.json.zip

@Ryxmedia
Copy link
Author

So what are we going to do about this?
I really need the possibility to hide the @before and @after information, because they totally blow up my reports.

@damianszczepanik
Copy link
Owner

You are more than welcome to prepare patch for this feature. It should not be a rocket science and we all will be happy about it!

@stevejensen22
Copy link

I have a fix for this but am struggling to build a custom jenkins .hpi plugin. If anyone could help me get my fix into a custom cucumber-jvm reports plugin I'd appreciate it. Here is my if to exclude after's and before's:

private String calculateAttachments(String keyword, Hook[] hooks) {
        StringBuilder sb = new StringBuilder();
        if (!keyword.equalsIgnoreCase("after") && (!keyword.equalsIgnoreCase("before"))) {
            for (Hook hook : hooks) {
                String attachmentStatus = hook.getResult().getStatus();

                sb.append("<div class=\"").append(attachmentStatus).append("\">");
                sb.append("<span class=\"step-keyword\">").append(keyword).append(" </span>");
                sb.append("<i>").append(hook.getMatch().getLocation()).append("</i>");

                sb.append("<span class=\"step-duration\">");
                if (Status.MISSING.getRawName().equals(attachmentStatus)) {
                    sb.append(Util.formatDuration(hook.getResult().getDuration()));
                }
                sb.append("</span>");
                sb.append(Util.formatMessage(hook.getResult().getErrorMessage(), hook.getResult().hashCode()));
                sb.append("</div>");

                sb.append(hook.getAttachments());
            }
        }
        return sb.toString();
    }

@damianszczepanik
Copy link
Owner

Check ..travis file which has build command that produce hpi file

@Ryxmedia
Copy link
Author

@lilshrumpmerp

Thank you, that looks good, but where do I have to implement this to take effect?

@gts2257
Copy link

gts2257 commented Mar 31, 2016

First, thank you for the great project and the effort put in this :)

I would like to add to this discussion that before and after are mostly technical details. An analyst or a product owner would rarely want to see how we prepare the system or what we do as clean up procedures.

Also, I think this is quite obvious as the steps displayed in the report are only method names that most of the time does not make sense to the non-developer.

So 👍 for providing an option to hide them. In my opinion this should also be the default.

@damianszczepanik
Copy link
Owner

I think this is good idea but I don't know when it will be scheduled and fixed. I guess within 2-3 releases.

@Ryxmedia
Copy link
Author

Ryxmedia commented Apr 5, 2016

As soon as we get this, I'm happy because at the moment I have to use an older version because of this.

@damianszczepanik
Copy link
Owner

Here we have some PoC for similar feature for scenarios https://cloud.githubusercontent.com/assets/9612911/14655017/a38477ec-0680-11e6-905e-f2f922f09f07.png - the plan is to have the same for hooks. Let me know if this would be accepted

@wildinstinct
Copy link

@damianszczepanik I have written java program to run my system test cases to test my API. The inputs of an API and expected output are defined in excel sheet. I read the data from excel and run against my API. I started using your library to build Feature object so that i can produce reports.

I am much worried about the line number required to be mentioned in Step and Scenario object. Does it really used by the library to publish reports?

@garlapati99
Copy link

lilshrumpmerp

how to remove the before and after hook in the cucumber extent reports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants