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#
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Always test in isolation


A good test is one that is completely confined within the function where it is defined. The state of the test suite and the state of the system are the same after the test has run, as it was before.

When tests are not isolated, you start to get maintenance and reliability problems. The most common refactoring that developers do on their test suite is to share setup between tests. It is common that tests share much of the setup code, but instead it should be considered a waste. Instead, we need to investigate how we can refactor the SUT in order to avoid excessive and repeatable tests setup. Once we've done this, we will end up with better tests and better-designed SUT.

Tests need not only to be isolated from each other by code, but also by state. One of the largest problems in test suites is that one test sets a particular state in the target system and this affects the results of subsequent tests. These bugs are hard to track down because the error is not in the test...