Transcript from the "Code Coverage" Lesson
>> Speaker 1: Moving right along to code coverage. So let's all go ahead and check out the next branch, and get rid of all of our own stuff and pull the new stuff.
>> Speaker 1: And we're gonna do code coverage. So I actually the three of you who were here yesterday and maybe some people online are going to hear the same thing again.
[00:00:59] So what code coverage is, basically consists of four metrics. Lines, branches, functions, and now I cannot even remember. Does anybody know what the last one is? My brain tonight just decided to give up, statements. All that Code Coverage tells you is that this line ran, or this if statement was evaluated to true, or it evaluated to false and so the alternate ran.
[00:01:37] Or this function was run. All of that pieces of information. It doesn't say like this function was run with this state, it doesn't say like that. This function was called with a boolean rather than an integer, whatever. It just tells you that at some point during the running of your test, that this line and this function and this branch was hit.
[00:01:59] So the way that it accomplishes this is through what's called instrumentation. What it does is something similar to this. It creates a global variable called coverage and that's an object. And then this coverage variable will add properties to it, like it will actually just to make it a little bit easier.
[00:02:22] It will add a bunch of properties to it that are hash or something. I am not a 100% sure what the keys even mean. But then they have a value of how many times a certain line or something was.
>> Speaker 1: Run. And then it will stick these all over the place.
[00:03:53] Well, I totally blew everything away, but let me just reset.
>> Speaker 1: By the end of it, you have this global variable that contains all of the information that's needed to tell what lines were run and what lines weren't. And then your instrumenter will create a report out of that to show you these are the lines that you're missing.