-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Print summary at the end of the run #536
Conversation
Print the same kind of summary at the end of the run as Cucumber-Ruby: x Scenarios (x1 failed, x2 skipped, x3 pending, x4 undefined, x5 passed) y Steps (y1 failed, y2 skipped, y3 pending, y4 undefined, y5 passed) XmY.YYYs The new class SummaryCounter is used by the Runtime class to collect the data for the summary. The SummaryPrinter then let the SummaryCounter print the summary before the errors and the snippets. The printout from the SummaryPrinter is moved to after the printout from the formatters to make the summary printed after the progress or pretty printout.
Awesome thanks! I have a few questions/comments that I'll add to the various lines. |
@@ -62,19 +63,29 @@ public Runtime(ResourceLoader resourceLoader, ClassLoader classLoader, RuntimeOp | |||
} | |||
|
|||
public Runtime(ResourceLoader resourceLoader, ClassLoader classLoader, Collection<? extends Backend> backends, RuntimeOptions runtimeOptions) { | |||
this(resourceLoader, classLoader, backends, runtimeOptions, new UndefinedStepsTracker()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class isn't in a public API, so there is no need to keep old constructors for backwards compatibility. Can you cut this back to two (or preferrably - one) constructors please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not so easy. It is not possible to first create a UndefinedStepsTracker and the pass it to the creation of the RuntimeGlue in the same constructor, which calls another constructor, so I think both the two new constructors are needed, but they does not need to be public, the third can be private and the forth package private.
The first constructor is used by cli.Main and the second one is used by tests to pass backends to the Runtime. It is used in tests both in the runtime package and in the runtime.formatter package so need to be public.
I can cut it back to three constructors, but this will affect a hand full of tests, see the gist: https://gist.github.com/brasmusson/5755281
Let the SummaryPrinter tell the Runtime to print the summary instead of asking for the SummaryCounter. Put back the check for an emtpy list of backends in the Runtime ctor, which was removed by mistake. Add test to check that a CucumberException is thrown when the list of backends is emtpy. Use Long for duration arguments in SummaryCounter, to conform to the return type of Result.getDuration().
It is possible to cut the number of constructors in Runtime to one constructor and one factory method, but is it the right way to go? See https://gist.github.com/brasmusson/5755281 I would like encouragement that that change actually is an improvement, before I push up that change. |
@brasmusson - have you seen my comment/query on your gist? https://gist.github.com/brasmusson/5755281 |
@sebrose - I'm sorry I have missed it. I'm still learning about what notifications github will send mail for, and what I need to look out for manually. In short, since the same UndefinedStepTracker instance is shared between the Runtime and the RuntimeGlue, I did not see another options to allow for a RuntimeGlue to be injected, than to create both the UndefinedStepTracker and the RuntimeGlue in the factory method and send them both to the Runtime constructor. Since the gist in all looked fine to you, I will add a commit to this pull request with the change to only have one constructor in the Runtime and to have a factory method as the normal way to construct a Runtime (when not injecting an alternative/mocked RuntimeGlue) |
To minimize the number of constructors in the Runtime class, and to handle that by default a UndefinedStepTracker is created and then injected both into the Runtime and the RuntimeGlue, create a factory method as the main entry. Expose additional conveniece factory methods for testing in the core module in RuntimeTest.
Now I got a build failure on openjdk6 for commit c8feb10, and the logs are truncated (both for the failed build and the passed build, so I cannot see why the build failed, but the log says that the Spring module started to build, so the changed modules Core, Java and Junit had been built and passed), and I cannot restart the build, so now I do not know what to do. |
After finally succeeded to get a complete log from Travis, I see that it was the deployment of snapshots to maven central that failed:
On the other hand a build on a pull request should not be deployed, so it might be just as well that the deployment failed. Somehow the Travis set up for Cucumber-JVM ought to be change to exclude deployment of builds for pull requests. |
Localise the UndefinedStepTracker in the Runtime and remove that argument from the constructor. Use that the optionalGlue argument is null, as the cue to let the Runtime create the default RuntimeGlue. When the optionalGlue argument is not null, the glue injected with that argument will be used by the Runtime.
@sebrose I looked over the Runtime constructor again. In 3a77cff the UndefinedStepTracker is localized within the Runtime. I am not totally happy about using when the optionalGlue argument is null, as the cue for the Runtime constructor to create the default RuntimeGlue. On the other hand, normally the Runtime is constructed through factory method, so the constructor is only intended to be used when backends and/or glue needs to be injected for testing purposes. |
Add RuntimeOptions.isMonochorme(), since commit 65f3bd6 on the master branch change RuntimeOptions to have private fields and getters. Basically revert commit c8feb10. Since the new android support on the master banch sends backends to the Runtime constructor, which previously only was done in tests, the change to use factory methods in Runtime no longer make sence.
When I merged cucumber-jvm:master into this PR branch and resolved that RuntimeOptions is change to use private fields and getter, I discovered that my solution to minimize the number of constructors in Runtime does not work with the new android module. The android module injects backends into the Runtime, which previously only been done in tests (see https://travis-ci.org/cucumber/cucumber-jvm/builds/8535311).
It is possible to only have one constructor in the Runtime, but then the production classes that instantiates the Runtime would need to pass null for the backends and glue parameter to say "load backends and instantiate a RuntimeGlue as usual". I think that would be confusing, passing null is more like saying "there should be no backends nor glue in the Runtime". Commit 442c4ed was not build by Travis, maybe because git get confused when both cucumber-jvm:master and this PR branch add methods (getters) last in the RuntimeOptions and report merge a conflict, but after manually merging cucumber-jvm:master into the PR branch Travis builds it successfully. |
@sebrose Please tell me if there is more a I need to do in this pull request, because I don't see that there is. |
@aslakhellesoy Just give me a go ahead, and I merge this PR. |
LGTM! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR fixes #195
Print the same kind of summary at the end of the run as Cucumber-Ruby (sub counts are only printed in >0):
The new class SummaryCounter is used by the Runtime class to collect the
data for the summary. The SummaryPrinter then let the SummaryCounter
print the summary before the errors and the snippets. The printout from
the SummaryPrinter is moved to after the printout from the formatters to
make the summary printed after the progress or pretty printout.