/unit-testing

An example that demonstrates mocking using jMockit and Mockito + PowerMock for a standard Java Spring application with JPA persistence

Primary LanguageJava

Summary

CircleCI codecov Sonar

An example that demonstrates mocking using jMockit and Mockito + PowerMock for a standard Java Spring application with JPA persistence

Getting Started

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

Classes

Alt text

Test Coverage

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

Static Code Checks

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