Testing with F#

Deliver high-quality, bug-free applications by testing them with efficient and expressive functional programming

Testing with F#

This ebook is included in a Mapt subscription
Mikael Lundin

Deliver high-quality, bug-free applications by testing them with efficient and expressive functional programming
$0.00
$26.99
$44.99
$29.99p/m after trial
RRP $26.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781784391232
Paperback286 pages

Book Description

Starting with an introduction to the concepts behind test automation, you will learn how to set up your test environment for unit testing and how to execute your test suite within and outside of Visual Studio. Using different test frameworks as MSTest, NUnit, and xUnit, you will learn how to write tests in isolation, create test doubles with Foq, and write expressive assertions with FsUnit.

You will learn techniques used to mock database contexts, test stored procedures, use migrations to test databases in isolation, control a web browser with Canopy, and test web services with F# interactive. You will learn how these techniques apply to Agile principles and discover how testing fits into your project.

Table of Contents

Chapter 1: The Practice of Test Automation
Testing as a practice
Building trust
The purpose of testing
Testing with intent
Writing tests for regression
Summary
Chapter 2: Writing Testable Code with Functional Programming
Purely functional
Immutability
Writing testable code
Expressiveness through functional programming
Summary
Chapter 3: Setting Up Your Test Environment
F# Interactive
Testing with Visual Studio
Comparing MSTest, NUnit, and xUnit
Tools and frameworks
Executing a test suite outside Visual Studio
FAKE
Continuous integration
Summary
Chapter 4: Unit Testing
Structuring your tests
Arrange, act, assert
FsUnit
Unquote
Testing in isolation
Finding the abstraction level
Test doubles
Dependency injection
Stubbing with Foq
Mocking
Dealing with databases
Summary
Chapter 5: Integration Testing
Good integration tests
Your first integration test
Setting up and tearing down databases
Speeding up integration testing
Testing stored procedures
Data-driven testing
Testing web services
Summary
Chapter 6: Functional Testing
Specifications
Setting up TickSpec
Web-browser-based testing
Regression testing
Summary
Chapter 7: The Controversy of Test Automation
Bugs or defects
The cost of quality
The false security of code coverage
Test-driven development
Testing or fact-checking
Summary
Chapter 8: Testing in an Agile Context
Building a bridge or tending to a garden
The broken iron triangle
Visualizing metrics
The Kanban board
Predictability
Testing in agile
Summary
Chapter 9: Test Smells
Tests that break upon refactoring
Tests that break occasionally
Tests that never break
Tests that are too complex
Tests that require excessive setup
Developers not writing tests
Summary
Chapter 10: The Ten Commandments of Test Automation
Testing behavior, not implementation
Using ubiquitous language in your test name
Asserting only one thing in your test
Don't mock the Mockingbird
Always refactor your SUT
Your test should never be more than 10 lines of code
Always test in isolation
Controlling your dependencies
Your test is a ninja
The test is not complex
Summary

What You Will Learn

  • Set up a test environment in your code base
  • Write unit tests, integration tests, and functional tests for F# applications
  • Leverage tools such as FsUnit, Foq, Canopy, and TickSpec to run tests both inside and outside your development environment
  • Maximize the productivity of your test code using the language features of F#
  • Extract dependencies to databases, web services, and other IO bound operations
  • Test your applications using executable specifications on a web browser
  • Discover the best practices for developing a sustainable test suite

Authors

Table of Contents

Chapter 1: The Practice of Test Automation
Testing as a practice
Building trust
The purpose of testing
Testing with intent
Writing tests for regression
Summary
Chapter 2: Writing Testable Code with Functional Programming
Purely functional
Immutability
Writing testable code
Expressiveness through functional programming
Summary
Chapter 3: Setting Up Your Test Environment
F# Interactive
Testing with Visual Studio
Comparing MSTest, NUnit, and xUnit
Tools and frameworks
Executing a test suite outside Visual Studio
FAKE
Continuous integration
Summary
Chapter 4: Unit Testing
Structuring your tests
Arrange, act, assert
FsUnit
Unquote
Testing in isolation
Finding the abstraction level
Test doubles
Dependency injection
Stubbing with Foq
Mocking
Dealing with databases
Summary
Chapter 5: Integration Testing
Good integration tests
Your first integration test
Setting up and tearing down databases
Speeding up integration testing
Testing stored procedures
Data-driven testing
Testing web services
Summary
Chapter 6: Functional Testing
Specifications
Setting up TickSpec
Web-browser-based testing
Regression testing
Summary
Chapter 7: The Controversy of Test Automation
Bugs or defects
The cost of quality
The false security of code coverage
Test-driven development
Testing or fact-checking
Summary
Chapter 8: Testing in an Agile Context
Building a bridge or tending to a garden
The broken iron triangle
Visualizing metrics
The Kanban board
Predictability
Testing in agile
Summary
Chapter 9: Test Smells
Tests that break upon refactoring
Tests that break occasionally
Tests that never break
Tests that are too complex
Tests that require excessive setup
Developers not writing tests
Summary
Chapter 10: The Ten Commandments of Test Automation
Testing behavior, not implementation
Using ubiquitous language in your test name
Asserting only one thing in your test
Don't mock the Mockingbird
Always refactor your SUT
Your test should never be more than 10 lines of code
Always test in isolation
Controlling your dependencies
Your test is a ninja
The test is not complex
Summary

Book Details

ISBN 139781784391232
Paperback286 pages
Read More

Read More Reviews