如何在同一个源集合中将集成测试与集成测试分开? [英] How do I separate gradle unit tests from integration tests in the same source set?
问题描述
./ test /
中才能工作。 ./ it /
是不可接受的,因为每次你尝试做任何事时,IntelliJ都会将它作为错误的来源。那么......我如何将集成测试与单元测试分开,以便它们可以在Gradle中单独运行(如果它们位于相同的源代码集中)?我们使用 * Test * .java
和 * ITCase * .java
命名约定,如果有帮助的话。我们正在考虑使用的某种方式是使用JUnit的 @Category 注释。 请投票支持此问题。考虑到Gradle在单元测试的不同目录下进行集成测试,这将成为任何IntelliJ商店的一面刺。
我不能说IntelliJ配置,但在 build.gradle $ c $如果你有:
test {
if(!project.hasProperty(ITCASE)){
排除** / * ITCase *
}
}
<那么下面的命令行会包含集成测试:
gradle test -PITCASE = true
code>
那么标准将会排除它们:
gradle test
The problem is that we are an IntelliJ shop and this issue has been a thorn in our sides. It basically means that everything has to be in ./test/
in order to work. ./it/
isn't acceptable because IntelliJ picks it up as the wrong kind of source every time you try to do anything. So.... how do I separate integration tests from unit tests so that they can be run separately in Gradle if they are in the same source set? Anyone have an example?
We use the *Test*.java
and *ITCase*.java
naming conventions, if that helps. Anothing thing we were thinking of is some kind of use of JUnit's @Category annotation.
P.S. Please vote for this issue. It will be a thorn in the side of any IntelliJ shop considering Gradle that has integration tests in a different directory from unit tests.
I can't speak to IntelliJ configuration, but in build.gradle
, if you have:
test {
if (! project.hasProperty("ITCASE")) {
exclude "**/*ITCase*"
}
}
then the following command-line would include the integration tests:
gradle test -PITCASE=true
then and the standard would exclude them:
gradle test
这篇关于如何在同一个源集合中将集成测试与集成测试分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!