Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This depends of the language and packager (like maven/gradle, ..) used in the project to execute the tests and build the artifacts.

Sonar recognizes 2 types of testing that can be executed in a build for the coverage report.

  1. Unit tests
    This It tests the classes or methods directly, generally by using specific test framework (Junit, testNG, etc ...)
    The "container framework" used behind the scene (Spring/ JBoss/ EJB or whatever) SHOULD NOT be used in the Unit test scope.
    External calls to test servers for or third party components or /anything MUST NOT be done here. These type of tests should be executable on a
    This can require the usage of mock frameworks because databases or third party systems MUST NOT beby anybody locally in an IDE.
    Due to that, it's sometimes required to make use of mock frameworks to replace the code that can't be triggered because it does require unreachable components
    The mocking SHOULD NEVER consume the developer's bandwidth, that means mocking the code should be straight-forward.
    Don't waste your time into a complicated implementation, for that there is a second test phase called "integration tests"

    Also DO NOT add "isTest" flag in your code to replace the mock, this is a common test anti pattern that lead the useless tests.

  2. Integration tests
    It Integration tests

Here are some tips to setup that coverage per packager and per language

...