[英]How do I separate gradle unit tests from integration tests in the same source set?
The problem is that we are an IntelliJ shop and this issue has been a thorn in our sides. 问题是我们是IntelliJ商店, 这个问题一直是我们的一个棘手问题。 It basically means that everything has to be in
./test/
in order to work. 它基本上意味着一切都必须在
./test/
才能工作。 ./it/
isn't acceptable because IntelliJ picks it up as the wrong kind of source every time you try to do anything. ./it/
是不可接受的,因为每当你尝试做任何事情时,IntelliJ都会把它当作错误的来源。 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? 那么....如何将集成测试与单元测试分开,以便它们可以在Gradle中单独运行(如果它们在同一个源集中)? Anyone have an example?
有人有例子吗?
We use the *Test*.java
and *ITCase*.java
naming conventions, if that helps. 如果有帮助,我们使用
*Test*.java
和*ITCase*.java
命名约定。 Anothing thing we were thinking of is some kind of use of JUnit's @Category annotation. 我们想到的一件事是使用JUnit的@Category注释。
PS Please vote for this issue . PS请投票支持这个问题 。 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.
考虑到Gradle在与单元测试不同的目录中进行集成测试,这将是任何IntelliJ商店中的一根刺。
I can't speak to IntelliJ configuration, but in build.gradle
, if you have: 我不能说IntelliJ配置,但是在
build.gradle
,如果你有:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.