This post is available at http://www.thinkcode.se/blog/2012/06/01/adding-a-junit-test-template-in-intellij-idea
Actually, IntelliJ has a template for creating JUnit tests, but it is available as a “File template” and not a “Live template”:
1. Open your test class
2. “Right click” and select “Generate…” (or simply press “ctrl” + “n” if you use mac)
3. Select “Test Method” and implement your test
To change the template:
1. Open “Settings”
2. Select “File Templates”
3. Select “Code”
4. Select “JUnit4 Test Method” and do your changes
Comment by Mattias Severson — June 6, 2012 @ 18:24
This was news to me. I will make I try it out to see if does what I want it to do.
Thanks for telling!
Comment by Thomas Sundberg — June 7, 2012 @ 19:00
And also, if you are looking at the class you want to test, just press Ctrl-Shift-T (or Cmd-Shift-T) and it will create the test class for you after asking whether you want to use junit 3,4 or testng.
Comment by Jamie Briant — November 27, 2013 @ 06:25
The only issue I have with that is that I must create the class I want to test before I start writing the tests. I prefer to work the other way around, create the test and then see which classes I actually have to implement.
Comment by Thomas Sundberg — November 27, 2013 @ 07:24
RSS feed for comments on this post. TrackBack URI
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.
Blog at WordPress.com.