Support nested test classes with SpringClassRule & SpringMethodRule [SPR-14150] #18722
Closed
3 tasks done
Labels
in: test
Issues in the test module
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Milestone
Benoit AVERTY opened SPR-14150 and commented
Status Quo
The Spring TestContext Framework has traditionally supported only top-level or static nested test classes. With support for
@Nested
test classes in JUnit 5 and custom runners in JUnit 4, however, there is increased need to support nested non-static test classes (i.e., inner classes).Deliverables
ApplicationContext
via@ContextConfiguration
and related annotations for a nested test class.Class
, so the TestContext framework doesn't need to do anything special here.@Nested
test classes work with the TestContext framework.SpringClassRule
andSpringMethodRule
work in conjunction with JUnit 4 based runners that support nested test classes.JUnit 4 Hierarchical Runners
When using the
@Rule
and@ClassRule
classesSpringMethodRule
andSpringClassRule
in conjunction with a custom JUnit 4Runner
that allows one to use nested classes to create hierarchical tests, the tests in subclasses fail with anIllegalStateException
.Examples of hierarchical runners:
The second one doesn't have the same error, but I'm guessing the problem is similar.
The exception makes sense because the nested class indeed doesn't have the static
SpringClassRule
. But it can't have it because the nested class isn't static. Moreover, I'm not sure it would need it because the rule would be evaluated twice.Affects: 4.2.5
Issue Links:
Referenced from: commits ab7b5e5, e574820
The text was updated successfully, but these errors were encountered: