InfoQ catching up with the easyb team

Posted by Ken Brooks Tue, 23 Sep 2008 04:23:00 GMT

Craig Wickesser from InfoQ pinged the members of the easyb dev team recently in preparation for an article about BDD and bringing it to the masses.

The focus of the article is on easyb. It references Rod’s excellent JavaWorld article and then goes on to dive into a brief Q&A with the easyb team.

If you want some inside information on where easyb is headed, then Behavior-Driven Development for Everyone by Craig is hot off the presses today and is a must read.

Posted in  | Tags ,  | no comments

pretty print your behavior

Posted by Ken Brooks Sun, 21 Sep 2008 00:00:00 GMT

Our favorite BDD tool is about to get some upgrades that give you that warm fuzzy feeling inside. Just like waking up on a cold winter day to the wonderful smell of baking cookies. Yummy!

Html reports you say? Well hello Mr. Fancy Pants!

All the goodness you’ve come to love about the existing easyb reports have now come to life in living color. In order to enable them, you’ll just need to configure another report in exactly the same way as other reports.

via ant in your easyb task:

<report location="target/easyb-report.html" format="html" />

or on the command line:

c:>java org.disco.easyb.BehaviorRunner my/path/to/MyStory.groovy -html ./target/easyb_report.html

Currently available are a Summary, Specification List, Stories List, Specification List Plain, Stories List Plain.

The Summary you saw just above. It will show you an overall summary, and summaries at the specification and story level. Any failed behavior count will be highlighted in red and pending behaviors will be highlighted in a wonderfully peaceful reminder color of purple.

The Stories List provides all of that that but takes it a couple of steps further. All of the elements of the stories (any scenarios, givens, whens, thens, etc.. ) will show up when the story name is clicked on and for any failures you’ll get an eyeful of failure messages along with part of the relevent stacktrace.

More of the same for Specifications list.

Since all we had prior to easyb 1.0 was a text only format, we got sentimental and included a stripped down, nearly text only, format here as well. Ok, so we didn’t really get sentimental, we actually thought this is really where the rubber meets the road when it comes to bringing stakeholders and developers together. As part of your build you can now publish these reports and share them with those interested parties. Makes BehaviorDrivenDevelopment truly, uh, easy!

All of this and more is waiting for you in easyb 1.0. Just like those tasty warm cookies, its still in the oven and I’ll bet you can’t wait to get your hands on it.

Keep an eye on the following sites for more announcements about the availability of 1.0.

Posted in  | Tags , , , ,  | 1 comment

an easyb storm is brewing

Posted by Ken Brooks Sat, 20 Sep 2008 04:40:00 GMT

The press on easyb has really picked up in the last few weeks. I think the development world at large is about to catch onto the super fun way of BehaviorDrivenDevelopment via easyb. For those of you who haven’t heard, easyb is a BDD tool for testing your code but it has a slick DSL (Domain Specific Language) that makes it ridiculously easy to specify and ensure the intentions of the code you are testing. Best of all, its written in groovy so its usable in your existing jdk5+ jvm.

Here are a few posts I know about, feel free to ping me with others you know about.

Posted in  | no comments

Executable Documentation - EasyB style

Posted by Ken Brooks Mon, 04 Feb 2008 21:45:00 GMT

One of the challenges of maintaining and enhancing an existing system is that the documentation goes out of date probably before you even finish it the first time. Whenever someone has a question for me about how does something work I usually refer to the location of truth. That would be the code itself, which is always the most up to date source of documentation. So the closer to the source you get the better chance your documentation has of standing the test of time.

Unit Tests helps in this area in that they can outline the assertions we are placing on our code. That too must stay up to date because it is also close to the code. Unfortunately unit tests are often more complex than the code they are testing and ultimately end up not being very good sources of documentation either.

There has to be a way to build human (possibly even business person) consumable documentation that stays in sync with the truth.

Enter EasyB.

EasyB is a BDD testing framework written in groovy and java. It provides what we like to call executable documentation. This is achieved by taking TDD, all sopping wet with techy mess, and throwing it in the evolutionary dryer with a nice fabric softener. Out from the other end pops a nice fluffy testing framework that can not only provide up-to date documentation about the application every time it is built, but can even bridge the gap between business requirements and developer interpretation.

It has two supported ways to write specifications. Behaviors and Stories. Its just a matter of personal taste on which you use for each component in your project. Behaviors often are shorter and good for utilities. Stories are more verbose and usually map to a series of interactions.

Behaviors look like this:

it "should return null for null input to trim", {
  ensure(StringUtilPartial.trim(null)) {
    isNull
  }
}

it "should return the string without whitespace at either the end", {
  StringUtilPartial.trim(" somestring ").shouldNotBe null
  StringUtilPartial.trim(" somestring ").shouldBe "somestring"
}

Stories look like this:

scenario "appending string to empty string buffer", {
  given "an empty string buffer", {
    stringBuffer = new StringBuffer()
  }

  when "a string is appended", {
    stringBuffer.append("somestring")
  }

  then "the buffer should contain the string appended", {
    stringBuffer.toString().shouldBe "somestring"
  }
}

scenario "appending string to existing string buffer with existing data", {
  given "a string buffer with an initial value", {
    stringBuffer = new StringBuffer("abcd")
    originalStringBufferValue = stringBuffer.toString()
  }

  when "a string is appended", {
    stringBuffer.append("somestring")
  }

  then "the buffer should contain the original value plus the appended value", {
    stringBuffer.toString().shouldBe(originalStringBufferValue + "somestring")
  }
}

What you have just witnessed is that we have tested our code and written documentation at the same time. That documentation will evolve right along with the code its testing and nobody has to be the low man on the totem pole and write documentation.

All well and good, but what we wrote above still wouldn’t be what a business person would consider documentation. Too much techy goobledeegook in there. Easyb has another trick up its sleeve especially when dealing with the story based specifications. When I ran the story above a report is generated and here is what the contents look like:

  Story: string buffer
    scenario appending string to empty string buffer
      given an empty string buffer
      when a string is appended
      then the buffer should contain the string appended
    scenario appending string to existing string buffer with existing data
      given a string buffer with an initial value
      when a string is appended
      then the buffer should contain the original value plus the appended value

What?! Where did that english documentation come from? Shhh.. don’t tell your developers that they wrote it.

Check out easyb at easyb.org and join the group to keep up on the latest developments. The current release of easyb is 0.6 and some of the syntax presented above (shouldBe for example) is in the trunk and not a release yet.

Posted in  | Tags , ,