Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I avoid running some tests in parallel?

I have a collection of tests. There are a few tests that need to access a shared resource (external library/API/hardware device). If any of these tests run in parallel, they fail.

I know I could run everything using --test-threads=1 but I find that inconvenient just for a couple of special tests.

Is there any way to keep running all tests in parallel and have an exception for a few? Ideally, I would like to say do not run X, Y, Z at the same time.

like image 982
Juan Leni Avatar asked Aug 05 '18 11:08

Juan Leni


1 Answers

Use the serial_test crate. With this crate added, you put in your code:

#[serial]

in front of any test you want run in sequentially.

like image 138
D G Avatar answered Sep 20 '22 13:09

D G