我刚刚JUnit
按照示例使用 4.11 实现了一个 JUnit 测试用例:
https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.11.md#example-1
我使用创建一个 Maven 项目
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yyt</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
而这个测试用例:
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class Example {
@Parameters(name = "{index}: fib({0})={1}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 },
{ 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });
}
private int input;
private int expected;
public Example(int input, int expected) {
this.input = input;
this.expected = expected;
}
@Test
public void test() {
}
}
但是当我使用 测试它时mvn test
,maven 说:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
如何让它发挥作用?