Running Unit and Integration Tests in IntelliJ

故事扮演 提交于 2019-12-12 16:38:42

问题


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:


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.



来源:https://stackoverflow.com/questions/19277665/running-unit-and-integration-tests-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!