Boosted support for testing using the Spring framework

IntelliJ IDEA 2017.1: Spring is here

Gabriela Motroc

Group of people holding hands image via Shutterstock

IntelliJ IDEA 2017.1 is now available for download. It brings countless improvements to supported languages, frameworks, and built-in tools such as Java 8 and 9, Gradle, Kotlin 1.1, Spring, JavaScript and the list goes on.

IntelliJ IDEA 2017.1 is here and it comes bearing lots of gifts: improvements to supported languages, frameworks, and built-in tools such as Java 8 and 9, Gradle, Kotlin 1.1, Spring, JavaScript and the list goes on.

Spring Testing now supports Spring Boot 1.4.3. Furthermore, the upcoming Spring 5.0. Spring Data tools are updated to version 2.0 (including MongoDB, Redis, Solr,KeyValue, Gemfire, Apache Cassandra, REST, Neo4j, Couchbase, and Elasticsearch) and there’s a new Data tab in the Spring tool window which brings better repository navigation.

Less than one week later, JetBrains’ Trisha Gee explained in a blog post that support for testing using the Spring framework has been enhanced.

Spring Testing improvements — Overview

Gutter icons and navigation

Users will notice that where they use the standard test annotations, there are gutter icons to help them navigate around the code, the same as they would usually expect from Spring annotations.

Users can now see and navigate to the relevant application contexts, and navigate to the declarations of autowired beans.

Furthermore, IntelliJ IDEA recognizes classes annotated with Spring test annotations as a test that can be run.

IntelliJ IDEA also understands mocks, and how they work in Spring tests, Gee wrote. Gutter icons take users to the declaration of the mock.

Code completion

Users can easily work with WebAppConfiguration with the provided navigation and code completion.

IntelliJ 2017.1 also offers support for test property sources and meta annotations for properties. For example, users get code completion for @TestPropertySource and navigation to the properties file.

Code completion and navigation still work as expected even when users declare their own TestProperties annotation and alias the TestPropertySource attributes.

Completion and navigation are also provided is in the @Sql annotation.  IntelliJ IDEA offers suggestions and can even show users when they have configured something incorrectly.


Users can now catch problems that arise from using the wrong attributes on @DirtiesContext with the help of inspections. For example, if users set the methodMode at the class level, a warning will appear.

Same goes for setting hierarchy mode when it’s not applicable

and for using classMode at the method level

More new inspections show where the method signature doesn’t match the annotation’s expectations. For example, if there’s a return type on a method annotated with either @BeforeTransation or @AfterTransaction.

or if the @BeforeTransation or @AfterTransaction methods take arguments.

For more information about Spring Testing improvements, check the IntelliJ blog.


Update March 21, 2017

JetBrains’ Trisha Gee explained in a blog post that the support IntelliJ IDEA 2017.1 offers for Java 9’s new modularity(Project Jigsaw) consists of code completion in the file and quick fixes for adding modules to your project.

SEE ALSO: IntelliJ welcomes new addition to the family: Gogland, a new Go IDE

How it works

Step 1: We have an ordinary IntelliJ IDEA module which contains a simple “Hello World” type application.


IntelliJ IDEA lets you create a new for your module.

This will have the basic structure provided for you.

Everything works as it should; you notice the impact of using modularity only when you try to use Java classes that you’d normally be able to access, Trisha wrote.

IntelliJ IDEA will help you find the problem and offer suggestions to fix it.

Furthermore, it makes the correct changes to the file.

The IDE offers code completion and suggestions even when you choose to edit the file yourself.

Quick fixes are available for the standard Java modules, but that’s not all: they can also help you write modular code yourself.  According to the blog post, if you are trying to access code which belongs in another IntelliJ IDEA module, from inside a module which uses Java 9’s modularity (indicated by the presence of a file), IntelliJ IDEA will point out that you need to make some changes.

Trisha revealed that there is more code completion available to help you make the changes to the module that needs to be accessed. Once you have a file in the module you want to use, the required packages can be quickly exported.

Let’s have a look at the module which needs to use this newly exported code: use Alt and Enter if you want to receive suggestions as to how to fix the problems. First, the IntelliJ IDEA module one must have a dependency on the IntelliJ IDEA module two. Second, the file for module one can be updated to show that the module requires module two.

Users must keep in mind that there are two systems of modularly here:

  1. The IntelliJ IDEA modules that you are probably already familiar with
  2. The new Java 9 (Jigsaw) modules that are configured using  To use Java 9 modularity, each Java 9 module must correspond to an IntelliJ IDEA module.

Don’t forget to declare your IntelliJ IDEA module dependencies as well as your Java 9 module dependencies.

In the last example, module one was dependent upon module two:

However, it also needed to declare that it requires module two in

We may be four months away from Java 9 but it’s good to know that IntelliJ IDEA 2017.1 provides support for working with Java 9 modularity (Jigsaw).

Gabriela Motroc
Gabriela Motroc was editor of and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.

Inline Feedbacks
View all comments