ParameterizedTest with a name in Eclipse Testrunner

前端 未结 5 576
小鲜肉
小鲜肉 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:28

    If you use JUnitParams library (as I have described here), the parameterized tests will have their stringified parameters as their own default test names.

    Moreover, you can see in their samples, that JUnitParams also allows you to have a custom test name by using @TestCaseName:

    @Test
    @Parameters({ "1,1", "2,2", "3,6" })
    @TestCaseName("factorial({0}) = {1}")
    public void custom_names_for_test_case(int argument, int result) { }
    

    @Test
    @Parameters({ "value1, value2", "value3, value4" })
    @TestCaseName("[{index}] {method}: {params}")
    public void predefined_macro_for_test_case_name(String param1, String param2) { }
    

提交回复
热议问题