easyb now supports re-running failed behaviors

how-to
Sep 10, 20092 mins

The latest version of easyb (that is, 0.9.6) contains two new features (among others, man):

  • the ability to run behaviors listed in a file via the -f flag
  • capturing any failed behaviors at run time in an output file via the -outfail flag

everyone loves rerun!
Thus, given these two features, you can now run a series of behaviors and if any of those behaviors fail, easyb will create a file (the default name if you don’t provide one is failure-files.txt) at the conclusion of the run, which contains a listing of those failed behaviors. Consequently, you can now re-run easyb and pass it this file — accordingly, only the failed behaviors from a previous run will be executed.

For example, imagine you have a suite of behaviors that takes a bit to run — say 10 minutes. If any of those stories (or specifications, for that matter) fail, it becomes somewhat painful to have to re-run the entire suite after making any requisite fixes which address the previously failing behavior. In that case, it oftentimes becomes easier (and much quicker, baby) to just re-run the previously failing bogue behavior (i.e. a few seconds versus 10 minutes). Thus, when executing easyb, say from Ant, you can now set the failureFile property of the easyb like so:

<pre class="prettyprint"><code><easyb failureproperty="easyb.fail" failureFile="target/easyb-failures.txt">
....
</easyb>

In this case, I’m running a series of stories and specifications — if anything fails, a new file will be created listing the offending behavior– in my case, the file will be in the target directory and named easyb-failures.txt. The contents of this file are extremely simple — it’s just a listing of fully qualified file paths. Accordingly, if I want to rerun a particular behavior (or behaviors), I can either execute it via the command line via the -f flag like so:

%>java org.easyb.BehaviorRunner -f target/easyb-failures.txt

or via another Ant task like so:

<pre class="prettyprint"><code><easyb failureproperty="easyb.fail" inFile="target/easyb-failures.txt">
....
</easyb>

With re-running only a subset of a behavior suite (i.e. just the ones that failed) easyb just got a bit easier, don’t you think, man?

You can now follow The Disco Blog on Twitter, baby!
andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author