Unit Testing

Overview

Documents the approach to unit testing and how such tests are organized.

Coverage

There are four important layers to the architecture of the application for which we could consider unit testing

  • Domain model (JPA Objects)
  • Service layer (JPA Services)
  • REST layer (REST services)

Service and REST layers lend themselves better to integration testing as whether they function properly can only be determined in the context of an execution environment with data loaded that is known (or with an extensive mocking framework).    

Unit testing focuses on the ability to test classes without needing to access external resources such as servers, databases, or the file system.  The following areas were identified as good candidates

  • Model objects
  • List objects
  • Helpers
  • Validation Checks

Beyond this, the majority of the "business" logic of the application is written into either the REST service layers and so are not good candidates for unit testing approach.

Coverage Definition

Coverage is defined by the following spreadsheet

Organization

Unit tests are kept in the same modules with the classes they are intended to test in the standard src/test/java Maven structure. Test names are kept unique so they are easily identifiable.