3.2.2 Hands-on: Running IntelliJ’s code coverage

Course subject(s) Module 3. Structural Testing and Code Coverage

We just learned structural testing and line coverage. Let’s re-do the steps of the video and see line coverage in person!

  1. Open the tudelft.blackjack.BlackJack class. It contains the implementation of our blackjack problem.
  2. Open the tudelft.blackjack.BlackJackLineCoverageTest that exists in our test folder. Although we do not usually put “LineCoverage” in the name of the test, we did it to make it easier for you to find it.
  3. Run the tests using the “Run” feature you are already familiar with.
  4. Both tests should pass. We already fixed the bug in this implementation.
  5. Now, run the tests using the “Run with Coverage” feature.
  6. First, inspect the Coverage window that just opened. You can double click on the package and see the data for the BlackJack class.
  7. See all the lines marked as green, indicating that we really achieved 100% line coverage.
  8. Now, play a bit with line coverage. Comment both tests and see what happens to the coverage. Uncomment each of them, one at a time, and see what happens again.
Creative Commons License
Automated Software Testing: Practical Skills for Java Developers by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://online-learning.tudelft.nl/courses/automated-software-testing-practical-skills-for-java-developers/.
Back to top