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

Runner should be able to register itself with the Computer #816

Closed
bechte opened this issue Feb 9, 2014 · 1 comment
Closed

Runner should be able to register itself with the Computer #816

bechte opened this issue Feb 9, 2014 · 1 comment
Milestone

Comments

@bechte
Copy link
Contributor

bechte commented Feb 9, 2014

Currently, the resolving strategy of the test runner is very static. The only way for a Runner to participate is via the @RunWith annotation. This is more than fine as long as the runner does only support top-level classes.

Now with the HierarchicalContextRunner (see https://github.com/bechte/junit-hierarchicalcontextrunner), which has more and more stargazers, it's somehow different. This runner supports member classes and uses them to form a context hierarchy, i.e. member classes will inherit all initializations from the outer classes, without having to extend them. This is a great benefit.

Now, when the tests are executed, everything is fine. But when someone restarts a test of a lower hierarchy, then the test tools does not recognize the @RunWith annotation of the top-level class. Instead it tries to run the very most inner-class with the default JUnit4 runner, leading to a "The inner class XYZ is not static."-Exception.

I wish we could have an extension point other that the @RunWith annotation, that allows us to contribute to the way, JUnit resolves the runner, namely, the Computer mechanism should be more extendible.

If that's not possible, maybe we can change the current Computer in such a way, that given a non-static member class, the Computer resolves the top level class and verifies if this class is annotated with @RunWith and uses this runner instead of the default JUnit4 runner, which anyways does not support this kind of classes, at all.

For the latter approach, we would only have to change the current implementation of the AnnotatedBuilder.runnerForClass(Class) method to perform the check within a for-loop (see attached pull request).

What do you think about this change?

@kcooney
Copy link
Member

kcooney commented Apr 30, 2014

Fixed via #816

@kcooney kcooney closed this as completed Apr 30, 2014
@stefanbirkner stefanbirkner added this to the 4.12 milestone Apr 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants