#100DaysOfWeb in Python Transcripts
Chapter: Days 81-84: Unit testing web apps
Lecture: Running all the tests at once

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now we have these two files that have tests. Here's our view tests. Here is our view model tests
0:08 and that's just for the ones that are in the default view. Of course in a real app we'd have like a store section and an account section etc, etc.
0:15 So we'll have a whole bunch of these different tests these test files, these test cases. Now, we would like to just run them all really easily.
0:23 There's a couple things we can do but nice integration with PyCharm is we can just get it to run all the tests. So if you notice if I click on this
0:30 it'll say run unit test in that file. So what we can do is we can come over here one option is just define all tests
0:37 give us a little more control. Here we can just say from billtracker.test.defaulttest.thisone import * and do the same thing for the view test.
0:48 Of course tell PyCharm that this is not a problem. So now if I save this and we right click on it it'll say run, but not run unit tests in. Why not?
0:59 Well this little right click menu actually looks and says are there tests in here? And it thinks actually no. So let's do this.
1:05 So if we just create like an empty test here so we say class, all tests and it's unittests.testcase
1:12 we say pass, save it. Now if we right click, guess what? Run all unit tests. There we go, look all of our tests are test details
1:21 here are running. Oh, you know I think we made a mistake actually let's go to this view model test here in the view. So this should be view test, ah!
1:30 Good thing I caught that. Run it again now you can see we're running all the different tests. There's all of our tests, all of them working.
1:37 Now all we got to do when we add more tests is just make sure we import them there actually we want that right there, a little bit higher.
1:45 Everything still works, good. So whenever we add something to our test folder we just import it there, everything's good.


Talk Python's Mastodon Michael Kennedy's Mastodon