IntelliJ IDEA cannot resolve static import

3.7k Views Asked by At

When I import regularly it works as expected:

enter image description here

However, if I change an import to static, IDEA cannot resolve it:

enter image description here

Gradle builds the project successfully.

It seems to be a problem with IDEA but I can't find if it is a known problem. I tried cleaning, invalidate caches etc. Anything else I can do?

Im using IntelliJ IDEA community 2016.2.4 and java version 1.7.0_79

2

There are 2 best solutions below

2
Ash On BEST ANSWER

You either want to do this, which will import all of the static members of Assert

import static org.junit.Assert.*;

Or, to get a specific method

import static org.junit.Assert.assertEquals;
0
Mureinik On

Your syntax is wrong - static imports are for static methods, not for classes. I'm guessing you meant to statically import all the methods belonging to org.junit.Assert:

import static org.junit.Assert.*;