Playing
22. Running tests in parallel

Transcript

00:00
Let's take a quick break to see how we can run our tests in parallel with PEST. Now within Laravel this feature has been available for a little while
00:08
and if we check this out you can see that we can use this parallel option when we run phps and test. Now we're running PEST so let's try this out and see what happens. So let's run PEST and parallel and you can see here parallel support requires the parallel plugin.
00:26
So we're going to go ahead and pull this in and see how it's going to speed up our tests. Now our tests are pretty quick at the moment but of course we can always benefit from getting faster feedback so as our test numbers grow and we do more this is going to really help us. So let's come down and install this and then we'll check out how it works.
00:45
Okay so that's pretty much pulled in and we can go ahead and follow the instructions here. So we can either use the parallel option or just P on its own which of course is shorter. So let's run PEST and P and there we go. So that's not much difference at the moment from what we would normally get
01:03
but as our tests grow you'll see a massive reduction in the speed at which this works. Now what we can also do is specify the processes here. So if you wanted to go ahead and run P with the processes option you can bump this up to as many processes as you need.
01:20
Once again in our case we don't really have that many tests so we're not seeing a massive reduction in time. But in future you can just go ahead and run PEST P just to make sure you're getting the fastest test run you can.

Episode summary

In this episode, we take a quick look at how to run our tests in parallel using Pest within Laravel. Parallel testing can really help speed things up, especially as our test suite grows.

We start by trying out Pest's --parallel option and see that we need to install the parallel plugin to make it work. After installing the plugin, we run our tests in parallel using both the --parallel flag and the short p command. Even though our current test suite is pretty small and we're not seeing dramatic speed improvements, it's worth noting that as your tests increase, you'll really start to notice the benefits.

We also check out how you can control the number of parallel processes Pest uses by specifying it in the command. This way, you can really maximize your system's resources for even faster test runs. For now, it's a quick win to set up, and will pay off more as your test suite gets bigger!

Episode discussion

No comments, yet. Be the first!