Randy Coulman with Key Technologies is going to talk about Acceptance testing with Fit, FitNesse, and FitLibrary. This is going to be more of an overview of the tools than anything. Randy: Working for Key and doing Smalltalk for afive years.
The example we'll use - the game "Mastermind". Basic idea - you set up a "code" (colored pegs in sequence), and your opponent tries to break the code. Randy broke down the rules into a set of Fit tests using the Fit Wiki server (FitNesse). Fit is the acceptance testing framework from Ward Cunningham. FitLibrary is a set of additional fixtures. Available for:
- VW, VAST (port in progress)
- Java
- .NET
- C/C++/C#
- Python
- Ruby
- Perl
- PHP
- et. al.
Randy is the maintainer of the Smalltalk (VW) port. The idea is that you write the tests in HTML pages, and then run them on any back end - thus making the acceptance testing live above the implementation lavel. The developers create fixture code that runs the tests themselves. The writing:
- Subclass the desired fixture class (ActionFixture used directly most times)
- implement #signatureFor: to provide type adaptor information
- Implement the necessary instance variables and methods
ColumnFixture
This is the simplest one - each row is a different scenario. Each column is either and input or an output. The expected outputs are compared to actuals, and then the test is marked red (fail) green (pass). Rows and columns refer to the HTML table used for presentation.
ActionFixture
You create "workflow" type tests with this. There are actions to deal with - start, enter, press, check - you create a helper class to implement. This one can be brittle.
RowFixture
This is used to check a collection of results (eg - results of a query). The order of the rows doesn't matter, it's smart about matching up rows. It will show missing/surplus rows.
Then there are a set of extension fixtures - DoFixture, SetUpFixture, SetFixture/ArrayFixture, CalculateFixture (and more). Randy has a few implemented, is doing more.
DoFixture
Must be the first one on a test page - it's a "workflow" fixture. Takes over execution of remaining tables. It's less verbose than an ActionFixture.
SetUpFixture
Used to set up data for a test. Similar to givens in a ColumnFixture - no feedback in the table
Set/ArrayFixture
Similar to RowFixture, but easier to write. You just create a set and it gets auto-wrapped. In SetFixture, order is irrelevant, in ArrayFixture, it matters.
CalculateFixture
Similar to ColumnFixture - no header markup needed to distinguish givens and expected values.
Now a demo of the way it works - I'd take a picture, but it turns out that I can't email myself pictures from here - which means that I need a real camera :) You can download all this stuff and try it out:
"How do I debug a test?" Well, in Smalltalk it's simple - you use the debugger that's right there, and slap in a breakpoint. It's a little more complicated over in curly-brace-ville.