Testing is important as it is impossible to test all the cases manually. So here are some guidelines: The tests are mostly written in a behavioral sense:

  • Test method name should indicate what is tested
  • The GIVEN section sets up the test environment, defining the mocks, their responses (using BDDMockito)
  • In the WHEN section the actual method that is under test is called
  • In the THEN section the verification happens

My general aim is to have a test coverage of at least 80% of the lines and 50% of the branches.