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 Recipe to add @TestInstance(Lifecycle.PER_CLASS) to JUnit Test classes #5

Closed
MBoegers opened this issue Mar 2, 2024 · 0 comments · Fixed by #6
Closed

Add Recipe to add @TestInstance(Lifecycle.PER_CLASS) to JUnit Test classes #5

MBoegers opened this issue Mar 2, 2024 · 0 comments · Fixed by #6
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@MBoegers
Copy link
Owner

MBoegers commented Mar 2, 2024

To align JUnit Junipter test behaviors with the TestNGs the annotation @TestInstance(Lifecycle.PER_CLASS) is mandatory.
We need a recipe that adds this annotation to all classes containing Methods annotated with @org.junit.jupiter.api.Test.

Example

Before

import org.junit.jupiter.api.Test;

class MyTest {
  @Test
  void aTest() {}
}

After

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MyTest {
  @Test
  void aTest() {}
}

Remark

This recipe should be a general one line the MigrateTestAnnotation one see here

@MBoegers MBoegers added enhancement New feature or request help wanted Extra attention is needed labels Mar 2, 2024
@MBoegers MBoegers added this to the V1.0 milestone Mar 2, 2024
@MBoegers MBoegers self-assigned this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
1 participant