I have a gradle project with "unit test" and "integration tests" tasks defined as follows:
test {
include '**/*Test.class'
}
task integrationTest(type: Test) {
include '**/*IT.class'
}
I created a run configuration in IntelliJ to run all unit tests like image shows:
And did the same with the task 'integrationTest':
IntelliJ 'understands' the test task and run it showing graphical results, like in this image:
The same doesn't happen when it runs the 'integrationTest' task. The results are shown in text, like when I run the task by command line.
Answering my own question... As far as I know you can't make IntelliJ to run tests of a specific task and the Pattern solution doesn't work so well.
So, the only way I found to effectively separate integration tests in IntelliJ was with the use of a JUnit Category.
Create an interface to represent integration tests. For example:
public interface IntegrationTest {
}
You have to annotate every integration test class with the category annotation and the created interface:
import org.junit.experimental.categories.Category;
import mycompany.mypackage.IntegrationTest;
@Category(IntegrationTest.class)
public class DbfFileProcessorIT {
...
}