Your import static line imports all the static members of the Assert class into the static namespace of your compilation unit. The fail() call refers to Assert.fail() .
The confusion you face regarding the definition of fail() , which is why I usually do not recommend using import static . In my own code, I usually import the class and use it to call static methods:
import org.junit.Assert; import org.junit.Test; public class Test { @Test public void hello() { Assert.fail(); } }
Much more readable.
However, as JB Nizet points out , it is a fairly common practice to use import static for JUnit statements; when you write and read enough JUnit tests, knowing where the approval methods come from will become second nature.
source share