Skip to content
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

Add support for @Parameters in SpringJUnit4ClassRunner #277

Closed
wants to merge 1 commit into from

Conversation

gpitteloud
Copy link

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

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).

In the case of a parameterized test, the TestContextManager is created
once for the test class.

Issue: SPR-5292
@sbrannen
Copy link
Member

sbrannen commented Feb 22, 2019

Original JIRA issue: SPR-5292

@sbrannen
Copy link
Member

GitHub issue: #9965

@sbrannen
Copy link
Member

Closing this PR as a duplicate of #12387.

@sbrannen sbrannen closed this Feb 22, 2019
@pivotal-issuemaster
Copy link

@gpitteloud Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@sbrannen sbrannen added in: test Issues in the test module status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 22, 2019
@sbrannen sbrannen removed their assignment Feb 22, 2019
@pivotal-issuemaster
Copy link

@gpitteloud Thank you for signing the Contributor License Agreement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants