2

I am trying to use JUnit 4.11 to set execution order.

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. 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]

@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)

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?

Community
  • 1
  • 1
user1941746
  • 21
  • 1
  • 2
  • Remove all of your instances of junit, and re-add junit 4.11. You are using a version that does not do anything with that annotation. – Eric Leschinski Feb 19 '15 at 00:48

1 Answers1

5

This sounds like you have another JUnit on the classpath. See if you have, and remove it. In Eclipse, you can look at Project Properties-> Java Build Path, then the Libraries tab.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
  • Many thanks for your kind Assistance. Following your advice I have discovered a copy of JUnit 4.10 (D:\Java\jdk1.6.0_23\jre\lib\ext\junit-4.10.jar) in the classpath in addition to JUnit 4.11. I have removed JUnit 4.10 and the new features in JUnit 4.11 work fine. – user1941746 Jan 02 '13 at 11:11
  • Yeah, I can't wait until Eclipse upgrades their JUnit to 4.11+ . They still haven't done so. – djangofan Jan 17 '13 at 18:31