The Art of Unit Testing with Examples in C#
Paperback Engels 2013 2e druk 9781617290893Samenvatting
You know you should be unit testing, so why aren't you doing it? If you're new to unit testing, if you find unit testing tedious, or if you're just not getting enough payoff for the effort you put into it, keep reading.
'The Art of Unit Testing, Second Edition' guides you step by step from writing your first simple unit tests to building complete test sets that are maintainable, readable, and trustworthy. You'll move quickly to more complicated subjects like mocks and stubs, while learning to use isolation (mocking) frameworks like Moq, FakeItEasy, and Typemock Isolator. You'll explore test patterns and organization, refactor code applications, and learn how to test "untestable" code. Along the way, you'll learn about integration testing and techniques for testing with databases.
What's Inside
- Create readable, maintainable, trustworthy tests
- Fakes, stubs, mock objects, and isolation (mocking) frameworks
- Simple dependency injection techniques
- Refactoring legacy code
The examples in the book use C#, but will benefit anyone using a statically typed language such as Java or C++.
Specificaties
Lezersrecensies
Inhoudsopgave
Foreword to the first edition
Preface
Acknowledgments
About this book
About the cover illustration
Part 1: Getting started
1. The basics of unit testing
-Defining unit testing, step by step
-Properties of a good unit test
-Integration tests
-What makes unit tests good
-A simple unit test example
-Test-driven development
-The three core skills of successful TDD
-Summary
2. A first unit test
-Frameworks for unit testing
-Introducing the LogAn project
-First steps with NUnit
-Writing your first test
-Refactoring to parameterized tests
-More NUnit attributes
-Testing results that are system state changes instead of return values
-Summary
Part 2: Core techniques
3. Using stubs to break dependencies
-Introducing stubs
-Identifying a filesystem dependency in LogAn
-Determining how to easily test LogAnalyzer
-Refactoring your design to be more testable
-Variations on refactoring techniques
-Overcoming the encapsulation problem
-Summary
4. Interaction testing using mock objects
-Value-based vs. state-based vs. interaction testing
-The difference between mocks and stubs
-A simple handwritten mock example
-Using a mock and a stub together
-One mock per test
-Fake chains: stubs that produce mocks or other stubs
-The problems with handwritten mocks and stubs
-Summary
5. Isolation (mocking) frameworks
-Why use isolation frameworks?
-Dynamically creating a fake object
-Simulating fake values
-Testing for event-related activities
-Current isolation frameworks for .NET
-Advantages and traps of isolation frameworks
-Summary
6. Digging deeper into isolation frameworks
-Constrained and unconstrained frameworks
-Values of good isolation frameworks
-Features supporting future-proofing and usability
-Isolation framework design antipatterns
-Summary
Part 3: The test code
7. Test hierarchies and organization
-Automated builds running automated tests
-Mapping out tests based on speed and type
-Ensuring tests are part of source control
-Mapping test classes to code under test
-Cross-cutting concerns injection
-Building a test API for your application
-Summary
8. The pillars of good unit tests
-Writing trustworthy tests
-Writing maintainable tests
-Writing readable tests
-Summary
Part 4: Design and process
9. Integrating unit testing into the organization
-Steps to becoming an agent of change
-Ways to succeed
-Ways to fail
-Influence factors
-Tough questions and answers
-Summary
10. Working with legacy code
-Where do you start adding tests?
-Choosing a selection strategy
-Writing integration tests before refactoring
-Important tools for legacy code unit testing
-Summary
11. Design and testability
-Why should I care about testability in my design?
-Design goals for testability
-Pros and cons of designing for testability
-Alternatives to designing for testability
-Example of a hard-to-test design
-Summary
-Additional resources
Appendix: Tools and frameworks
Index
Rubrieken
- advisering
- algemeen management
- coaching en trainen
- communicatie en media
- economie
- financieel management
- inkoop en logistiek
- internet en social media
- it-management / ict
- juridisch
- leiderschap
- marketing
- mens en maatschappij
- non-profit
- ondernemen
- organisatiekunde
- personal finance
- personeelsmanagement
- persoonlijke effectiviteit
- projectmanagement
- psychologie
- reclame en verkoop
- strategisch management
- verandermanagement
- werk en loopbaan