Effective 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 and PyCharm has support for most of the ways that we do testing in Python, let's try pytest.
0:12 Over here we have a starter project, in the beginning it doesn't really have any tests but it does have at least some working code
0:23 that you can write some tests for, so over here, we're going to do a couple of things first we're going to configure the pytest test
0:31 which is not super obvious on how to do in PyCharm until you've seen it, and then we want to use code coverage to see how well we're doing,
0:37 realize we need some more tests, write a few more tests, realize now we have great code coverage. So we'll start out by opening up your table
0:45 create a virtual environment in it, open it in PyCharm, standard stuff, so we need to add a run configuration for the tests
0:52 and so you need to go edit the written configuration, drop down, pull down, hit edit, go over here and add a new Python test
1:00 pytest option, it talks about the settings to use to get it to work, when you run it you'll see, stuff is not so much working and they're all failing,
1:10 now, that's okay that it's failing, for now, let's just run it with code coverage and see how much code we're even trying to run with our faulty test.
1:19 So we're going to come over here and run the test with coverage you may have to click the little button
1:23 to install coverage.py into your virtual environment and then what you're going to do is you're going to start implementing the tests
1:31 and you'll see in the test code, there's some little notes on how to do that what you need to do, once you get all the tests to pass
1:39 and core.py has on 100% code coverage, you are done, you should see some awesome like this, all green at the end.


Talk Python's Mastodon Michael Kennedy's Mastodon