00:0.24 These air conditioned tests were great but let's just comment them out just for a moment
00:3.79 so we can see a little bit more in action.
00:6.94 If we've got a simple little program like this one file,
00:10.69 100 lines of code. We want to know how much of our tests actually interacts
00:15.0 with how much of that program.
00:17.14 We can probably reason about it,
00:18.79 even though it's not 100% obvious,
00:20.64 we can probably figure out that yeah,
00:22.35 this these tests are exercising the code well enough.
00:25.94 If you've got code that is not being run at all by the tests then the
00:30.26 tests say absolutely nothing about the quality of that code other than maybe it can be
00:34.66 parsed by python. So maybe the syntax is mostly okay,
00:38.94 so how do we know, you're in a real project
00:40.9 We might have hundreds of tests and thousands of lines of python.
00:43.8 How do we know what part of code being tested by the test we've written so
00:47.76 far, that's code coverage. So we can go up here and we can press
00:52.2 another one of these buttons we've seen profiling debugging regular running,
00:55.44 but now we have run with coverage the first time you run this,
00:59.6 it might say coverage is not installed.
01:1.63 Just click enable bundled coverage and you should be good to go,
01:5.44 we click this and it takes a little bit longer because it's thinking a whole lot
01:8.83 about what's happening and then whoa,
01:10.32 there's a lot of information on the screen here and check this out.
01:12.41 So we've got a like a graphical thing going on over here,
01:15.59 like an Excel type report, Scroll down into the demos projects,
01:20.86 a bunch of this is not covered because it's not really part of this project.
01:24.26 Let's go to the one that is the tests.
01:26.11 Well, guess what? The test ray?
01:27.32 And when we ran the test,
01:28.38 that doesn't mean anything. Let's check this out.
01:30.39 So over here, in core we have 75% of the lines and program,
01:35.49 we're not exercising that. So that's useful information already.
01:39.28 If we put that to the side,
01:40.67 look at this, this is way better over here.
01:43.74 It gives you right within the project,
01:45.5 a nice report showing you for each level that you go into it.
01:50.34 Right? So here's our core definitely tested and now even better remember how we had
01:56.09 GIT hub showing us on the side here,
01:59.04 look at this. So for example,
02:1.15 here this green code. This means it was hit by code coverage and this red
02:5.54 part here means that it wasn't.
02:7.86 So that is fantastic. I'm not sure if this comes through what color comes through
02:12.83 in the video when it's exported,
02:14.27 but light green, faint green and faint red here.
02:18.74 If we want to improve the code coverage of this actual file here of our core
02:23.64 Well, we need to make a couple of things happen.
02:27.84 We need to make this case run,
02:30.0 we've run the test but we've never run this and we've run this test but we've
02:33.66 never run this. Let's go in,
02:36.94 quote, right. Another testament to re enable this one.
02:41.14 This will be about a non existent table.
02:42.82 So when I run it, notice this red part should go away right again.
02:48.54 Running again with coverage and here we go.
02:51.86 Look that first part about the non existent table.
02:54.46 Now, that's running fantastic. Let's go and finish it off by running that little
02:59.48 bit there. That's going to be this last test.
03:3.34 You can run with coverage. Perfect it,
03:8.82 pass and check it out. All of that is good.
03:12.84 There is something else going on here that still thinks it's not running.
03:16.71 But when I look at this file,
03:18.21 it looks like this is 100% code coverage, as far as I'm concerned.
