Junit参数化名称不会显示

时间:2017-06-19 15:29:27

标签: junit4 parameterized

您好我在我的maven依赖项中运行Junit 4.12并且以下示例代码没有产生任何错误,并且运行完全正常,但是,在eclipse neon中,参数化名称不会显示。所有显示的都是索引。

我花了相当多的时间搜索谷歌和其他堆栈溢出问题,但没有看到任何有类似问题的人。谢谢您的帮助。 Attached is an image of the output

import static org.junit.Assert.assertEquals;

import java.util.Arrays;

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 FibonacciTest {

    @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 FibonacciTest(int input, int expected) {
        this.input = input;
        this.expected = expected;
    }

    @Test
    public void test() {
        assertEquals(expected, Fibonacci.compute(input));
    }
}

0 个答案:

没有答案