-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support for custom JUnit rule instead of RunWith #4
Comments
How would you like it to work? Do you have an example in mind of what it would look like when you use all of these together? JUnit & test running is a bit complicated, and full of annotational magic. What would be the KISS solution? |
An alternative to using JUnitParams is WrappingParameterizedRunner which is in the |
With JUnit rules, the following things are not possible (afaik):
The first bullet can be circumvented (as proven by PowerMockRule), apparently by using java agents or similar to transform the classes being tested. It might be possible to use this technique for the third bullet also, haven't looked deeply enough into how PowerMockRule does it. Luckily most "features" that you might want to plug in (for example the list in the issue description) will do just fine without these bullets. In these cases it's probably even easier to implement the feature as a JUnit rule than as a runner. Of the features listed in the issue description I think all except the following should be possible to implement as JUnit rules:
An alternative for these is to make the runners wrapping runners (i.e. the runners calls another runner in a chain, for example like the Since you can still choose one runner to be the "bottom runner", it is enough that one of the above two "cannot be implemented as JUnit rule" features is implemented as a wrapping runner. Personally I would perhaps evaluate how hard it would be to do that for the NestedRunner first. Feel free to challenge any of my hypotheses above. |
@Macroz @xkr47 My assumption has been that Please note that I'm not well versed in the internals of Junit, am just someone trying find a comprehensive framework combination |
@thekalinga: The api is similar to I completely agree that as many "features" should be implemented as JUnit rules as possible. Everything else would benefit from supporting runner wrapping. I would love to see something new to replace the current JUnit that took out all these limitations in a single blow and allowed easy combination of features without crazy classloading stuff being required to combine them to get e.g. JUnitParams-style features. I wouldn't mind if it was the next major release of JUnit, as long as the current Runner concept and associated responsibility constraints would be replaced with open and collaborative concepts - like JUnit rules but for the whole process. |
@xkr47 Yes, could not agree with you more.. To me it seems everything boils down to lack of JUnit to chain
Update @xkr47 @Macroz Any suggestions on integrating these two frameworks? Thanks |
I am planning to use
Spring MVC in the current milestone version (4.2.0.RC1 or > 4.2 whenever the release happens) uses rules instead of runner to support integration with other runners. PowerMock currently supports Rules. Mockito supports Rule in the current Beta version (2.0.17-beta)
However, AFAIK, all others does not support rules. It would be better if this library can implement the runner using Junit Rule instead of Runner so that it can be compatible with all other runners to make a full blown testing stack. Else, people need to hack around to get most out of Java test frameworks.
Reference:
The text was updated successfully, but these errors were encountered: