Testing with Schedulers
Testing is perhaps one of the most compelling scenarios where we can use Schedulers. So far in this book we’ve been coding our hearts out without thinking much about the consequences. But in a real-world software project, we would be writing tests to make sure our code works as we intend.
Testing asynchronous code is hard. We usually run into one of these problems:
-
Simulating asynchronous events is complicated and error prone. The whole point of having tests is to avoid bugs and errors, but if your tests themselves have errors, they’re not helping.
-
If we want to accurately test time-based functionality, automated testing becomes really slow. For example, if we need to accurately test that an error is called after ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access