-
-
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
Would like JUnit ErrorCollector support or a Cucumber-jvm equivalent #771
Comments
I haven't ever had to use any ErrorCollector functionality with Cucumber. Perhaps a pull request with some examples? |
ErrorCollector is a JUnit API class which handles error collecting. This means if a test fails and I want to continue execution, I can. And then, at the end of the test (in a @after hook I believe), the test would be marked as failing and would provide teh stack trace for each of the errors captured. So, in a simple case: public class TestClass{
@Rule
ErrorCollector handler = new ErrorCollector();
@When("this test will (.*)")
public void test(String type){
switch(type){
case "pass":
case "still pass"
handler.checkThat("This worked", true, equalTo(true)); //Similar to Assert.that
break;
case "fail"
handler.checkThat("this failed", false, equalTo(true)); //Similar to Assert.that
break;
}
}
}
In a normal JUnit framework, I can get the above scenario to FAIL as described. Right now, since JUnit Rules are never checked, this test will pass 100% of the time (even though there should be failures). |
If a step fails, but you want it to continue executing, that's a different scenario. I would say you're not using Cucumber properly. Your step should not fail, if you want it to continue executing. It looks as though you brought this up over a year ago: https://groups.google.com/forum/#!searchin/cukes/steps$20continue/cukes/odXSUY9cbK0/FdUl1CgrTCwJ And the answer was, you're not righting your tests correctly. I'm going to go with the same answer, and say that you're not using cucumber the way cucumber is intended to be used, and unless you can offer a compelling reason as to why we should break the fundamental logic of "A step failed, your test failed" I don't think this is going to happen. |
Well, in that post, I actually wanted the test to skip based on outside forces (real bug in the system, just don't run this specific check without having to comment it out of the feature file). But I will give you an actual test case and let me know if you still think this is bad.
This is a more practical example, are you still saying I am using cucumber incorrectly? Even though these tests can essentially run in parallel? If it is intended that this be 3 separate scenarios, wouldn't that be bad from an execution and resource need perspective? EDIT: comment returned Shoot - can you get my comment back? I tried to cancel edit, not delete post... |
So cucumber isn't about optimizing execution, it's about optimizing communication. This example scenario indicates that those three things are required to be on the page, and so if any one of those items is not there, have it fail. How would the scenario be valuable if item title, description, or number of bids doesn't exist, but you expect them to exist? You could refactor the test, and use a background to grab the page (if you're worried about grabbing the page too many times, which I think shouldn't be a problem for a system under test.) and then
You can do some internal caching if page load times are very slow, where it'll cache it once for a given period of time, or maybe for the entire run, cache eviction strategies are really outside the scope of cucumber. |
what you are proposing is fine for a simple case, but starts to break down (in my opinion) when the setup is harder (solution isn't scalable).
In a scenario like this, having a big background slows down the test considerably. Not to mention that I now have 3 test items instead of 1. I don't think breaking up the test is the ideal solution (I know the DBA would hate me for example). And when you consider all the services like Sauce Labs that charge based on execution times, breaking up the tests actually become a bad idea since it will cost us more money and we will have to wait longer for results. However, based on your comment that cucumber is about communication and not execution, I see this as a valid counter point. I do want to make something clear though. You said, "How would the scenario be valuable if item title, description, or number of bids doesn't exist, but you expect them to exist?" The problem I am trying to solve is that if the title doesn't exist, I don't know if the description or number of items exist (is it just the title?) or if everything on the page missing. Sure, a screen shot can help reduce the amount of investigative work, but, it isn't always complete (I am looking at you Chrome Webdriver). Also, just for the sake of mentioning, one of my QA co-workers actually asked for this functionality because she said that the cucumber reports weren't that helpful - they didn't tell her only what failed. it told her what was failed and what was skipped and that made her NOT TRUST the tests. I know its just a matter of perception (I trust the tests after all), but it is still upsetting when people aren't looking at your test results because of all the blue. |
Perhaps you could write a step that "Required elements are on the page" If you wanted to assert mutliple things per single step. And then fail that step and indicate what elements aren't on the page, basically grouping your assertions into one "pass/fail" and outputting what was causing that grouping to fail. Make sense? |
Thats what I am trying to do :) I just thought this thread become more of a philosophical discussion. I actually thought I was doing something wrong... JUnit does this for me. Hence the request. My thought was "Why re-invent the wheel". Also, I would think this feature would be used by lots of people. Maybe its just me though, so I could be wrong. |
Fair enough, I don't think it'll be resolved at the cucumber level though, since that would require a fundamental change to the Step failure methodology. However, if you were to provide a pull request that can do optionally the ErrorCollecting, I'm confident it would be fairly reviewed. |
Well, I already re-invented the wheel on my end since it didn't seem like this would happen at first. I guess I can compare the two different runner classes and see what JUnit is doing instead of you guys. Would take me a bit though. |
Hello, I've seen a lot of threads on the Web about people wanting to continue steps execution if one failed. But if you REALLY need this feature, like our project do, we've done a fork of Cucumber-JVM. The fork is available here: Best regards, |
Hi @JasonSmiley , I hope that the suggestions from the team have provided you with some different ways around your problem, or that the code mentioned here by @slaout is suitable for solving it. Since the team have indicated that they don't intend Cucumber-JVM to work in the way you describe (I support them in this), I am closing this ticket as a "won't fix". I hope you're enjoying your work with Cucumber-JVM! |
No worries, I found a suitable workaround. Thanks for responding!
…Sent from my iPhone
On Jun 28, 2017, at 8:40 AM, Liz Keogh <notifications@github.com<mailto:notifications@github.com>> wrote:
Hi @JasonSmiley<https://github.com/jasonsmiley> , I hope that the suggestions from the team have provided you with some different ways around your problem, or that the code mentioned here by @slaout<https://github.com/slaout> is suitable for solving it. Since the team have indicated that they don't intend Cucumber-JVM to work in the way you describe (I support them in this), I am closing this ticket as a "won't fix". I hope you're enjoying your work with Cucumber-JVM!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#771 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADEcgh85Rkwj-d-QVij4y7fhD83qmyohks5sIkmqgaJpZM4CenMx>.
|
Hi @JasonSmiley , could you share your workaround with me? I also stuck with this problem |
I basically just wrote my own implementation by copy and pasting the error collector into my project, and then writing an after step to call the verify function (made public), and used the error collector as needed
…Sent from my iPhone
On Oct 19, 2017, at 6:46 AM, Andrii Dvoinik <notifications@github.com<mailto:notifications@github.com>> wrote:
Hi @JasonSmiley<https://github.com/jasonsmiley> , could you share your workaround with me? I also stuck with this problem
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#771 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADEcgs9ihVl9QXtbmLVa500sKoVd0sXkks5styiSgaJpZM4CenMx>.
|
You mean an AfterStep like this: https://github.com/cucumber/cucumber/wiki/Hooks#step-hooks ? So it only works with Ruby. No support in Java: see this issue: #604 |
Just for clarify, here is what I did:
|
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. |
I think this would be a common enough concern that it would work, however, I saw a post elsewhere saying this is not supported. (https://groups.google.com/forum/#!msg/cukes/qMwgAVzWmR0/GSkRUgJ8f4EJ)
I am ok with this not being supported at the moment, however, it seems like Error Collecting is something that any test developer would want.
Can we get this support inserted or get a cucumber equivalent?
The text was updated successfully, but these errors were encountered: