Wednesday, 1 February 2012

Tip: Content assist for static imports in Eclipse

You can add a list of "Favourites" in your Eclipse settings to help with content assist for standard static methods. For example, assertNotNull() and friends when writing unit tests.

To enable this, in your Eclipse Preferences window, navigate to Java / Editor / Content Assist / Favorites. I've got the following types in mine:

  • org.hamcrest.Matchers
  • org.junit.Assert
  • org.springframework.test.web.server.request.MockMvcRequestBuilders
  • org.springframework.test.web.server.result.MockMvcResultHandlers
  • org.springframework.test.web.server.result.MockMvcResultMatchers
  • org.springframework.test.web.server.setup.MockMvcBuilders
Add them one at a time with the New Type… button.

No comments:

Post a Comment