Make Enclosed runner not try to run the tests in static nested classes without test methods
See original GitHub issueThe Enclosed runner treats all static nested classes as test classes. If any static nested classes have no methods annotated with @Test
you will get a failure. This prevents you from having a nested class that is a helper class. It would be great if Enclosed would ignore those classes.
Suggestion: Make Enclosed runner ignore all the inner classes annotated with @Ignore just like it works for ignoring the tests with @Ignore.
@RunWith(Enclosed.class)
public class RootTest {
@Ignore
public static class B {
......
}
public static class FooTest {
@Test
public void testFoo() {
B b = new B();
....
}
}
}
Issue Analytics
- State:
- Created 10 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
how can I use @Enclosed without making methods as static
Unfortunately, the Enclosed runner requires that the enclosed classes be static (aka "nested classes").
Read more >Running non-static inner classes of JUnit tests
Running non -static inner classes of JUnit tests. JUnit ships with an "experimental" custom runner called Enclosed . When you annotate a test...
Read more >JUnit5 inner test classes should be annotated with @Nested
This rule raises an issue on inner classes and static nested classes containing JUnit5 test methods which has a wrong usage of @Nested...
Read more >JUnit 5 Tutorial: Writing Nested Tests - Petri Kainulainen
This blog post describes how we can write nested tests with JUnit 5. ... All nested test classes must be non-static inner classes....
Read more >Testing - Spring
The POJOs that make up your application should be testable in JUnit or TestNG tests, with objects instantiated by using the new operator, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried this with JUnit 4.11 and I didn’t got any error if I put the @Ignore on the B class. Probably fixed already.
Thanks for the feedback!