Saturday, September 18, 2010

FitNesse and today's date with .net

I have an acceptance test that says I need to validate the age of majority in each of the different states and provinces.  Here is a simple example:

Given Mary who is born January 5, 1995 and lives in Manitoba
When she asks if she is the age of majority
Then return no

The test above is faily simple and I could write it like this in the wiki as a Column Fixture (using the fitSharp.dll to test C# code)

!|Check Age of Majority|
|Province State|Birth Date|Am I Underage?|
|MB            |5-Jan-1995|Yes           |

The problem of course is that this test will start failing on January 5, 2013 when Mary turns 18.  Also, it does not perform the boundary testing that I would like it to do in order to test someone who is 18 today vs. someone who will turn 18 tomorrow.  In order to improve this test, I investigated some other date functions in FitNesse and a plugin by James Carr that allowed you to add days to the current date.  These work ok for smaller calculations like "Given document ABC, When it is 30 days old, Then archive it".  However, this would be a little more cumbersome for birth dates when adding 18 years (esp. with leap year calculations) and the !today function in FitNesse does not work in ColumnFixture wiki tables.  So, I found a simple way to meet my requirement.

First, I wrote a class in C# that accepts two parameters to Add or Subtract Years and Days to the current date.  The class uses C#'s simple DateTime addition to add or subtract the years/days from today and returns the result.  You could easily extend this to add months or add other functionality required in your tests:

namespace FitNesseTutorial.Tests
{
      public class GetDateBasedOnToday : ColumnFixture
      {
        public int AddYears;
        public int AddDays;

        public DateTime ResultingDate()
            {
            return DateTime.Today.AddYears(AddYears).AddDays(AddDays);
            }
      }
}

Then in FitNesse at the top of my script for this story I call GetDateBasedOnToday and store the resulting values in FitNesse variables.  Finally,  I use the variable names through my script to reference the underage and of age birth dates.  Here is an example:

The FitNesse script:

''Get underage and of age dates for 18 and 19 year olds''
!|Get Date Based On Today          |
|Add Years|Add Days|Resulting Date?|
|-18      |1       |>>UNDERAGE_18  |
|-19      |1       |>>UNDERAGE_19  |
|-18      |0       |>>OFAGE_18     |
|-19      |0       |>>OFAGE_19     |

!|Check Age of Majority|
|Province State|Birth Date   |Am I Underage?|
|MB            |<<OFAGE_18   |Yes           |
|MB            |<<UNDERAGE_18|No            |
|BC            |<<OFAGE_19   |Yes           |
|BC            |<<UNDERAGE_19|No            |

In FitNesse, the final result including the acceptance criteria above looks like this:


 (Note: The example above should probably be written as a unit test because it is fairly straightforward, but it simply illustrates how to use the date logic that I'm using as part of larger acceptance tests.)

Sunday, August 15, 2010

Agile readiness assessments at Agile2010

I've posted the images from the session "Look before you leap - Agile readiness assessments done right" at Agile2010.  The images are here http://tinyurl.com/26bwlzw.

Some of the images are blurry in my browser (IE), but if you 'Save As' to your computer then you get more detail (not sure why).  If there are any images you need more detail on, let me know - I still have all the originals.

Saturday, August 14, 2010

Agile2010 - My Conference Summary

My user stories for the conference were:
- Learn more about coaching and agile assessments (done)
- Get ideas for promoting and increasing agile adoption (done)
- Find better ways to use FitNesse and Selenium (done)
- Acquire some new tools for expressing user needs (done)
- Meet many of the people I’ve been following over the years (done)
- Meet some of the AA-FTT folks (done)

In addition, I encountered a passionate community that is willing to share their time, skills and ideas with anyone who asks. In addition, I encountered a troubled group of leaders that is legitimately concerned about the lack of technical content at the conference. In addition, I encountered leaders advocating for agile in all its flavours instead of promoting any specific one (hurray!). In addition, I encountered people passionate about taking what they have learned in agile and using that to improve communities outside of the business world. In addition, I encountered a few technical folks who undervalue mastery of the ‘soft’ skills over the technical skills. In addition, I encountered new friends that I hope to see again next year. In addition, I encountered a dedicated and friendly volunteer staff that helped make the conference run smoothly. In addition, I encountered a community willing to volunteer their time and money towards a cause (mano-a-mano).

Finally, I encountered a growing and dedicated community that has a lot of success stories to share, some challenges in the road ahead, and hopefully a commitment to continue the fight together.

Thanks all.

Day 5 at Agile2010

The final day of the conference contained three general sessions.  I found a few people who skipped out on these sessions - too bad for them as the sessions were a great wrap up for the entire week.

Dave West talked about Product-Centric Development and the move away from the separation of business and IT (yes please!).  He asked us to start measuring ourselves and our teams by how much value we deliver and not by on-time, on-budget, # of defects, # of stories, lines of code, etc. We can’t make our teams act as part of the business unless we change our measurements.

Ron Jeffries and Chet Hendrickson provided both comic relief and poignant commentary.  I think Chet's comment sums up their talk: "there’s lots of ideas out there and we need to look at every damn one of them”.

Finally, Mike Cohn's talk was a great ending to the conference as he challenged us with some practical ideas of how to spread what we’ve learned using the ADAPT model.  Create Awareness of the problem by communicating using metrics and stories. Focus on one or two reasons to change. Increase the Desire to change by communicating that there is a better way. Get the team to take agile for a test drive and focus on addressing any fears. Develop the Ability to work in an agile manner by providing coaching and training. Promote agile by publicizing success stories or holding agile safaris where people can drop in to agile teams for a short time to see how it works. Transfer agile to all non development teams, departments, divisions, etc. Align promotions, raises, HR, and Marketing. Finally, don’t expect an agile transition to happen all at once. Create an improvement backlog and improvement communities and work on a few stories that are important to your community before tackling the next ones.

A final call to action from Mike: “Now we’ve upped our skills, up yours!”  Well said.

Day 4 at Agile2010

Two of today's sessions were more about aquiring ammunition and ideas for my own future talks than about aquiring new skills.  In confessions of a Flow Junkie, Dave Rooney introduced me to the coin flipping game which contrasts the flow in Agile vs Waterfall.  In the final session of the day, James Shore and Arlo Belshee made us laugh and cry with their Bloody Stupid Johnson routine.  The highlight of the session is the soon to be framed certificate that I attained as an "Agile Software Specialist" or A.S.S.

The session with Gerry Kirk and Michael Sahota was designed to create a knowledge base of methods and tools for doing agile readiness assessments. It was great to see ideas from other coaches and I look forward to the compiled results.

The conference party at Epcot was also a lot of fun and I enjoyed some non-agile time with my agile friends.