Testing with F#
eBook - ePub

Testing with F#

Mikael Lundin

Share book
  1. 286 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Testing with F#

Mikael Lundin

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Testing with F# an online PDF/ePUB?
Yes, you can access Testing with F# by Mikael Lundin in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Control y garantía de calidad. We have over one million books available in our catalogue for you to explore.

Information

Testing with F#


Table of Contents

Testing with F#
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Practice of Test Automation
Testing as a practice
Black or white box testing
Manual testing
Test automation
Style check
Static analysis
Unit testing
Integration testing
System testing
Building trust
The purpose of testing
When not to test
Testing with intent
Asserting written code
Contracts versus tests
Designing code to be written
Writing tests for regression
Executable specifications
Summary
2. Writing Testable Code with Functional Programming
Purely functional
Immutability
Immutable data structures
Built-in immutable types
Tuple
List
Sequence
Creating an immutable type
Writing testable code
Active patterns
Higher order functions
Partial application
Continuations
Expressiveness through functional programming
Imperative programming
Declarative programming
Tail call optimization
Parallel execution
Summary
3. Setting Up Your Test Environment
F# Interactive
Loading external references
Testing with Visual Studio
NUnit
xUnit
Comparing MSTest, NUnit, and xUnit
Tools and frameworks
FsUnit
ReSharper test runner
xUnit.net
Executing a test suite outside Visual Studio
MSTest
NUnit
xUnit
FAKE
Continuous integration
Git Hooks
TeamCity
Summary
4. Unit Testing
Structuring your tests
Arrange, act, assert
Separate project versus inline tests
FsUnit
Assertions
Custom assertions
Unquote
Assertions
Testing in isolation
Vertical slice testing
Finding the abstraction level
Public interface
Private functions
Test doubles
Dependency injection
Functional injection
Currying
Higher order functions
Stubbing with Foq
Mocking
Dealing with databases
Summary
5. Integration Testing
Good integration tests
Layer-for-layer testing
Top down testing
External interface testing
Your first integration test
Setting up and tearing down databases
Brownfield database setup
Really large databases
Speeding up integration testing
Testing in parallel
Testing stored procedures
Data-driven testing
Testing web services
Web service type provider
Summary
6. Functional Testing
Specifications
Setting up TickSpec
Executable specifications
Combinatorial examples
Web-browser-based testing
Selenium
PhantomJS
Canopy
CSQuery
Regression testing
Summary
7. The Controversy of Test Automation
Bugs or defects
Bugs
How to avoid them
Defects
How to avoid them
The difference between bugs and defects
The cost of quality
Quality index
The software craftsman
Not all code is created equal
Being a pragmatic programmer
Good enough
Technical debt
The false security of code coverage
Measuring the delta of code coverage
Test-driven development
Red, green, refactor
Aversions to test-driven development
Test first development
Fixing bugs
API design
Testing or fact-checking
Replacing the tester with automation
Summary
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
What it means to be done
Mitigating risks
Known unknowns
Unknown unknowns
Automation
Testing in agile
Summary
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
Testing is a waste
Management won't let us
We don't know where to start
Our code is hard to test
It's a thing about culture
Summary
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
Index

Testing with F#

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2015
Production reference: 1170215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-123-2
www.packtpub.com

Credits

Author
Mikael Lundin
Reviewers
Neil Danson
Max Malook
Karlkim Suwanmongkol
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Reshma Raman
Content Development Editor
Shweta Pant
Technical Editor
Tanmayee Patil
Copy Editors
Gladson Monteiro
Merilyn Pereira
Nithya P
Project Coordinator
Sageer Parkar
Proofreaders
Simran Bhogal
Lauren E. Harkins
Indexer
Tejal Soni
Graphics
Sheetal Aute
Abhinash Sahu
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade

About the Author

Mikael Lundin is a software developer living in Malmö, Sweden. He started programming in Pascal 20 years ago and has been enjoying the craft both professionally and as a hobby through languages and frameworks such as PHP, C#, F#, Ruby, and Node. He has been a practitioner and mentor of test-driven development and agile methodologies for the last 8 years, helping teams succeed in delivering high-quality software.
Mikael has been working with F# for 4 years, providing solutions to clients, publicly speaking about functional programming, and holding seminars for colleagues to spread the word. He strongly believes that functional programming is the future of delivering high-quality software.
Mikael is employed as a technical consultant by Valtech in Sweden, where he takes on the roles of a software developer, solution architect, and agile mentor. He has delivered quality software to high-profile international clients and helped organizations adopt Scrum as their software development practice.

About the Reviewers

Neil Danson is an active professional developer and passionate F# advocate since 2010. He has over 10 years of experience in using the .NET framework, working on varied projects that range from military software and huge-scale international news websites to high-performance trading platforms. When Neil is not working, he can usually be found writing games, compilers, raytracers, and anything else that pops into his head. He can be found occasionally blogging at https://neildanson.wordpress.com.

Table of contents