5.6. Sleeping snail
Working with file I/O is dreadfully slow compared to working with in-memory data. Again, slow tests are a major drag to maintainability because programmers need to run the test suite again and again as they work on changes, whether adding new functionality or fixing something that’s broken.
File I/O isn’t the only source of slow tests. Often a much bigger impact to a test suite’s execution time stems from the army of Thread#sleep calls put in place to allow other threads to finish their work before asserting on the expected outcomes and side effects. This sleeping snail is remarkably easy to spot: just look out for calls to Thread#sleep and keep an eye out for exceptionally slow tests. Unfortunately, getting rid of the stench ...
Get Effective Unit Testing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.