Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA, Hamcrest and static imports

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?

like image 689
James Raitsev Avatar asked Oct 30 '12 23:10

James Raitsev


1 Answers

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.

like image 113
Mark Peters Avatar answered Oct 18 '22 13:10

Mark Peters