简体   繁体   English

如何在同一源集中将gradle单元测试与集成测试分开?

[英]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.

相关问题 如何为单元测试创​​建单独的源代码树 - How to create separate source tree for unit tests 如何从 IntelliJ 上下文菜单为 gradle 项目运行集成测试? - How to run integration tests from IntelliJ context menu for gradle project? 我们应该在 intelliJ Gradle 项目中将集成测试、冒烟测试(不是单元测试)放在哪里? - Where should we put the integration tests, smoke tests (not unit tests) in the intelliJ Gradle project? IntelliJ中的运行单元和集成测试 - Running Unit and Integration Tests in IntelliJ 如何在Intellij中指定Dropwizard配置文件进行单元测试? - How do I specify the Dropwizard config file in Intellij for unit tests? 集成测试是从gradle构建运行的,而不是从intellij运行的? - Integration tests run from gradle build but not from intellij? 如何为 Junit 单元测试设置 JVM 参数? - How to set JVM parameters for Junit Unit Tests? 从 IntelliJ 和 Gradle 开始:如何进行 jUnit 测试? - Starting with IntelliJ and Gradle : how to do jUnit tests? 从 IntelliJ IDEA 中的 gradle 项目运行单元测试时,如何仅显示 class 名称? - How to show only class name when running unit tests from gradle project in IntelliJ IDEA? 按设置运行测试时单元测试失败? - Unit tests fail when tests run as set?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM