Question:
- How to manually run a disabled Junit test in IntelliJ IDEA?
eg:
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class DisabledMethodTest {
@Disabled
@Test
public void testDisabled() {}
}
Answer:
-
Identify if the issue is occurring due to the runner being used. Using Gradle to run the tests would not enable the play button for tests marked as
@Disabled/Ignored. However, it should work if the IntelliJ runner is selected. -
Change the runner to IntelliJ's if it is not already, doing this should enable the play button for the disabled tests.
Follow these steps to change the runner :
-
Open the Run/Debug Configurations dialog box by navigating through Run | Edit Configurations.
-
In the dialog box, click Edit configuration templates… and select JUnit.
-
In the configuration settings, make sure that the Test runner is set to 'IntelliJ IDEA'.
- With the IntelliJ runner selected, the disabled Junit tests should show the play button allowing for manual execution even when they are marked disabled with
@Disabled.
Note:
The ability to run disabled Junit tests manually even when they are marked as @Disabled is advantageous for situations like testing UI forms by having these tests disabled for auto test, but manually run them via the play button.**
Comments
0 comments
Please sign in to leave a comment.