Wednesday, 27 July 2016

Code Coverage with Tests in IntelliJ

Right, your using IntelliJ and you wanted to find the coverage for your code before you checked your code into your version controlling system. It's easy, just follow the steps below to tell you your code coverage:
  • Based on whether you've created Unit Tests or Integration Tests, you might want to test the coverage of either. In this case, am assuming its the Integration Test Coverage that is required.

    When you right click on the file in the Project window, you would see the following options for that file. Select the Run with Coverage option

  •  Once the tests have completed successfully, you would now see the below for each file that has been covered as part of the test. You get a summary of how much coverage there is for each file.

  • If you would like a more detailed analysis, you can click into each file to see the exact coverage. What is highlighted in green below has been covered and what is red is not covered.

Happy testing!