Current section: Test Database 5 exercises

Isolating Test Databases for Efficient Testing

Loading solution


00:00 So it's cool that I can run one test at a time, but I want to be able to run all the tests at a time and not have it explode on me. And so to do this, we're going to have our DB set up right here. And it's going to actually have an individual database file per test process that's being run.

00:18 And so VTest actually makes that pretty easy for us to do. We're going to add a VTest pool ID as part of the file name. And with that, that's it. Now we have an individual kind of ID that we can apply to each one of these tests. And if you take a look at this output right here, let's run it again, then you'll see

00:38 those tests are popping in place and then getting deleted, or those test databases pop into place, get deleted when they're done. But they're completely isolated from each other, and so we don't have to worry about that. And so that is that. Now, I mean, the output is still like, looks really funny. The tests are taking a really long time because every single one of our test processes

00:58 has to create its own test database that's running all the migrations, all that stuff. But it is in isolation, and so that is an improvement. We're going to make this even better next. But you should feel pretty good about yourself because you are isolating your stuff and making it way easy to test your software. So good job.