Jan 18 2008
Test Driven .NET Development With FitNesse: Table of Contents

This book takes you on a journey through the wonderful world of FitNesse, a great web-based collaboration tool for software acceptance testing. FitNesse enables software developers and business people to build a shared understanding of the domain and helps produce software that is genuinely fit for purpose.
More information
Sample chapter
Buy the book
Buy the PDF
Source code
Register your book
Acknowledgements ………………………………………………………………. ix
About the author ………………………………………………………………… xi
I. Getting started ………………………………………………………………….. 1
1. Introduction …………………………………………………………….. 3
Who should read this book? ……………………………………. 3
Why bother with TDD? …………………………………………… 4
Beyond unit tests …………………………………………………… 6
Getting FIT …………………………………………………………… 7
FitNesse or NUnit? …………………………………………………. 9
The next step ………………………………………………………. 11
2. Installing FitNesse ……………………………………………………. 13
Setting up FitNesse ……………………………………………….. 13
A quick test …………………………………………………………. 15
How FitNesse connects to .NET classes ……………………… 20
Don’t forget the test …………………………………………….. 21
Playtime ……………………………………………………………… 23
II. FitNesse and TDD in practice ……………………………………………. 25
3. Our Project …………………………………………………………….. 27
Lottery rules ………………………………………………………… 27
Selected user stories ……………………………………………… 27
Applying TDD to our project ………………………………….. 28
The next step ………………………………………………………. 35
4. Writing basic tests ……………………………………………………. 37
ColumnFixture — the Swiss Army knife of FitNesse ……… 38
Testing in plain English …………………………………………. 42
Playtime ……………………………………………………………… 46
5. Writing simple test scripts …………………………………………. 47
Passing values between tables …………………………………. 48
Writing a simple test script …………………………………….. 50
Use data-transfer objects directly …………………………….. 52
Using symbols to check dynamic values ……………………. 55
Checking for errors ………………………………………………. 55
Playtime ……………………………………………………………… 57
6. Writing efficient test scripts ……………………………………….. 59
Better test scripts with DoFixture …………………………….. 61
Use DoFixture keywords for better control ………………… 66
Keep ActionFixture in mind ……………………………………. 67
Playtime ……………………………………………………………… 68
7. Removing duplication ………………………………………………. 71
Group related tests into test suites …………………………… 71
Include pages and use them as components ………………. 74
Reuse entire suites with symbolic links …………………….. 75
Use markup variables to parameterise test pages …………. 75
Defining common actions ……………………………………… 77
Remove irrelevant information ……………………………….. 77
Acceptance tests should focus on business rules …………. 78
Hide parts of the page …………………………………………… 79
Playtime ……………………………………………………………… 79
8. Coordinating fixtures ……………………………………………….. 81
Embed fixtures for best results ……………………………….. 82
Use SetUpFixture to prepare the stage for tests …………… 83
Create test suites in flow mode ……………………………….. 88
Wrapping business objects with DoFixture ………………… 90
Playtime ……………………………………………………………… 91
9. Working with collections …………………………………………… 93
Testing lists of objects …………………………………………… 94
Checking for empty collections ………………………………. 97
Beware of test extensions ………………………………………. 99
Use RowFixture for better precision ……………………….. 101
Playtime ……………………………………………………………. 104
III. Advanced FitNesse usage ……………………………………………….. 105
10. Working in a team ……………………………………………….. 107
Options for team setup ……………………………………….. 107
Organising the files …………………………………………….. 110
Integrating with automated build tools …………………… 114
11. Testing web interfaces ……………………………………………. 121
Choosing the right thing to test …………………………….. 121
Introducing Selenium ………………………………………….. 123
Connecting from FitNesse ……………………………………. 127
Running tests on a remote server …………………………… 133
More Selenium tests ……………………………………………. 134
12. Testing database code ……………………………………………. 135
Connecting to the database ………………………………….. 135
Working with stored procedures ……………………………. 138
Preparing test data ……………………………………………… 139
Executing statements …………………………………………… 140
Verifying query results …………………………………………. 140
Other DbFit features ……………………………………………. 141
13. Testing legacy code ……………………………………………….. 143
Covering legacy code with tests …………………………….. 143
Use blank cells to print out results …………………………. 143
Use show and check with FitLibrary ……………………….. 144
Wrap existing objects for tests ………………………………. 145
Use ArrayFixture and RowFixture to capture data
batches ……………………………………………………………… 146
Using existing forms for regression tables ……………….. 147
14. Under the hood ……………………………………………………. 151
What really happens during a test? ………………………… 151
Attaching the Visual Studio debugger ……………………… 155
Load non-standard cell handlers for simpler comparisons
………………………………………………………………… 157
Simplify verifications with a custom cell handler ………. 158
Avoid conversions by supporting custom data types …… 159
Implement domain-specific tests using custom fixtures
………………………………………………………………………… 160
IV. Appendices ………………………………………………………………….. 163
A. Formatting text ……………………………………………………… 165
B. Test smells ……………………………………………………………. 167
C. Resources ……………………………………………………………… 169
Web sites …………………………………………………………… 170
Blogs with good articles on FitNesse.NET ………………… 171
Articles ……………………………………………………………… 171
Video presentations and slides ………………………………. 173
Promising tools ………………………………………………….. 173
D. Source code ………………………………………………………….. 175
C# Classes …………………………………………………………. 175
FitNesse Tests …………………………………………………….. 202
Build scripts ………………………………………………………. 214
Web code ………………………………………………………….. 215
Index ……………………………………………………………………………… 217
About the author ………………………………………………………………… xi
I. Getting started ………………………………………………………………….. 1
1. Introduction …………………………………………………………….. 3
Who should read this book? ……………………………………. 3
Why bother with TDD? …………………………………………… 4
Beyond unit tests …………………………………………………… 6
Getting FIT …………………………………………………………… 7
FitNesse or NUnit? …………………………………………………. 9
The next step ………………………………………………………. 11
2. Installing FitNesse ……………………………………………………. 13
Setting up FitNesse ……………………………………………….. 13
A quick test …………………………………………………………. 15
How FitNesse connects to .NET classes ……………………… 20
Don’t forget the test …………………………………………….. 21
Playtime ……………………………………………………………… 23
II. FitNesse and TDD in practice ……………………………………………. 25
3. Our Project …………………………………………………………….. 27
Lottery rules ………………………………………………………… 27
Selected user stories ……………………………………………… 27
Applying TDD to our project ………………………………….. 28
The next step ………………………………………………………. 35
4. Writing basic tests ……………………………………………………. 37
ColumnFixture — the Swiss Army knife of FitNesse ……… 38
Testing in plain English …………………………………………. 42
Playtime ……………………………………………………………… 46
5. Writing simple test scripts …………………………………………. 47
Passing values between tables …………………………………. 48
Writing a simple test script …………………………………….. 50
Use data-transfer objects directly …………………………….. 52
Using symbols to check dynamic values ……………………. 55
Checking for errors ………………………………………………. 55
Playtime ……………………………………………………………… 57
6. Writing efficient test scripts ……………………………………….. 59
Better test scripts with DoFixture …………………………….. 61
Use DoFixture keywords for better control ………………… 66
Keep ActionFixture in mind ……………………………………. 67
Playtime ……………………………………………………………… 68
7. Removing duplication ………………………………………………. 71
Group related tests into test suites …………………………… 71
Include pages and use them as components ………………. 74
Reuse entire suites with symbolic links …………………….. 75
Use markup variables to parameterise test pages …………. 75
Defining common actions ……………………………………… 77
Remove irrelevant information ……………………………….. 77
Acceptance tests should focus on business rules …………. 78
Hide parts of the page …………………………………………… 79
Playtime ……………………………………………………………… 79
8. Coordinating fixtures ……………………………………………….. 81
Embed fixtures for best results ……………………………….. 82
Use SetUpFixture to prepare the stage for tests …………… 83
Create test suites in flow mode ……………………………….. 88
Wrapping business objects with DoFixture ………………… 90
Playtime ……………………………………………………………… 91
9. Working with collections …………………………………………… 93
Testing lists of objects …………………………………………… 94
Checking for empty collections ………………………………. 97
Beware of test extensions ………………………………………. 99
Use RowFixture for better precision ……………………….. 101
Playtime ……………………………………………………………. 104
III. Advanced FitNesse usage ……………………………………………….. 105
10. Working in a team ……………………………………………….. 107
Options for team setup ……………………………………….. 107
Organising the files …………………………………………….. 110
Integrating with automated build tools …………………… 114
11. Testing web interfaces ……………………………………………. 121
Choosing the right thing to test …………………………….. 121
Introducing Selenium ………………………………………….. 123
Connecting from FitNesse ……………………………………. 127
Running tests on a remote server …………………………… 133
More Selenium tests ……………………………………………. 134
12. Testing database code ……………………………………………. 135
Connecting to the database ………………………………….. 135
Working with stored procedures ……………………………. 138
Preparing test data ……………………………………………… 139
Executing statements …………………………………………… 140
Verifying query results …………………………………………. 140
Other DbFit features ……………………………………………. 141
13. Testing legacy code ……………………………………………….. 143
Covering legacy code with tests …………………………….. 143
Use blank cells to print out results …………………………. 143
Use show and check with FitLibrary ……………………….. 144
Wrap existing objects for tests ………………………………. 145
Use ArrayFixture and RowFixture to capture data
batches ……………………………………………………………… 146
Using existing forms for regression tables ……………….. 147
14. Under the hood ……………………………………………………. 151
What really happens during a test? ………………………… 151
Attaching the Visual Studio debugger ……………………… 155
Load non-standard cell handlers for simpler comparisons
………………………………………………………………… 157
Simplify verifications with a custom cell handler ………. 158
Avoid conversions by supporting custom data types …… 159
Implement domain-specific tests using custom fixtures
………………………………………………………………………… 160
IV. Appendices ………………………………………………………………….. 163
A. Formatting text ……………………………………………………… 165
B. Test smells ……………………………………………………………. 167
C. Resources ……………………………………………………………… 169
Web sites …………………………………………………………… 170
Blogs with good articles on FitNesse.NET ………………… 171
Articles ……………………………………………………………… 171
Video presentations and slides ………………………………. 173
Promising tools ………………………………………………….. 173
D. Source code ………………………………………………………….. 175
C# Classes …………………………………………………………. 175
FitNesse Tests …………………………………………………….. 202
Build scripts ………………………………………………………. 214
Web code ………………………………………………………….. 215
Index ……………………………………………………………………………… 217

