-
-
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
JUnit Rule annotation is not supported #393
Comments
You can take screenshots in an After hook, checking |
I'm not suggesting of making JUnit a dependency in core, but in cucumber-junit which already depends on JUnit. The point is that rules are very flexible and represent a JUnit standard extension mechanism and supporting rules can redirect all those weird requests you receive into just "can't you write a rule for it?" BTW, I tried that solution, but I wasn't able to have it working as I get an exception (I'm using Spring and the JavaHookDefinition class is trying to instantiate my singleton web driver a second time) and the imports look quite different as |
Feel free to send a pull request. I can't guarantee I'll accept it, but it's always easier to discuss around code. |
I spent a few hours on this and I ended up with an implementation that was working withing the JUnit constraints but it was then unable to manipulate the report so I think it's not worth to be evaluated. Thanks for your attention. |
Hi. I came across this thread because I am trying to put together a simple framework using a Page Object Model patten using Webdriver and using Cucumber as the BDD framework. I'm not a developer first and foremost, however I have taken the advice of Dave Haeffner in his book 'Selenium Guidebook for Java' in setting up a Base test class which uses JUnit's rule to set up an external resource and set capabilities then fire up a browser either locally or in saucelabs. I have conflict between this and my cucumber annotations and cannot get the two to play nicely together when my base test class is extended by my SearchTestDefinitions class. I suspect that if the cucumber api supported JUnit rule, I would not get this issue (but as I say, I am not a developer by nature). Any advice on how to combine the two if possible would be welcomed The code is at https://github.com/markwinspear/SeleniumCucumberJavaBasicTest2 Many thanks |
Rules are important for Android. See #894. |
I just came across this thread - see Serenity issue serenity-bdd/serenity-core#221 It seems this feature would be very helpful for Spring integration, and a lot of people use Spring in the JVM world. Is there any chance this could be looked at again? |
+1 I think the solution would be to have |
I'm also wanting to put some time into this but haven't looked into it since I last commented as I've been away on holiday. @alb-i986 I'll take a look at what you're suggesting. It sounds like you're ahead of me in conceptualizing a solution. I'll be able to comment more once I take a fresh look at the code. |
@aslakhellesoy |
I can think of one potential issue, but maybe not an issue (not sure how Cucumber.class is being used).
Therefore, if If this class is being used for by the DI cucumber runners, then you might just need a "CucumberJunitRule" runner for Pure Java implementations. For the record, I would love to see a Cucumber Runner which would allow me to use rules out of the box :). Currently I am just pulling in the Rules manually into my projects (copy and paste style) since I usually update them to work with my code base anyways (basically I would pull in my scenario objects for logging purposes) |
There is also a JUnit 5 alternative... :) Il lunedì 29 febbraio 2016, Jason Smiley [email protected] ha
|
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. |
The JUnit Rule annotation support would be very useful to allow to take snapshots on failing tests, but the Cucumber JUnit runner does not support such annotation.
I think that it should be easy to add this support by modifying the runners and introducing the JUnit Statement class usage: I've forked the project and started working on it: please let me know if this is an unwanted feature.
The text was updated successfully, but these errors were encountered: