Why are tests marked with #[serial]
?
#766
-
Tests by default are marked with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Tests marked with For example, when running a test that interacts with a database (such as a controller that creates a user), the following steps might occur:
If these steps were run in parallel with other tests, it could lead to conflicts, such as data being overwritten or tests failing unpredictably due to race conditions. By marking the test with |
Beta Was this translation helpful? Give feedback.
Tests marked with
#[serial]
are primarily used to prevent interference between tests, especially when they involve shared resources like a database.For example, when running a test that interacts with a database (such as a controller that creates a user), the following steps might occur:
If these steps were run in parallel with other tests, it could lead to conflicts, such as data being overwritten or tests failing unpredictably due to race conditions. By marking the test with
#[serial]
, we ensure that it runs in isolation, preventing o…