Add support for @Parameters in SpringJUnit4ClassRunner #277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, it was not possible to use JUnit's @parameters
annotation in a test that runs within the Spring TestContext
framework, in order to run each test multiple times with values
defined by the invocation of the @parameters static method, as it is
the case with JUnit's Parameterized runner.
This commit introduces such support, by delegating either to a
parameters-aware spring runner, or to the standard Spring runner,
depending on the presence or absence of a public static method
annotated with @parameters.
SpringJUnit4ClassRunner now just makes the decision and delegates
to another runner. The code that was once in SpringJUnit4ClassRunner
is now in a package-protected internal runner
(InternalSpringJUnit4ClassRunner), which is used either directly or
through the package-protected, parameters-aware spring runner
(SpringJUnit4ParameterizedClassRunner).
The TestContextManager is created once and reused for each set of
parameters. If @IfProfileValue is present on the class level and the
criteria is not matched, the TestContextManager is not created,
other annotations (@ContextConfiguration, @TestExecutionListeners)
are not parsed, and the test class is immediately ignored.
@BeforeClass/@afterclass methods and TestExecutionListener's
beforeTestClass/afterTestClass methods are each executed once for
a parameterized test class.
Issue: SPR-5292
I have signed and agree to the terms of the SpringSource Individual
Contributor License Agreement.
Gaëtan