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 do
Short answer:
doesn't work with JUnit 5
Long answer
CrazyCoder kindly responded to my post on Jetbrain's forum. He provided an answer and also uploaded his working project. That was helpful because I verified that pattern matching worked fine on his project.
Then another Jetbrain engineer responded to my How-To request. He pointed out IDEA-164088, JUnit 5 doesn't support pattern configurations
That's a known issue and will be fixed on versions 2017.2.X coming up on April 2017.
Solution
A workaround until then, is to use JUnit5 tags
@Tag("junit")
public class MyTest
and then run the following configuration that only picks up test classes annotated with that particular tag.
P.S. Actually, using Tags seems an even more elegant solution for the given task as long as the number of test classes is limited.
You can run all test case in a class, after that >> select some test case by hold Ctrl and click mouse >> run, then open config run and copy the pattern to edit more..
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: