Eclipse Favorites to Make Your Java TDD Life Easier

Having a set of commonly-used functions globally available and ready for Ctrl+Space autocomplete goodness can be a nice productivity boost. Eclipse has a feature called “Favorites” which helps with that (under PreferencesFavorites).

These are a few static imports that I use all the time as part of my normal JUnit/Hamcrest/Mockito TDD workflow:

// generally useful, especially for setting up test data
import static java.util.Arrays.asList;

// Hamcrest matchers---use `hamcrest-library` as a dependency
import static org.hamcrest.Matchers.*;

// built-in JUnit assertions like assertThat()
import static org.junit.Assert.*;

//useful with Mockito's ArgumentCaptor
import static org.mockito.Matchers.*;

 // Mockito functions like mock() and when()
import static org.mockito.Mockito.*;
Eclipse TDD favorites