简体   繁体   中英

Passing the test name as a parameter

I am using Junit5 parametrizedTests and want to know if there is a possibility to generate the test name with a more advance way than to use something more advanced than @DisplayName.

The best thing for me would be having a way to use a method to generate the test name using a specific logic and the parameters that are passed to that test.

Thanks in advance.

You could extends DisplayNameGenerator.ReplaceUnderscores and use it in annotation @DisplayNameGenerator:

@DisplayNameGeneration(YorNameGenerator.class)
class YourTest {
    ...
}

Have a look at example in the documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM