Saturday, November 14, 2009

GivWenZen and FitLibrary Part 3

I mentioned in the previous post that I liked the plain text but really would like to write plain text without the indicator, '- ', that it is plain text.  In my continued testing of and improving the usage of GivWenZen with FitLibrary I have tweaked the ParseUtility class in FitLibrary to look for BDD keywords given, when, then and and.  This allows the same simple test we have been looking at to be written like the following.

A bit cleaner, in my oppinion, that prefixing each line with '- '.

I have done an override of the fitlibrary.utility.ParseUtility class. Unfortunately it is not extensible because it is mostly static methods. :( My override of this class simply changes the place that looks for '- " to look for one of the GivWenZen/BDD keywords, given, when, then or and. Here is the part I changed/added.  I added the static int isGivWenZenLine(String html)method and replaced a line that was simply looking for '- ' with a call to the new method. See ParseUtility is the example source.

When the test is run the then line is turned green on a failure. (more about this later)

In reality there are tables when the plain text test runs. FitLibrary is still running this as if each line were tables and magically creates the tables at run time. I have a custom CSS to stop the tables from showing after the test runs. Below are the CSS values I have overridden in my fitnesse.css. table, td, th { border: none; }


  1. Cool! Thank you for sharing - could you post a screenshot of an executed test? Are the words colored red/green (instead of cells which no longer exist)?

  2. I will get some images posted in the next couple of hours. And yes I have the then portion of the test turning green in my example. Any of the steps can be turned green. I will post a follow up to discuss how to do this and why I only like to see the when turn green.

  3. Thank you! This is very interesting - I may give it a go.

    P.S. - My dad is from Kalookan City (which I believe is a suburb of Manila).


  4. Great, let me know if you have any other questions.

    I have only been here in Manila since late June of this year. I do not think I have been to this area yet. Manila is a huge city with a lot of people. Some of the friendlies people you will ever meet.