[英]How to use new JUnit 4.11 features including change test name and set execution order
I am trying to use JUnit 4.11 to set execution order. 我正在尝试使用JUnit 4.11设置执行顺序。
I have tried running the Parameterized test example on this link ( Changing names of parameterized tests ) within Ecipse IDE and I see no change to the displayed test name in Eclipse IDE. 我尝试在Ecipse IDE中的此链接上运行Parameterized测试示例( 更改参数化测试的名称 ),但在Eclipse IDE中看不到显示的测试名称的任何更改。 I expect to see test names displayed like test[1: fib(1)=1] and test[4: fib(4)=3], but instead they are displayed like test[0] and test[1] 我希望看到测试名称显示为test [1:fib(1)= 1]和test [4:fib(4)= 3],但是它们却像test [0]和test [1]一样显示
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
The following example running in Eclipse IDE results in the following execution order (b,a,d,c) instead of the expected (a,b,c,d) 在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");
}
}
The ordering of tests is not happening, what am I doing wrong? 测试的顺序未发生,我在做什么错?
This sounds like you have another JUnit on the classpath. 听起来您在类路径上还有另一个JUnit。 See if you have, and remove it. 看看是否有,然后将其删除。 In Eclipse, you can look at Project Properties-> Java Build Path, then the Libraries tab. 在Eclipse中,您可以查看Project Properties-> Java Build Path,然后查看Libraries选项卡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.