Jake Scruggs

writes ruby/wears crazy shirts

This summer I'm revisiting my short apprenticeship at Object Mentor. I'll be posting commentary on all my posts from the summer of 2004 exactly 5 years later to the day.

Friday 8-6-04

Last day of the TDD and refactoring class today. We started with an intro to FitNesse, which is acceptance testing. The basic idea is that while unit tests are concerned with the inner workings of the classes and methods, acceptance testing is after more global behavior. An acceptance test tends to simulate the actual operation of the program. What you do is enter some data in a table that the user might enter. Now this table is in a wiki which is being served by FitNesse which may be running locally or on the company server. Then, when you push the button (on the wiki page) that sez 'Test,' FitNesse parses the wiki text and feeds the data from the table into your program. And then it checks the output against the table you created (on the wiki) with the expected output.

Which sounds a lot like a unit test -- just applied to a larger scale. And it mostly is, but with the added benefit that it's easier to write a test in a wiki than to learn java, or C#, or whatever. That means that the customer can write the acceptance tests and you can gets busy making them pass. Which is pretty cool.

The tick of Fitness is that you have to write a bunch of interface code between your natural language wiki tests and your code -- In that way it's kind of like cucumber. But anyone wishing to write Fitness/Cucumber tests has to learn to think a bit like a programmer because you can't write just any sentence and have the magic computer turn it into a test. We programmers often forget how hard our job is until we see non-coders attempt to do what we do every day. Often a team will try to adopt an acceptance testing framework because the tests look so easy to write but that is deceptive -- computers can't really read natural language yet and so writing acceptance tests as a non programmer can be frustrating because the cucumber or selenium or fitnesse or whatever tests look like sentences but a slight deviation from the form produces a cryptic error message. Ultimately I think they are worthwhile but you have to have a serious commitment from the people writing the tests to learn how write the tests.

0 comments :