-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Provide shorter 'alias' for SpringJUnit4ClassRunner [SPR-13954] #18527
Comments
Juergen Hoeller commented Note that we're following JUnit's own naming conventions there: The base class is called With JUnit 5 on the immediate horizon already, I'm not sure a renaming (i.e. the introduction of an empty subclass of Juergen |
Sam Brannen commented FWIW, JUnit actually introduced such a feature in JUnit 4.5: So with JUnit you can annotate your test class like this: I of course agree with Juergen that it's rather late in the game to do the same in Spring, but... even I would benefit from having to type less until Spring 5 / JUnit 5. ;) And now for a wild and crazy idea... How about introducing a final subclass of That would allow the following, super concise declaration: @RunWith(Spring.class) And... since we will never introduce any additional JUnit Thoughts? |
Sam Brannen commented Plus... I'm certain that a lot of developers will continue to use JUnit 4 even after JUnit 5 is released. And we naturally won't be dropping our JUnit 4 support in Spring 5. So with those points in mind, a shorter name/alias for the Spring runner would still be useful for years to come. |
Juergen Hoeller commented OK, point taken, if even JUnit itself has a shortcut for it, it makes sense to have one of our own as well. That said, sorry, I can't swallow a class named "Spring" :-) Seriously, what if somebody else wants similar aliasing in e.g. a template language and also names their class "Spring" there. Auto-import trouble all over the place, aside from the strange looking class name. I also don't want this to show up like that when somebody says "Open Type" in the IDE, starting with "Spring". On a related note, point taken that the version number doesn't have to be in there... but even JUnit has it in its Juergen |
Sam Brannen commented Ok, ok... no classes named simply As I said, it was a wild and crazy idea (which I assumed would get shot down quickly). ;) The reason that the JUnit team decided on JUnit 5 has extensions instead of runners. So, in my prototype for Spring 5's JUnit 5 support, I have called our integration simply Thus it's probably a good idea to strive for some consistency in our naming conventions for runners and extensions. I see two possibilities: Including JUnit Version Numbers@RunWith(SpringJUnit4.class)
public class MySpringJUnit4Tests { /* ... */ } @ExtendWith(SpringJUnit5.class)
public class MySpringJUnit5Tests { /* ... */ } Excluding JUnit Version Numbers@RunWith(SpringRunner.class)
public class MySpringJUnit4Tests { /* ... */ } @ExtendWith(SpringExtension.class)
public class MySpringJUnit5Tests { /* ... */ } Thoughts? |
Juergen Hoeller commented I quite like that |
Sam Brannen commented OK, unless we get significant negative feedback, I'll go with the Phil Webb, is |
Phil Webb commented It's short but still a bit ugly. Is there any reason to include the version of JUnit in the class name? Since the runner is in @RunWith(SpringRunner.class) @ExtendWith(SpringExtension.class) |
Stéphane Nicoll commented If |
Sam Brannen commented The more I think about it, the more I like Plus, we already have several precedents for duplicated class names in different packages. For example, consider For a JUnit 4 |
Juergen Hoeller commented
|
Sam Brannen commented Completed as described in GitHub commit 9d3dd1b:
|
Phil Webb opened SPR-13954 and commented
The
SpringJUnit4ClassRunner
is a bit of an ugly name and since it's now the only JUnit runner perhaps it could be renamed (or aliased) to something more succinct:Referenced from: commits 9d3dd1b
The text was updated successfully, but these errors were encountered: