Thursday, April 24, 2008

Testing Web Applications - More Art than Science

Gregg Pollock, of Rails Envy, gave a session on "The Art of Texting Web Applications"
The talk was based on the Model View Controller framework.
View Unit tests are bad because they are:
  • Hard to maintain
  • Very brittle - a change in the controller might impact many views
  • Difficult to debug
Another approach is Test Driven Development
  • Red - Write the tests
  • Green - Test until pass
  • Refactor
Another alternative is Behavior Driven Development. In the Ruby language this syntaxx/language for this is RSpec - A Domain specific language that is very descriptive. WebRat provides RSpec stories support.
Isolation is important. You should be able to run all your model view and Controller tests separately. You do this by using Mocks and Stubs.
Have One Assertion per specification. It simplifies debugging.
Integration Testing
User Stories are used to help Integration Testing by describing scenarios in english format.
The examples for BDD were given in Ruby on Rails but this method is appearing in other languages such as:
Ruby is the only language to integrate plain text stories (ie with WebRat).