Test-Driven Development for Embedded C
Table of Contents
1: Foreword by Jack Ganssle
2: Foreword by Robert C. Martin
3: Acknowledgments
4: Preface
Who Is This Book For?
How to Read This Book
The Code in This Book
Online Resources
5: Test-Driven Development
Why Do We Need TDD?
What Is Test-Driven Development?
Physics of TDD
The TDD Microcycle
TDD Benefits
Benefits for Embedded
Part 1 Getting Started
6: Test-Driving Tools and Conventions
What Is a Unit Test Harness?
Unity: A C-Only Test Harness
CppUTest: A C++ Unit Test Harness
Unit Tests Can Crash
The Four-Phase Test Pattern
Where Are We?
Put the Knowledge to Work
7: Starting a C Module
Elements of a Testable C Module
What Does an LED Driver Do?
Write a Test List
Writing the First Test
Test-Drive the Interface Before the Internals
Incremental Progress
Test-Driven Developer State Machine
Tests Are FIRST
Where Are We?
Put the Knowledge to Work
8: Testing Your Way to Done
Grow the Solution from Simple Beginnings
Keep the Code Clean —Refactor as You Go
Repeat Until Done
Take a Step Back Before Claiming Done
Where Are We?
Put the Knowledge to Work
9: Embedded TDD Strategy
The Target Hardware Bottleneck
Benefits of Dual-Targeting
Risks of Dual-Target Testing
The Embedded TDD Cycle
Dual-Target Incompatibilities
Testing with Hardware
Slow Down to Go Fast
Where Are We?
Put the Knowledge to Work
10: Yeah, but...
We Don ’t Have Time
Why Not Write Tests After the Code?
We ’ll Have to Maintain the Tests
Unit Tests Don ’t Find All the Bugs
We Have a Long Build Time
We Have Existing Code
We Have Constrained Memory
We Have to Interact with Hardware
Why a C++ Test Harness for Testing C?
Where Are We?
Put the Knowledge to Work
Part 2 Testing Modules with Collaborators
11: Introducing Test Doubles
Collaborators
Breaking Dependencies
When to Use a Test Double
Faking It in C, What ’s Next
Where Are We?
Put the Knowledge to Work
12: Spying on the Production Code
Light Scheduler Test List
Dependencies on Hardware and OS
Link-Time Substitution
Spying on the Code Under Test
Controlling the Clock
Make It Work for None, Then One
Make It Work for Many
Where Are We?
Put the Knowledge to Work
13: Runtime-Bound Test Doubles
Testing Randomness
Faking with a Function Pointer
Surgically Inserted Spy
Verifying Output with a Spy
Where Are We?
Put the Knowledge to Work
14: The Mock Object
Flash Driver
MockIO
Test-Driving the Driver
Simulating a Device Timeout
Is It Worth It?
Mocking with CppUMock
Generating Mocks
Where Are We?
Put the Knowledge to Work
Part 3 Design and Continuous Improvement
15: SOLID, Flexible, and Testable Designs
SOLID Design Principles
SOLID C Design Models
Evolving Requirements and a Problem Design
Improving the Design with Dynamic Interface
More Flexibility with Per-Type Dynamic Interface
How Much Design Is Enough?
Where Are We?
Put the Knowledge to Work
16: Refactoring
Two Values of Software
Three Critical Skills
Code Smells and How to Improve Them
Transforming the Code
But What About Performance and Size?
Where Are We?
Put the Knowledge to Work
17: Adding Tests to Legacy Code
Legacy Code Change Policy
Boy Scout Principle
Legacy Change Algorithm
Test Points
Two-Stage struct Initialization
Crash to Pass
Characterization Tests
Learning Tests for Third-Party Code
Test-Driven Bug Fixes
Add Strategic Tests
Where Are We?
Put the Knowledge to Work
18: Test Patterns and Antipatterns
Ramble-on Test Antipattern
Copy-Paste-Tweak-Repeat Antipattern
Sore Thumb Test Cases Antipattern
Duplication Between Test Groups Antipattern
Test Disrespect Antipattern
Behavior-Driven Development Test Pattern
Where Are We?
Put the Knowledge to Work
19: Closing Thoughts
Part 4 Appendixes
20: Development System Test Environment
Development System Tool Chain
Full Test Build makefile
Smaller Test Builds
21: Unity Quick Reference
Unity Test File
Unity Test main
Unity TEST Condition Checks
Command-Line Options
Unity in Your Target
22: CppUTest Quick Reference
The CppUTest Test File
Test Main
TEST Condition Checks
Test Execution Order
Scripts to Create Starter Files
CppUTest in Your Target
Convert CppUTest Tests to Unity
23: LedDriver After Getting Started
LedDriver First Few Tests in Unity
LedDriver First Few Tests in CppUTest
LedDriver Early Interface
LedDriver Skeletal Implementation
24: Example OS Isolation Layer
Test Cases to Assure Substitutable Behavior
POSIX Implementation
Micrium RTOS Implementation
Win32 Implementation
Burden the Layer, Not the Application
25: Bibliography
page_1
page_2
page_3
page_4
page_5
page_6
page_7
page_8
page_9
page_10
page_11
page_12
page_13
page_14
page_15
page_16
page_17
page_18
page_19
page_20
page_21
page_22
page_23
page_24
page_25
page_26
page_27
page_28
page_29
page_30
page_31
page_32
page_33
page_34
page_35
page_36
page_37
page_38
page_39
page_40
page_41
page_42
page_43
page_44
page_45
page_46
page_47
page_48
page_49
page_50
page_51
page_52
page_53
page_54
page_55
page_56
page_57
page_58
page_59
page_60
page_61
page_62
page_63
page_64
page_65
page_66
page_67
page_68
page_69
page_70
page_71
page_72
page_73
page_74
page_75
page_76
page_77
page_78
page_79
page_80
page_81
page_82
page_83
page_84
page_85
page_86
page_87
page_88
page_89
page_90
page_91
page_92
page_93
page_94
page_95
page_96
page_97
page_98
page_99
page_100
page_101
page_102
page_103
page_104
page_105
page_106
page_107
page_108
page_109
page_110
page_111
page_112
page_113
page_114
page_115
page_116
page_117
page_118
page_119
page_120
page_121
page_122
page_123
page_124
page_125
page_126
page_127
page_128
page_129
page_130
page_131
page_132
page_133
page_134
page_135
page_136
page_137
page_138
page_139
page_140
page_141
page_142
page_143
page_144
page_145
page_146
page_147
page_148
page_149
page_150
page_151
page_152
page_153
page_154
page_155
page_156
page_157
page_158
page_159
page_160
page_161
page_162
page_163
page_164
page_165
page_166
page_167
page_168
page_169
page_170
page_171
page_172
page_173
page_174
http://www.hexisoft.com/pdf-to-epub.html
midi to mp3
pdf-to-jpg.org
flash-map-shop.com