Inspectopedia 2025.2 Help

JUnit API usage from multiple versions in a single TestCase

Reports JUnit annotated methods when used in a test case from a different JUnit version. To determine the framework version for a test case the inspection checks the framework version of the super class when available. When a super class is not available it will use the most used framework in the test case.

Example (JUnit 4 annotation in JUnit 3 test case):

public class MyTest extends TestCase { @Test public void foo() { } @Test @Ignore public void testBar() { } }

After the quick-fix is applied:

public class MyTest extends TestCase { public void testFoo() {} public void _testBar() {} }

Example (JUnit 5 annotation in JUnit 4 test case):

public class MyTest { @BeforeAll // JUnit 5 lifecycle method public void initialize() { } @org.junit.Test // JUnit 4 test annotation public void test() {} @org.junit.Test // JUnit 4 test annotation public void testWouldBeExecuted() {} }

After the quick-fix is applied:

public class MyTest { @BeforeClass // JUnit 4 lifecycle method public void initialize() { } @org.junit.Test // JUnit 4 test annotation public void test() {} @org.junit.Test // JUnit 4 test annotation public void testWouldBeExecuted() {} }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

JUnitMixedFramework
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | JUnit

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection JUnitMixedFramework

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025