Skip to content

4.x: Convert JUnit 4 tests into JUnit 6 tests #8079

Closed

Description

@akarnokd

So we can take proper advantage of @Isolated testing.

The easy part is to use the @Test from org.junit.jupiter.api.* package.

The difficult ones are changing @Test(expected = TestException.class)

into

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;

@Test
void shouldThrowException() {
    assertThrows(TestException.class, () -> {
        // code that is expected to throw Exception (or subclass)
    });
}

Activity

  1. added this to the 4.0 milestone on Mar 25, 2026
  2. added theissue type on Mar 25, 2026
  3. akarnokd commented on Jun 29, 2026

    @akarnokd
    MemberAuthor

    Started working on this. Have to be done in one swoop. I'm sorry.

    The process is straightforward:

    • Remove JUnit 4 and Vintage converters
    • Look at the 20k error points in Eclipse problems
    • Each file, Organize imports, fix assertions static imports, rewrite expected exception tests
    • Change message order in assertXXX calls 😢
  4. self-assigned this
    on Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions