is it possible to create a Run/Debug configuration in IntelliJ that picks up only those files that match a regular expression?
I want to run all my unit tests. I don't want to run integration tests written by my colleagues. Integration tests contain the text "IT", so I thought the following regex would do:
^((?!IT).)*$
But it didn't.
EDIT
As a trivial example, I tried the following regex:
^.*IT.*$
(which does exactly the opposite of what I want to achieve), but still I fail. It still picks up every single Test and runs it.
Example tests that get picked up:
com.my_company.session.SessionTest.java
com.my_company.test.server.api.ITAuthentication.java
This is what the Test results panel looks like
Check in Project settings -> Modules that you test package is marked as Tests. Right click on the test class name either in the code window or in the project panel, and select Run <classname>. If you don't see the run menu in the popup then you haven't selected a test or you don't have junit plugin installed.
Show activity on this post. Open the class where the tests are located and check the part where inteliJ shows the the number of lines, at the beginning of each test method there is a green icon (looks like a play button) just hit that icon and the specific test method will be executed.
I've already provided the answer which describes how to exclude *IT.java
tests, but as your question is different and you want to exclude *IT*.java
tests (any test that has IT
in its name), the pattern would be different:
^(?!.*IT.*).*$
Note that it will not work with JUnit 5 in IntelliJ IDEA 2017.1, there is a known bug that is fixed for 2017.2 version:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With