我有一个使用旧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'
}
但是我不知道是否排除这样的唯一解决方案。
有没有办法消除此警告?
最佳答案
从JUnit FAQ:
Why do I get the warning "AssertionFailedError: No tests found in XXX" when I run my test?
Make sure you have more or more method annotated with
@Test
.
添加至少一个测试或排除您所描述的类。
关于java - gradle测试任务在扩展TestCase的Test Util类上失败,但是没有测试方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54528943/