Testing with F#
eBook - ePub

Testing with F#

Mikael Lundin

Buch teilen
  1. 286 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Testing with F#

Mikael Lundin

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Testing with F# als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Testing with F# von Mikael Lundin im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Ciencia de la computación & Control y garantía de calidad. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

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.

Inhaltsverzeichnis