14

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?

Mark Peters
  • 80,126
  • 17
  • 159
  • 190
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
  • 1
    An aside: you probably want to include `test` in your dependency declaration for Hamcrest and other testing libraries. – Mark Peters Oct 30 '12 at 23:53

1 Answers1

16

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.

Mark Peters
  • 80,126
  • 17
  • 159
  • 190