assertTrue statement requires static import in intelliJ IDEA?

intellij-idea, java, junit

Solution

You either have to add the static import OR make clear what class that static call is associated with:

Assert.assertTrue("Message", conditionCustom());

I usually use the latter because I think it's clearer.

Java won't compile unless it can figure out which class to associate that static method with.

I'd guess that perhaps you use inheritance to associate that static method with your test.

Problem

I just shifted my project form Netbeans to intelliJ IDEA, its a junit based test project. In netbeans I was using statments ``` assertTrue("Message", conditionCustom()); ``` and it was working without any extra import. Now when using the same above command in intelliJ I have to import file ``` import static org.junit.Assert.assertTrue; ``` is there any way so I dont need to write the above line in my code file? otherwise I have to edit all my files to get working assertTrue statement.

Original source