ParameterizedTest with a name in Eclipse Testrunner

前端 未结 5 568
小鲜肉
小鲜肉 2021-02-06 04:04

When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called [0], [

5条回答
  •  星月不相逢
    2021-02-06 04:23

    JUnit4 now allows specifying a name attribute to the Parameterized annotation, such that you can specify a naming pattern from the index and toString methods of the arguments. E.g.:

    @Parameters(name = "{index}: fib({0})={1}")
    public static Iterable data() {
        return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 },
                { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });
    }
    

提交回复
热议问题