Filed under: Java, Tools, — Tags: IntelliJ IDEA, JUnit, Test template — Thomas Sundberg — 2012-06-01
A test template for JUnit tests doesn't exist out of the box for IntelliJ IDEA. Creating one is not complicated.
The goal is to create a simple template that will assist you when you need to write a test in JUnit. I want it to look something like this:
@Test public void should_assert_a_behaviour() { // Given // Setup the system under test // When // Execute the system under test // Then // Assert that the expected change has occurred }
To add it follow, these steps:
To use the new template, just press cmd j or ctrl j (depending on your os) and select 'test'.