Bummer! This is just a preview. You need to be signed in with a Pro account to view the entire video.
Start a free Basic trial
to watch this video
In this video we'll look what code coverage is, why you should use it and what it _doesn't_ do.
Resources
-
0:00
[MUSIC]
-
0:04
Hello world.
-
0:05
Andrew here, JavaScript developer, lifelong learner and
-
0:08
teacher here at Treehouse.
-
0:10
In this workshop, we're going to be talking about code coverage.
-
0:14
Code coverage is the healthy development practice that describes how
-
0:18
much of a program source code is executed during the execution of the test sweep.
-
0:23
So, why should you do code coverage?
-
0:26
Well, it helps to see how much testing you're doing in your project.
-
0:29
It helps you spot parts in your code that the tests are missing.
-
0:33
It's also good to show business stakeholders in a project,
-
0:36
whether they are a project manager or clients on a project.
-
0:40
If you're publishing NPM modules,
-
0:43
showing your code coverage gives developers confidence in your module.
-
0:47
For example, you'd expect a module with 100% code coverage
-
0:51
should work better than a module with only 10%.
-
0:54
While software with more code coverage may instill more confidence than software
-
0:58
without code coverage,
-
1:00
it doesn't guarantee the quality of the tests that test the source code.
-
1:04
For example, there may be sets in edge cases missing.
-
1:08
Because test edge cases could be missing,
-
1:10
there could be some bugs that could still happen.
-
1:14
In other words, having 100% code coverage doesn't ensure good software.
-
1:20
The till we'll be using for code coverage is called Istanbul.
-
1:24
Istanbul is a node module that's compatible with testing libraries
-
1:27
like Mocha and Jasmine.
-
1:29
Istanbul can generate code coverage reports that are compatible with
-
1:32
online services like Coveralls and Codecov.
-
1:37
You can share your open source projects code coverage publicly, or
-
1:40
your internal or client projects privately.
-
1:44
In this workshop, we're going to set up code coverage in a simple calculator app.
-
1:48
Feel free to clone the app now or download the zip file attached to this video.
You need to sign up for Treehouse in order to download course files.
Sign up