Graphical tests again

I’m spending the summer getting good enough at Rails to fit in at Rails Edge. To do that, I’m creating a website for my kids.

Recently, I plugged in Acts As Authenticated to do signup, login, authentication, and the like. Since I’m messing around with that plugin’s workflow, this seemed like a good opportunity to write workflow tests (which, in Rails, falls under the category of “integration tests”). Here’s my first test, which follows something like the “Even Higher-Level Tests” style in section 13.4 of Agile Web Development With Rails:

  def test_normal_signup
    dave = new_visitor
    dave.starts_at ‘home page’
    dave.goes_to ’sign up page’
      (dave.is_at ’sign up page’)
    dave.enters :login => ‘dave’, :email => ‘’,
                :password => ‘dave332′, :confirm_password => ‘dave332′
      (dave.is_at ‘welcome page’)
      # Dave goes away
    dave_next_day = new_visitor
    in_email {
      dave_next_day.has_clicked_on_link_to ‘confirmation page’, dave.registration_code
        (dave_next_day.is_at ‘members page’)

But even as I wrote it, I became discouraged. It’s English-like, yes, but it’s still not terribly skimmable. Answers to questions like “Where do you go after you signup?” don’t leap out at you. Is this really a format that’s going to help people either communicate or make sense of paths through a set of pages?

So I fell back on my ideas about graphical tests and drew the following. (Click the picture for a larger pdf.)

A flow through screens

That took longer to draw than it did to write the first test, but actually not a whole lot longer. What do you think? Should I go to the trouble of reimplementing my OmniGraffle parser in Ruby and finish implementing the test? (The good thing about doing that is that it seems like Rails programmers all use Macs, so there’s actually a chance that a test framework I built would get used.)

7 Responses to “Graphical tests again”

  1. bob_carolgees Says:

    I think reimplementing the OmniGraffle parser in Ruby would be time well spent. Will you make it openly available? The second version is much easier to follow.

  2. JeffreyFredrick Says:

    Did you see Ward’s Process Explorer from the Eclipse Foundation portal? It is sort of the opposite, creating a picture from tests, but it does a very good job of letting you see what the flow for a given action is going to be.

    He’s got a bit write-up from it over here:

    And you can play with it directly here:

    (Not at all obvious but you press “swim” to see the diagram for a given test.)

  3. Brian Marick Says:

    I have seen Ward’s thing, thanks. There’ll be a workshop on business-facing tests after PNSQC in Portland. That’ll be a good chance to compare and contrast.

    I think it’s interesting (if it’s true) that our two different audiences led to different implementations. If I understand correctly, a big part of Ward’s motivation was to use tests as a way of engaging and communicating with 18 gazillion potential Eclipse committers/volunteers who needed to see and understand an automated process. That given, writing the test in ActionFixture-ish PHP is fine.

    What I’m trying to do, I think, is serve people who are using drawings to figure out what it is they want, to spark ideas, and to work through possibilities systematically. The first choice tool for that is a whiteboard (petter than pencil and paper because of its improved erasability). But OmniGraffle is not too much slower and more awkward, so it’s the right tool if the work can leave behind a document that needs only massaging to become an executable example/test (in contrast to the whiteboard, which requires rewriting).

  4. Brian Marick Says:

    Bob: yes, anything I do will be distributed as a freely-reusable gem.

  5. Exploration Through Example » Blog Archive » Too much testing Says:

    […] when the code tells you something surprising. For example, I just added groups to my fledgling Graffle parser. Previously, the object at the end-point of a line had to be at the same nesting level as the line […]

  6. Exploration Through Example » Blog Archive » Graffle 0.1.0 released Says:

    […] far as I know, there’s only one other person in the world who cares about testing Rails apps from OmniGraffle documents. (Hi, Tom!) Still, since I always make a fuss to clients about the need to frequently release […]

  7. Testing Outside of the Ruby World | Joseph Wilk Says:

    […] Graphical Tests – Brian Marick […]

Leave a Reply

You must be logged in to post a comment.