Unit Testing and Mocks

Guidelines

  • JUnit 4 tests with annotations
  • Mockito for Mocking as much as possible
  • PowerMock only where needed. If possible make changes to allow Mockito to work (remove statics, final classes, etc.)
  • Hamcrest Matchers for complex assertions Junit Assert.* for simple checks
  • Create Base Tests and setup methods to avoid boiler-plate code distracting from the meaningful work and assertions
  • Create more tests (methods) rather than add assertions to existing tests.