An example that demonstrates mocking using jMockit and Mockito + PowerMock for a standard Java Spring application with JPA persistence
Requirements:
- Apache Maven 3.3
- Java 1.7
Clone and build the project
git clone https://github.com/omerio/unit-testing
cd unit-testing
mvn install
For test coverage we are using the Cobertura code coverage maven plugin. The plugin is configured with the ignoreTrivial flag to ignore trivial one line methods such as getters and setters.
To run the test coverage:
mvn cobertura:cobertura
The coverage report will be available inside the target/site/cobertura/index.html directory
To ensure the code follows the best practices and standards, we are using the Checkstyle maven plugin with the Google Checkstyle settings.
To run the checkstyle report:
mvn checkstyle:checkstyle
To run FindBugs plugin:
mvn findbugs:check
To run the PMD plugin:
mvn pmd:check