Graphical workflow tests for Rails - alpha version released

For many web apps, it’s important to get the user’s workflow right. Consider a Rails app that uses some variant of acts as authenticated to handle user registration and login. Here’s one way of describing an example of normal registration:

John visits the home page.
John follows the “sign up” link.
(John is now on the signup page.)
John signs up as “john”, email “john@example.com”, password “sloop”.
(John is now on the welcome page.)
John waits for activation email…
John clicks on a URL ending in an activation code.
(John is now on the login page.)
John logs in as “john”, password “sloop”.
(John is now on the member page.)

Here’s another:

A registration workflow

Which is better? If I were trying to design the workflow—get it so that it’s right for the users—I’d much rather use a picture (whether drawn in OmniGraffle, as this was, or on a napkin or whiteboard.) Why?

  1. It’s easier to “zoom out” from a picture, to ignore the details. When I do that, I’m more likely to notice missing workflows or stupidities in the ones that I have.

  2. As a designer, I’ll soon have to explain my thinking to others. It’s easier to explain a picture because it’s sitting right there in front of both of you, visible in two-dimensional space. It’s simple to refer to something you already mentioned: point at it. A wealth of context gets recalled by that simple gesture. If it’s not readily recalled, you can decorate the graphic with something that jogs the memory. Pictures make for a much more fluid way of communicating.

  3. Our minds are in bodies; and bodies have minds of their own. We think kinesthetically and visually, not (just) by banging propositions together according to the rules of some kind of logic. The more ways you think about something, the fewer mistakes you’ll make.

But there’s one big disadvantage of pictures from the point of view of the test-driven (behavior-driven, example-driven) programmer: they’re not executable.

Until now

I’ve released an alpha version of an open-source library that converts such pictures into Ruby tests. Below the fold, I show how the workflow picture becomes a Rails integration test.

✂——✂——✂——✂——✂——✂——✂——✂——✂——✂——

To make the picture executable, you first need code to parse the OmniGraffle document. That’s pretty easy. Then you need to interpret three different kinds of elements of the picture:

  1. Labels on lines need to be turned into appropriate GET or POST messages. For example, ‘john logs in as “john”, “sloop”‘ can turn into a call of this method:


      def john_logs_in_as(name, password)
        post_via_redirect(action_for_link(”login”),
                            :user => {
                              :login => name,
                              :password => password
                            })
        assert_response :success
      end

    (Notice that I’m not using POST directly. Instead, I’m building a set of methods that’s at the same level of abstraction as the picture. I want to separate the issue of turning a designer’s intention into Ruby from the issue of what HTTP implements that intention.)

  2. Icons contain their own name (capitalized for emphasis). They need to be turned into calls to this method:

      def assert_on_page(page)
        assert_template page.downcase.gsub(/\s+/, “”)
      end

  3. Finally, there’s one special case: the text “John waits for activation email…” looks to OmniGraffle much like an icon, but it needs to be treated like a label. That is, it should turn into a call to this method:

      def john_waits_for_activation_email
        assert_equal([@user_email_address],
                     @sent.collect { |m| m.to[0] })
        assert_equal(”Welcome, Giant Microbe Fan”,
                     @sent.first.subject)
      end

    (Notice that this method is by no means a complete check of the email. That should be done by some more localized, non-workflow, tests. The methods for these tests answer the question “did the right thing happen?”, not “is what happened right in all details?”)

Given the appropriate interpreter-of-graphics, the above picture gets turned into these method calls:

@target.send(’john_visits_home_page’)
@target.send(’john_follows’, “sign up”)
@target.send(’assert_on_page’, “signup”)
@target.send(’john_signs_up_as’, “john”, “john@example.com”, “sloop”)
@target.send(’assert_on_page’, “welcome”)
@target.send(’john_waits_for_activation_email’)
@target.send(’john_clicks_on_url_ending_in_activation_code’)
@target.send(’assert_on_page’, “login”)
@target.send(’john_logs_in_as’, “john”, “sloop”)
@target.send(’assert_on_page’, “member”)

This test happens to fail. That looks like this:

A failing integration test in TextMate

What next? And what about you?

