Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding tests from being run in IntellIJ

Is it no option to exclude some tests in IntelliJ IDEA Ultimate? I want to run unit tests in IntelliJ but exclude the integration tests. I name the integration tests with *IT.java so the Maven failsafe plugin can run them seperatly from the unit tests.

like image 465
user626912 Avatar asked Oct 27 '12 21:10

user626912


People also ask

How do I exclude a test in IntelliJ?

To exclude let's say "integration-test", you just need to specify as tags: ! integration-test , and IntelliJ will run all your JUnit5 tests except the ones tagged with integration-test . Take a look at this answer for details (including screenshot).

How do I stop a test from execution in IntelliJ?

Stop tests or press Ctrl+F2 to terminate the process immediately. Click. to terminate the process gracefully, allowing shutdown hooks to run.

How do I change test runner in IntelliJ?

Open the Settings/Preferences dialog (press Ctrl+Alt+S ), and under the node Tools, click the page Python Integrated Tools. On this page, click the Default Test Runner field.


2 Answers

In the JUnit Run configuration set the Test kind to Pattern, specify the following regular expression as the pattern:

^(?!.*IT$).*$ 

It matches against the class name, so you don't need to match .java extension. Regular expression will not match if the class name ends with IT using the negative lookahead.

ignore tests ending with IT

like image 50
CrazyCoder Avatar answered Oct 19 '22 13:10

CrazyCoder


With JUnit5, you can now tag your tests, e.g: @Tag("integration-test").

Also, given IntelliJ supports now JUnit5 as well, you can then create a JUnit Test Configuration and select Test Kind: Tags (JUnit5).

To exclude let's say "integration-test", you just need to specify as tags: !integration-test, and IntelliJ will run all your JUnit5 tests except the ones tagged with integration-test.

like image 26
João Pinho Avatar answered Oct 19 '22 13:10

João Pinho