gradle 测试任务在扩展 TestCase 但没有测试方法的 Test Util 类上失败

我有一个使用旧 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'   

}

但我不知道这样排除是否是唯一的解决方案。


有没有办法消除这个警告?


慕桂英546537
浏览 102回答 1
1回答

慕莱坞森

从 JUnit常见问题解答:为什么我在运行测试时收到警告“AssertionFailedError: No tests found in XXX”?确保您有更多或更多用@Test.要么添加至少一个测试,要么像您描述的那样排除该类。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java