I’m building a site to learn Rails, and I’ll continue writing graphical tests for it. I expect that I’ll add new types of graphical tests; I have in the past. The tricky part is going to be figuring out a balance: on the one hand, you want designers and product directors to be able to sketch freely and not be bound by the tool. (They should not be taking on much more additional work.) On the other hand, the programmers shouldn’t have to do much work beyond what they’d do if they were writing tests directly in Ruby. What I need is some sort of
“language” for describing how pictures are to be interpreted that’s powerful enough, simple enough, etc. - all those things that are so hard to get right at the same time. For reference, here’s how I “program the interpreter” now:

class UserRegistrationTest < ActionController::IntegrationTest
  include GraphicalTestsForRails
  …
 
    graphics = InWorkflowOrder.new(doc.first_sheet).graphics
    interpreter = GraphicInterpreter.new(graphics,
          ‘line labels’ => ArgsFromQuotedText.new,
          ’shaped graphic text’ => TextIsNameOfPage.new(‘assert_on_page’),
          ‘text…’ => ArgsFromQuotedText.new)
    interpreter.run_against(self)

The more people I have trying this on their own sites (and helping with language design), the better it will turn out. Let me know if you’re interested.

5 Responses to “Graphical workflow tests for Rails - alpha version released”

  1. Exploration Through Example » Blog Archive » Everyday Scripting utilities at Rubyforge Says:

    […] if you’re making gems anyway (like I’m doing these days), s4t-utils might as well be another gem your gem depends on. So s4t-utils is now available from […]

  2. Exploration Through Example » Blog Archive » Crowdware Says:

    […] one of my graphical tests. The input is in a form pleasing to a non-technician. In this case, the test is failing. The output […]

  3. Exploration Through Example » Blog Archive » Rough sketch of examples track at Agile2008 Says:

    […] Space, but oriented toward showing rather than telling. For example, I’d be happy to show my graphical workflow tests in action—if people want to see […]

  4. Exploration Through Example » Blog Archive » An example of a useful workflow test Says:

    […] been growing a little disillusioned with my graphical workflow tests: implementing the test support code seems like a lot of work for little benefit. (It has nothing to […]

  5. OSTATLI a success, and a lot of fun « A Test Guy Says:

    […] a demo of what he accomplished after 10 minutes of playing with CubicTest. It reminded me of the graphical workflow test for rails Brian Marick was working […]

Leave a Reply

You must be logged in to post a comment.


  • Buy Cheapest fluoxetine cod Online Best Online. Buy Medications Online.
  • Buy Cheapest diazepam generics Now Cheap Online Pharmacy. WorldWide Shipping.
  • Buy Cheapest trazodone for sleep Online Best Drugstore. Free Viagra Pills!
  • Buy Cheapest does cialis work Online Best Internet. Top Online Pharmacy.
  • Buy Cheapest viagra generic Online Cheap Prescription Drugs. Best Internet.
  • Buy Cheap clomid get pregnant Now Cheap Pharmacy Online. Cheap Online Pharmacy.
  • Buy Cheapest diet pills for weight loss Now No Prescription Needed. Best Drugstore.
  • Buy Cheapest codeine buy Online Order Cheap Meds Without Rx. Low Prices.
  • Buy Cheap purchase xenical Online Discount Pharmacy Online. Best Prices.
  • Buy Cheapest viagra in mexico Online Drugs, Health And Beauty. Best Internet.
  • Buy Cheap buy cheap generic viagra Now Free Viagra Pills! Guaranteed Shipping.
  • Buy Cheapest discount weight loss suppliments Now Best Prices. No Prescription Needed.
  • Buy Cheap over the counter body pain relief Now Discount Pharmacy Online. Best Drugstore.
  • Buy Cheap levitra levitria Online Cheap Pharmacy Online. Guaranteed Shipping.
  • Buy Cheap natural viagra alternatives Now Pharmacy Store. Order Cheap Meds Without Rx.
  • Buy Cheapest very cheap phentermine Now WorldWide Shipping. Cheap Pharmacy Online.
  • Buy Cheap generics for valium Now Guaranteed Shipping. Discount Online Pharmacy.
  • Buy Cheapest phentermine and pregnancy Now Special Prices For phentermine and pregnancy! Pharmacy Store.
  • Buy Cheap clomid and multiple births Now 100% Satisfaction Guaranteed. Low Prices.
  • Buy Cheap tramadol recreational Now 100% Satisfaction Guaranteed. Low Prices.
  • Buy Cheap levitra facts Online 100% Satisfaction Guaranteed. Best Online.
  • Buy Cheap ativan information Online Cheap Pharmacy Online. Guaranteed Shipping.
  • Buy Cheap cialis mail order medication Online Free Viagra Pills! WorldWide Shipping.
  • Buy Cheapest buy hair loss medicine stop Now Best Prices. Order Cheap Meds Without Rx.
  • Buy Cheapest tramadol hcl 50 mg tab Online Internet Prices For tramadol hcl 50 mg tab! Low Prices.
  • Buy Cheapest acne medication pills Now Discount Online Pharmacy. Low Prices.
  • Buy Cheapest cheapest ultram Now Online Medical Shop. Cheap Pharmacy Online.
  • Buy Cheap buy phentermine diet pill Now Drugs, Health And Beauty. Online Medical Shop.
  • Buying Cheap real phentermine. Offshore Pharmacy, Good Prices. Best Internet.
  • Buy Cheap viagra buy india Online Cheap Prescription Drugs. Best Internet.
  • Buy Cheap pain medicine online Now Order Cheap Meds Without Rx. Best Prices.
  • Buy Cheap drugs on line Now All Medications Are Certificated! Best Prices.
  • Buy Cheap viagra super active Online Cheap Online Pharmacy. Pharmacy Store.
  • Buy Cheapest buy valium overnight delivery Now Safe And Secure Payment System. Low Prices.
  • Buy Cheapest cialis 30 oral Online Best Drugstore. Free Viagra Pills!
  • Buy Cheapest nonprescription pain killer Now Best Prices. Buy Medications Online.
  • Buy Cheapest weight loss probiotics Now Online Medical Shop. WorldWide Shipping.
  • Buy Cheap cialis levitra viagra Now 24/Internet)(safe Pharmacy. Best Drugstore.
  • Buy Cheap fluconazole 150mg Now Best Drugstore. Internet Prices For fluconazole 150mg!
  • Buy Cheapest phentermine online directory Online Best Internet. Top Online Pharmacy.
  • Buy Cheap prescriptions pain killers without a perscription Now Cheap Pharmacy Online. 24/Online Pharmacy.
  • Buy Cheapest xanax generics Online Cheap Prescription Drugs. Best Internet.
  • Buy Cheap fat weight loss products Online Low Prices. Order Cheap Meds Without Rx.
  • xanax usa Online Without Prescription Best Prices. Best Internet.
  • Buy Cheapest multiple prescriptions of xanax Now Best Drugstore. No Prescription Needed.
  • Buy Cheap where to buy valium Now The Largest Internet Pharmacy. Best Prices.
  • Buy diflucan pill Without Prescription Doctor. Best Prices. Best Internet.
  • Buy Cheap anti depression tablets Online No Prescription Needed. Best Drugstore.
  • Buy Cheapest order amoxicillin Now Cheap Pharmacy Online. WorldWide Shipping.
  • Buy Cheap 100mg tramadol Now Cheap Prescription Drugs. Best Drugstore.
  • Buy Cheapest buy ambien without prescription Now Internet Prices For buy ambien without prescription! Best Online.
  • Buy Cheapest does buspar work Now Pharmacy Store. Online Medical Shop.
  • Buy Cheap impotence levitra Online WorldWide Shipping. Guaranteed Shipping.
  • Buy Cheapest ambien long term effects Now No Prescription Needed. WorldWide Shipping.
  • Buy buy codeine no prescription Without Prescription Doctor. Pharmacy Store. Low Prices.
  • Buy Cheapest tramadol info Online Cheap Online Pharmacy. Best Online.
  • Buy Cheapest cheap buspar Now Best Prices. The Largest Internet Pharmacy.
  • Buy Cheap phentermine online Online Best Prices. Online Prices For phentermine online!
  • Buy Cheap buy aspirin witn codeine from canada Now 24/Online Pharmacy. Cheap Pharmacy Online.
  • Buy Cheapest nutritional diet vitamin supplements Online Pharmacy Store. Buy Medications Online.
  • Buy Cheapest cheap generic cialis Now Pharmacy Store. Discount Pharmacy Online.
  • Buy Cheapest order spironolactone Online Best Internet. Cheap Online Pharmacy.
  • Buy Cheap long term anxiety treatment Now Order Cheap Meds Without Rx. Best Prices.
  • Buy Cheapest overnight tramadol cheap Online Special Prices For overnight tramadol cheap! Best Prices.
  • Buy Cheapest buy diet pills in uk Now Pharmacy At The Best Price! Best Drugstore.
  • Buy Cheapest order plavix Online Top Online Pharmacy. Best Internet.
  • zoloft lexapro Online Without Prescription Best Online. Free Viagra Pills!
  • Buy Cheap clonazepam drug Online Pharmacy Store. Drugs, Health And Beauty.
  • Buy Cheapest online medicine Online Discount Pharmacy Online. Best Internet.
  • Buy Cheap pharmacy anxiety Online The Largest Internet Pharmacy. Best Online.
  • Buy Cheapest codeine solution Now Best Online. Top Online Pharmacy Supplier.
  • low cost xenical Online Without Prescription Low Prices. Pharmacy Store.
  • Buy Cheap effects of lasix Now Best Online. Order Cheap Meds Without Rx.
  • Buy Cheap overnight delivery ativan Online Best Online. 24/Internet)(safe Pharmacy.
  • Buy Cheapest viagra buy Online Online Prices For viagra buy! Low Prices.
  • Buy Cheap how long does levitra last Online Top Online Pharmacy. Online Medical Shop.
  • Buy Cheap vitamin supplement Online Pharmacy At The Best Price! Low Prices.
  • Buy Cheap pain meds without prescriptions Now Cheap Pharmacy Online. 24/Online Pharmacy.
  • Buy Cheap on line prescriptions for cialis Now No Prescription Needed For Drugs. Best Online.
  • Buy Cheapest cialis line order Now Best Drugstore. Buy Medications Online.
  • Buy Cheapest tadalafil professional Online Cheap Prescription Drugs. Best Prices.
  • Buy order appetite suppressants online Online Without Prescription. Internet Prices For order appetite suppressants online!
  • Buy Cheap valium about Now Best Internet. Pharmacy At The Best Price!
  • Buy overnight shipping of cialis Without Prescription Doctor. Best Prices. Best Online.
  • Buy Cheapest valium no rx Now Best Drugstore. Buy Medications Online.
  • Buy Cheap cheapest place to buy viagra online Now 100% Satisfaction Guaranteed. Best Drugstore.
  • Buy Cheap compare viagra cialis levitra Now WorldWide Shipping. Cheap Pharmacy Online.
  • Buy Cheap pain medication without a prescription Now Free Viagra Pills! Internet Prices For pain medication without a prescription!
  • Buy Cheap wholesale medications Now Buy Medications Online. 24/Online Pharmacy.
  • Buy Cheap overnight shipping of cialis Now Cheap Pharmacy Online. Online Medical Shop.
  • Buy Cheap cialis impotence drug eli lilly co Now Best Prices. Internet Prices For cialis impotence drug eli lilly co!
  • Buy Cheap online diet meds Now Drugs, Health And Beauty. Guaranteed Shipping.
  • Buy Cheap levaquin 500 mg Now Free Viagra Pills! Special Prices For levaquin 500 mg!
  • Buy Cheapest diet patch in canada Online Best Drugstore. Guaranteed Shipping.
  • Buy Cheapest do diet pills really work Online No Prescription Needed. Best Online.
  • Buy Cheapest antidepressant pills Now Low Prices. Safe And Secure Payment System.
  • Buy Cheap reliable online pharmacies Online Best Drugstore. Pharmacy At The Best Price!
  • Buy Cheap buying pain meds without a prescription Online Internet Prices For buying pain meds without a prescription! Best Online.
  • Buying Cheapest xanax and weight loss. Mexican Rx, Best Prices. Free Viagra Pills!
  • Buy Cheapest buy valium cheap Now Low Prices. Drugs, Health And Beauty.