运行gradle junit:如何从jar文件中选择测试 [英] gradle junit runs: how to pick tests from jar file

查看:166
本文介绍了运行gradle junit:如何从jar文件中选择测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以运行j 单元批处理测试,并从jar文件中挑选测试。

 < zipfileset src =tests-only.jarincludes =** / * Test.class/> ; 

这将运行从test-only.jar中挑选的所有匹配测试

如何用gradle做类似的事情。 testClassesDir 只需要实际的目录。

解决方案

Gradle没有内置的特性来运行Jar文件中包含的测试类。 (可以通过 http://forums.gradle.org 提交功能请求。)应该运行的是拆包Jar(作为一个单独的任务),然后相应地设置 testClassesDir 。请注意,测试类也需要存在于测试任务的 classpath 中(但它可能已经足够使用Jar了)。


We can run junit batchtest with tests picked from a jar file.

<zipfileset src="tests-only.jar" includes="**/*Test.class"/>

This runs all matching tests picked from test-only.jar

How to do similar thing with gradle. The testClassesDir only takes actual directory.

解决方案

Gradle doesn't have a built-in feature for running test classes contained in a Jar file. (Feel free to submit a feature request at http://forums.gradle.org .) What should work is unpacking the Jar (as a separate task) and then setting testClassesDir accordingly. Note that the test classes will also need to be present on the test task's classpath (but it might be good enough to use the Jar for this).

这篇关于运行gradle junit:如何从jar文件中选择测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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