If I generate test for a class which has let's say getId()
method the corresponding test method will be called getId()
as well.
Is it possible to setup IntelliJ to add some static prefix for automatically generated test methods?
For instance:
getId()
-> shouldGetId()
doStuff()
-> shouldDoStuff()
Go to Preferences > Editor > File and Code Templates
and choose JUnit4 Test Method
. This by default has the form of
@org.junit.Test
public void test${NAME}() {
${BODY}
}
Change to
@org.junit.Test
public void should${NAME}() {
${BODY}
}
You can change the template of the test method easily as follows:
Create a test class and press ALTR + Insert button in the keyboard and you will see a popup as shown in the following screenshot. Then press the right arrow key on the keyboard and "Edit Template" menu will be opened. Then click on it.
Change the method template as required and press on (In my cause it will be redirected to TestNG method template, but yours will be JUnit).
When you insert a method by ALTR + Insert (Shown in the first step) click on Test Method menu, then it will generate a method as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With