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

Tests that are too complex


If you cannot see what the test is about at a glance, then it is too complex. The first thing you look at is the name of the test, which should tell you what the test is asserting, and the second is the implementation of the test, which should be a few lines of straightforward code.

The signs of a too complex test are as follows:

  • Large amount of setup code needed

  • Conditional logic, such as if, switch, or null-coalescing operators are used

  • Looping constructs, such as while, for, or foreach are used

  • The test needs helper functions or types to operate

  • It has more than one mock or stub

  • It requires mocking and stubbing more than one method or property

  • The test doesn't fit the screen without scrolling

When the test fails, the developer looking at the test might not be the same that wrote it from the start. This makes it imperative that the test itself is as straightforward as possible. Even more plausible, the developer looking at the test is not even very familiar with the system...