Mastering PyCharm Transcripts
Chapter: Unit testing
Lecture: Your turn: Testing

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Unit testing is important for reliable code
0:05 and PyCharm has support for most of the ways
0:08 that we do testing in Python, let's try pytest.
0:11 Over here we have a starter project,
0:15 in the beginning it doesn't really have any tests
0:18 but it does have at least some working code
0:22 that you can write some tests for,
0:24 so over here, we're going to do a couple of things
0:27 first we're going to configure the pytest test
0:30 which is not super obvious on how to do in PyCharm until you've seen it,
0:33 and then we want to use code coverage to see how well we're doing,
0:36 realize we need some more tests, write a few more tests,
0:39 realize now we have great code coverage.
0:42 So we'll start out by opening up your table
0:44 create a virtual environment in it, open it in PyCharm, standard stuff,
0:48 so we need to add a run configuration for the tests
0:51 and so you need to go edit the written configuration,
0:55 drop down, pull down, hit edit, go over here and add a new Python test
0:59 pytest option, it talks about the settings to use to get it to work,
1:03 when you run it you'll see, stuff is not so much working
1:06 and they're all failing,
1:09 now, that's okay that it's failing, for now,
1:11 let's just run it with code coverage and see how much code
1:15 we're even trying to run with our faulty test.
1:18 So we're going to come over here and run the test with coverage
1:20 you may have to click the little button
1:22 to install coverage.py into your virtual environment
1:25 and then what you're going to do is you're going to start implementing the tests
1:30 and you'll see in the test code,
1:32 there's some little notes on how to do that what you need to do,
1:35 once you get all the tests to pass
1:38 and core.py has on 100% code coverage, you are done,
1:41 you should see some awesome like this, all green at the end.