Skip to content

Add recipe to migrate Testcontainers as part of JUnit 4 to 5 migration #835

@jc65536

Description

@jc65536

What problem are you trying to solve?

As part of migrating from JUnit 4 to 5, we need to use the new Testcontainer Extension APIs.

What precondition(s) should be checked before applying this recipe?

JUnit 4 to 5 migration preconditions is sufficient

Describe the situation before applying the recipe

public class SimpleMySQLTest {
    @Rule
    public MySQLContainer mysql = new MySQLContainer();
}

Describe the situation after applying the recipe

@Testcontainers
public class SimpleMySQLTest {
    @Container
    public MySQLContainer mysql = new MySQLContainer();
}

Have you considered any alternatives or workarounds?

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

Yes, I have mostly written this recipe (see attached PR)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions