我正在尝试使用JUnit 4.11来设置执行顺序。
我已尝试在Ecipse IDE中的此链接(Changing names of parameterized tests)上运行参数化测试示例,我看到Eclipse IDE中显示的测试名称没有变化。我希望看到测试名称显示为test [1:fib(1)= 1]和test [4:fib(4)= 3],但它们显示为test [0]和test [1]
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
以下在Eclipse IDE中运行的示例导致以下执行顺序(b,a,d,c)而不是预期的(a,b,c,d)
package com.org;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ExecutionOrderTestName {
@Test
public void bTest() {
System.out.println("b");
}
@Test
public void aTest() {
System.out.println("a");
}
@Test
public void dTest() {
System.out.println("d");
}
@Test
public void cTest() {
System.out.println("c");
}
}
测试的顺序没有发生,我做错了什么?
答案 0 :(得分:5)
这听起来像你在类路径上有另一个JUnit。看看你是否有,并将其删除。在Eclipse中,您可以查看Project Properties-> Java Build Path,然后是Libraries选项卡。