声明要运行的测试而无需编译源代码 [英] Declare tests to run without compiling sources

查看:74
本文介绍了声明要运行的测试而无需编译源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这种情况:有一个大项目,需要花费大量时间进行编译,而我将其生成的工件作为单独的文件(jar)保存.

Consider such a situation: there's a big project, which takes tremendous time to compile and I'm having it's resulting artifacts as separate files (jar).

我想在此项目上运行单元测试,而无需编译和罐装项目本身,因此我需要删除对 compileJava 任务的依赖性,但是此任务不在 dependsOn中测试" 任务的列表.

I want to run the unit tests on this project without compiling and jar-ing project itself, so I need to remove dependency on compileJava task, but this task is not in the dependsOn list of test task.

dependsOn 属性仅包含一些 [文件集合] ,如果我要打印此 FileCollection.files ,我正在获取文件和目录的列表,其中包括 .../build/classes/main .我认为,删除该条目后,我将成功消除对 compileJava 的依赖(据我了解, .../build/classes/main 仅仅是结果运行 compileJava 的原因,这就是 compileJava 出现的原因.但是我只是不明白如何删除该条目.

dependsOn property of test task contains only some [file collection] and if I'm printing this FileCollection.files, I'm getting the list of files and directories, which include .../build/classes/main. I think, after removing this entry, I'll get success in removing dependency on compileJava (as I understood, .../build/classes/main is just the result of running compileJava and that's why compileJava appeared). But I just don't understand, how to remove this entry.

顺便说一句,在这种情况下,将这个jar添加到类路径中没有问题,所以这不是问题.

By the way, in this case there's no problem of adding this jar to classpath, so that's not an issue.

我正在使用Gradle 1.8.谢谢.

I'm using Gradle 1.8. Thanks.

推荐答案

compileJava 将是最新的,如果没有任何变化,并且不依赖 jar 通过 test 进行测试.但是,如果您想增加针对下载的Jar运行测试的功能,请声明另一个 Test 任务.(重新配置 test.classpath 应该也可以,但是似乎不太理想.)

compileJava will be up-to-date if nothing has changed, and jar isn't depended upon by test. If you nevertheless want to add the ability to run tests against a downloaded Jar, declare another Test task. (Reconfiguring test.classpath should work as well, but seems less desirable.)

这篇关于声明要运行的测试而无需编译源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