Dmytro Chyzhykov's Blog

Yet another programmer.

Useful Eclipse Class Imports

A short note on how Eclipse can improve your efficiency with class imports.

Problem

When we work with JUnit, Mockito we all the time use their key classes static methods like org.junit.Assert.assertThat, org.mockito.Mockito.mock and so on. Be honest it’s hard to deal with static imports in Eclipse. Eclipse static member import before

Solution

But thanks to Eclipse Foundation Team we can tune the IDE easily with little effort by adding a set of useful types with static members or particular static members themselves to Preferences | Java | Editor | Content Assist | Favorites. For instance, that would be:

1
2
3
4
org.hamcrest.CoreMatchers
org.junit.Assert
org.junit.matchers.JUnitMatchers
org.mockito.Mockito

Preferences | Java | Editor | Content Assist | Favorites

Also make sure that Use static imports is enabled on the Preferences | Java | Editor | Content Assist tab. Preferences | Java | Editor | Content Assist

Result

Eclipse static member import after