Running Unit and Integration Tests in IntelliJ

2019-07-16 06:36发布

I currently have two different sets of tests in my Java project:

  • Unit tests
  • Integration tests - these use Arquillian to run in a container

I currently use Gradle as my build script and JetGradle to integrate with IntelliJ 12. In my Gradle build script I have to sets of test class paths:

  • testCompile - This is the standard test configuration for unit tests in Gradle and maps to the test scope in IntelliJ.

  • integrationTestCompile - This is a custom test configuration with the additional Arquillian dependencies used by the integration tests. This does not currently get mapped to a scope in IntelliJ

Is there any way in IntelliJ to manage separate sets of test class paths one for unit tests and one for integration tests and use the integrated IntelliJ test runner to run one or the other?

Currently I have worked round this by adding all test dependencies to the IntelliJ test scope but I would like to not have to include the integration dependencies when running unit tests.

The only other solution I can find is to create a separate integration test module with it's own class path but this is not ideal.

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-16 07:00

It isn't possible to have separate test scopes in IDEA because the latter only supports a fixed set of scopes (strongly inspired from Maven). It is, however, possible to configure the Gradle IDEA plugin to map both testCompile and integrationTestCompile (and also the corresponding runtime configurations) to IDEA's test scope. From your description, I'm not sure if you have already done that.

查看更多
登录 后发表回答