Excluding tests from being run in IntellIJ
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.
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
.