Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we are going to learn about code coverage. Can anyone tell me what that means?
Is it how much of the code we actually test when we run our unit tests?
Exactly! Code coverage measures the percentage of code that is executed when your tests run. Why do you think that's important?
It probably helps us find parts of the code that we haven't tested yet, right?
Absolutely! It helps identify untested areas, which can contain potentially risky bugs. This is crucial in delivering reliable software.
Now, let's talk about some tools. What tools do you think can measure code coverage?
I think I've heard of JaCoCo!
And Cobertura, right?
Exactly! JaCoCo and Cobertura are popular code coverage tools. They provide detailed insights into which parts of your code are not covered by tests.
Are there others?
Yes, SonarQube is another valuable option that not only analyzes code coverage but also provides a broader overview of code quality.
What do you think a good target for code coverage would be?
Maybe around 80%?
That's a great target! Generally, aiming for about 70-80% coverage is sensible because targeting 100% can lead to diminishing returns, especially on certain code types.
Like error logging?
Exactly! Not all code needs to be tested to that extent, as long as critical paths are well covered.
Term
What is code coverage?
Click to flip
Term
Name a code coverage tool.
Click to flip
A metric that indicates the percentage of code executed while running tests.
An open-source tool for measuring code coverage in Java applications.
A tool that can measure code coverage for Java applications and provides reports on test coverage.
An open-source platform for continuous inspection of code quality, which includes assessing code coverage.
Code coverage quantifies the proportion of software code executed by tests, which is essential for ensuring software reliability.
Code coverage measures how much of the application code is executed when tests are run. It helps identify untested parts of the codebase, informs about potential areas of risk, and assists in improving overall software quality.
Code coverage is a crucial metric in software testing that quantifies the percentage of code that is executed during test execution. It serves as an important indicator of the quality and reliability of software because it helps developers identify parts of the code that are not adequately tested.
There are various tools available to measure code coverage, such as JaCoCo, Cobertura, and SonarQube, each offering different features and insights. The primary objective of obtaining code coverage is to aim for high percentages, however, it is important to note that striving for 100% coverage might not be practical; certain types of code, like error logging, may not require exhaustive testing. The main goal is to ensure that critical paths and functionalities are well-covered by tests, which helps to reduce bugs and improve overall software quality.