【发布时间】:2019-02-05 06:40:03
【问题描述】:
我有一个使用旧 Junit 3 方式的旧测试类:
public class MyTestUtil extends TestCase {
//class has helper methods but no method starting with "test"
}
我还有其他扩展这个类的测试类:
public class MyTests extends MyTestUtil {
public void testSomething() {
}
}
我正在尝试使用 gradle 构建文件来运行它。并且构建失败并出现警告:
junit.framework.AssertionFailedError: No tests found in myPackage.MyTestUtil
当我从测试任务中排除这个类时,构建显然运行良好:
test {
exclude '**/MyTestUtil.class'
}
但我不知道这样排除是否是唯一的解决方案。
有没有办法消除这个警告?
【问题讨论】:
-
只需添加一个测试方法。如果没有测试方法,该类无论如何都没有存在的理由