首页 > 解决方案 > 通过 IntelliJ 2019 的“创建测试”功能重新定义用于创建 JUnit 5 类的模板

问题描述

标签: templatesintellij-ideajunitjunit5junit-jupiter

解决方案


JUnit 5 method template can be configured in Settings (Preferences on Mac) | Editor | File and Code Templates | Code tab, JUnit 5 Test Method:

method template

Change this:

@org.junit.jupiter.api.Test
void ${NAME}() {
  ${BODY}
}

…to this:

@org.junit.jupiter.api.Test
@org.junit.jupiter.api.DisplayName ( "NameGoesHere" )
void ${NAME}() {
  ${BODY}
}

推荐阅读