O'Reilly logo

Testing with F# by Mikael Lundin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required