Book Image

Testing with F#

By : Mikael Lundin
Book Image

Testing with F#

By: Mikael Lundin

Overview of this book

Table of Contents (17 chapters)
Testing with F#
About the Author
About the Reviewers

Tests that break occasionally

One of the most common test smells are tests that break from time to time. Sometimes you have a test that breaks once and then never again. Other tests will always fail the first time and then succeed when they're rerun. It often happens that you write a test that will work perfectly now but fail sometime in the future.

When it comes to unit testing, this kind of test smell is quite rare. Since your unit tests should operate on memory only, there are few things that would make the test fail occasionally. One thing would be threading. A race condition is always the kind of test that would break when the CPU cycles don't perform in the expected order. This could cause the test to fail even though it is a unit test.

It is much more common that integration tests have occasional hiccups. There could be a dip in the network during database transaction, or the hard drive that you're writing logs to is full. These are things that we have a hard time to protect ourselves...