[英]How to package tests with gradle and run from command line?
I have a large code base built with gradle to a fatjar. 我有一个用gradle到fatjar的大型代码库。 I have several JUnit tests which run when building.
我有几个在构建时运行的JUnit测试。
The jar & resources will be provided to a 3rd party on an isolated system, which does not have gradle and the ability to build the whole code base (and run the test goal). jar和资源将提供给隔离系统上的第3方,该系统没有gradle且不能构建整个代码库(并运行测试目标)。
Question: How can I provide my tests with the jar, and allow them to be run from command line like running a jar? 问题:如何为jar提供测试,并允许它们像运行jar一样从命令行运行?
I can't find anything on SO about distributing tests using gradle, and all the command line JUnit examples are insufficient because they require manually entering the classpath and the number of dependencies is enormous (hence use of gradle + fatjar). 我在SO上找不到任何有关使用gradle分发测试的信息,并且所有命令行JUnit示例都不足够,因为它们需要手动输入类路径并且依赖项数量巨大(因此使用gradle + fatjar)。
While searching for a similar problem, I came across http://mrhaki.blogspot.com/2010/11/gradle-goodness-create-jar-artifact.html My modifications are as follow: 在寻找类似问题时,我遇到了http://mrhaki.blogspot.com/2010/11/gradle-goodness-create-jar-artifact.html我的修改如下:
task testJar(type: Jar, dependsOn:[testClasses]) {
from sourceSets.test.output.classesDir
}
You might want to continue from there. 您可能要从那里继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.