Skip to content

IntelliJ IDEA cannot resolve static import

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

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;