Java – JUnit test inheritance does not work

public abstract class GenericTests<T extends Number> {
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> { ... }

No tests were performed at all, and both concrete classes were ignored How can I make it work? (I expect test1 () for integers and doubles)

I use JUnit 4.8 one

Update: it seems that this problem is related to Maven surefire plugin, not JUnit itself Look at my answer below

Solution

Rename all my classes to the suffix "test" and now it works (concrete1test, concrete2test)

to update:

This is related to the default settings of Maven surefire plugin

http://maven.apache.org/plugins/maven-surefire-plugin/examples/inclusion-exclusion.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>