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

Chapter 4. Unit Testing

Unit testing is the art of designing your program in such a way that you can easily test each function as isolated units and such verify its correctness. Unit testing is not only a tool for verification of functionality, but also mostly a tool for designing that functionality in a testable way. What you gain is the means of finding problems early, facilitating change, documentation, and design.

In this chapter, we will dive into how to write good unit tests using F#:

  • Structuring your tests

  • Testing in isolation

  • Finding the abstraction level

  • Test doubles

  • Dependency injection

  • Dealing with databases

After reading this chapter, you will be able to write high-quality unit tests that will require little maintenance and stand the test of refactoring, interface changes, and maintenance.