Spring Testing Improvements in IntelliJ IDEA 2017.1
Gutter Icons and Navigation
You’ll see that where you use the standard test annotations, you have gutter icons to help you to navigate around the code, the same as you’d usually expect from Spring annotations. For example, you can see and navigate to the relevant application contexts, and navigate to the declarations of autowired beans.
And of course IntelliJ IDEA recognises classes annotated with Spring test annotations as a test that can be run.
These screenshots show the functionality working for @RestClientTest, but it applies equally to @JsonTest, @DataJpaTest, @WebMvcTest, @WebIntegrationTest, and so on, including your own custom tests.
IntelliJ IDEA also understand mocks, and how they work in Spring tests. Gutter icons take you to the declaration of the mock.
You can easily work with WebAppConfiguration with the provided navigation and code completion.
There’s also support for test property sources, and meta annotations for properties. For example, you get code completion for
@TestPropertySource and navigation to the properties file.
Even if you declare your own TestProperties annotation and alias the TestPropertySource attributes, code completion and navigation still works as expected.
Another place where completion and navigation are provided is in the
@Sql annotation. Here, IntelliJ IDEA offers suggestions, and can even show you when you’ve configured something incorrectly.
Inspections have been added to help catch problems that arise from using the wrong attributes on
@DirtiesContext. For example, if you set the methodMode at the class level, you’ll see a warning.
Similarly for setting hierarchy mode when it’s not applicable
And also 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 you have a return type on a method annotated with either
Or if your
@AfterTransaction methods take arguments.
In summary, IntelliJ IDEA 2017.1 makes testing Spring applications even easier, with inspections, code completion, and easy navigation.
Develop with Pleasure!
Subscribe to Blog updates
Top 10 UI Updates in IntelliJ IDEA for 2023
Hey there, fellow developers! Today, we want to share the most significant UI updates from 2023 that have transformed how IntelliJ IDEA looks and functions. New UI Of course, the highlight of our recent updates was the launch of our new, clean, and modern UI. This was first announced at the en…
The What, Why, and How of JPA Buddy in IntelliJ IDEA
Master JPA entity management with JPA Buddy in IntelliJ IDEA! Our latest article shows you how to simplify your workflow and reduce boilerplate code.
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…
Import Postman Collections to the HTTP Client
We know that many of you use Postman collections and want to stay in the flow while working with them. This means staying inside IntelliJ IDEA and not switching to a different app. Great news! You can now effortlessly transform Postman collections into .http and use them in the HTTP Client …