Question

My maven project includes

186         <dependency>
187             <groupId>org.hamcrest</groupId>
188             <artifactId>hamcrest-all</artifactId>
189             <version>1.3</version>
190         </dependency>

When i type assertThat ..

I'd like for IDEA to figure out that the following is needed

import static org.hamcrest.MatcherAssert.assertThat;

Instead i get this.

enter image description here

How can this corrected? How can i get IDEA to perform a static import?

Was it helpful?

Solution

Open the parentheses and you will get a prompt for statically importing the method. IntelliJ won't understand it's a method you're trying to reference until you add the parenthesis.

In other words, type assertThat( and then ALT-ENTER.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top