Adding a JUnit test template in IntelliJ IDEA

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:

Done!

To use the new template, just press cmd j or ctrl j (depending on your os) and select 'test'.

Resources



(less...)

Pages

About
Events
Why

Categories

Agile
Automation
BDD
Clean code
Continuous delivery
Continuous deployment
Continuous integration
Cucumber
Culture
Design
DevOps
Executable specification
Git
Gradle
Guice
J2EE
JUnit
Java
Javascript
Kubernetes
Linux
Load testing
Maven
Mockito
New developers
Pair programming
PicoContainer
Presentation
Programming
Public speaking
Quality
React
Recruiting
Requirements
Scala
Selenium
Software craftsmanship
Software development
Spring
TDD
Teaching
Technical debt
Test automation
Tools
Web
Windows
eXtreme Programming

Authors

Thomas Sundberg
Adrian Bolboaca

Archives

Meta

rss RSS