如果我为一个具有getId()
方法的类生成测试,相应的测试方法也将被称为getId()
。
是否可以设置 IntelliJ 为自动生成的测试方法添加一些静态前缀?
例如:
getId()
-> shouldGetId()
doStuff()
-> shouldDoStuff()
最佳答案
转到 Preferences > Editor > File and Code Templates
并选择 JUnit4 Test Method
。默认情况下,它的形式为
@org.junit.Test
public void test${NAME}() {
${BODY}
}
更改为
@org.junit.Test
public void should${NAME}() {
${BODY}
}
关于java - 智能 : customize naming of generated test methods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45073740/