You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests declared within a @Nested inner class inheriting from their parent abstract class should run out of the box.
Actual
No tests are picked up.
Rationale
I want to test multiple strategies (MapperEngine). In order to verify feature parity, the tests are abstract functions.
To avoid boilerplate and group the tests, the strategy implementation verifications are inner classes of the abstract class.
Steps to reproduce
abstractclassMapperEngineTest {
abstractfunmap()
@Nested
innerclassLiquid : MapperEngineTest() {
@Test
// this test should run, but it doesn'toverridefunmap() { ... }
}
@Nested
innerclassReplace {
@Test
// doesn't run either (this time without inheriting the abstract class)funmap() { ... }
}
}
Context
Used versions: JUnit 5.10.2
Build Tool/IDE: Gradle 8.10.2, IntelliJ 2024.3 RC
The text was updated successfully, but these errors were encountered:
For @Nested on inner classes to work, JUnit needs to be able to create an instance of the enclosing class. Since it's abstract that doesn't work here. Instead of using @Nested (which requires inner classes) you should use regular "static" classes:
I've added this issue to #242 which will introduce an error reporting mechanism that should be triggered if such a @Nested annotation is found on a inner class of an abstract class so you'd notice what's wrong sooner.
@marcphilipp thank you for the quick help, that works as expected indeed!
The error report mechanism would be awesome to avoid such issues in the future.
Expected
Tests declared within a
@Nested inner class
inheriting from their parentabstract class
should run out of the box.Actual
No tests are picked up.
Rationale
I want to test multiple strategies (
MapperEngine
). In order to verify feature parity, the tests areabstract fun
ctions.To avoid boilerplate and group the tests, the strategy implementation verifications are
inner class
es of theabstract class
.Steps to reproduce
Context
The text was updated successfully, but these errors were encountered: