Parallelise Your NUnit Tests to Be More Productive and Waste Less Time
webdeveloperdiary.substack.com
Running tests in parallel can reduce time otherwise spent waiting for them to complete. This is easy in NUnit, but you must ensure your tests are compatible to prevent unexpected behaviour. Tests should be fully self-contained. While it’s tempting to use setup attributes to reduce code duplication, a new test starting can interfere with tests that are already running if shared variables are unexpectedly altered. It’s also important to remember not all data collections are fully thread-safe and performing write operations from different threads can cause exceptions to be thrown. Finally, if the test runner has capacity to start a new test, it will do so independently of the status of other tests. If a test relies on others completing in a predefined order, it may need rewriting.
Parallelise Your NUnit Tests to Be More Productive and Waste Less Time
Parallelise Your NUnit Tests to Be More…
Parallelise Your NUnit Tests to Be More Productive and Waste Less Time
Running tests in parallel can reduce time otherwise spent waiting for them to complete. This is easy in NUnit, but you must ensure your tests are compatible to prevent unexpected behaviour. Tests should be fully self-contained. While it’s tempting to use setup attributes to reduce code duplication, a new test starting can interfere with tests that are already running if shared variables are unexpectedly altered. It’s also important to remember not all data collections are fully thread-safe and performing write operations from different threads can cause exceptions to be thrown. Finally, if the test runner has capacity to start a new test, it will do so independently of the status of other tests. If a test relies on others completing in a predefined order, it may need rewriting.