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

Provide JUnit5 extension for integration tests as a replacement for old junit4 rule #3828

Closed
de-jcup opened this issue Jan 27, 2025 · 0 comments · Fixed by #3822
Closed

Provide JUnit5 extension for integration tests as a replacement for old junit4 rule #3828

de-jcup opened this issue Jan 27, 2025 · 0 comments · Fixed by #3822
Assignees

Comments

@de-jcup
Copy link
Member

de-jcup commented Jan 27, 2025

Situation

Currently we have for integration tests only a Junit4 way:

import org.junit.*;

public class XyzScenario1Test {

    @Rule
    public IntegrationTestSetup setup = IntegrationTestSetup.forScenario(Scenario12.class);

    @Test
    public void integrationTestXyz(){
        // ... the integration test
    }
}

Wanted

We want to provide Junit5 way

Solution

We will provide a Junit5 extension called IntegrationTestExtension.
To provide test scenario parameters we introduce: @WithTestScenario

Here an example how it will look like when using Junit5:

import org.junit.jupiter.api.Test;

@ExtendWith(IntegrationTestExtension.class)
@WithTestScenario(Scenario1.class)
class XyzScenario1IntTest {

     @Test
     void integrationTestXyz(){
        // ... as usual
     }
}
@de-jcup de-jcup self-assigned this Jan 27, 2025
de-jcup added a commit that referenced this issue Jan 27, 2025
- junit4 rule logic moved to IntegrationTestSupport class
- junit4 rule uses now the integration test support
- junit5 extension IntegrationTestExtension created
  + WithScenario annotation
- junit5 extension uses also IntegrationTestSupport class
@de-jcup de-jcup closed this as completed in ce0f1f0 Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant