【发布时间】:2012-02-07 05:06:40
【问题描述】:
public abstract class GenericTests<T extends Number> {
protected abstract T getT();
@Test public void test1() {
getT();
}
}
public class ConcreteTests1 extends GenericTests<Integer> { ... }
public class ConcreteTests2 extends GenericTests<Double> { ... }
根本不执行任何测试,两个具体类都被忽略。我如何使它工作? (我希望test1() 对Integer 和Double 都执行)。
我使用 JUnit 4.8.1。
更新:问题似乎与 maven-surefire-plugin 相关,而不是 JUnit 本身。请参阅下面的答案。
【问题讨论】:
-
需要扩展TestCase吗?
-
Junit4 不需要你扩展 TestCase 但你是如何运行这些的?从命令行?来自 Eclipse?
-
能否包含其中一个子类的内容
-
什么是 B?当然它应该是 Number 除非你用 2 个同名的类,Double 和 Integer 对一个类进行子类化,作为核心库中的一个类?
-
我本以为你的代表已经接触到了这个网站所要求的迂腐水平,显然不是。