Thursday, July 9, 2009

Behavior driven development: Generating Groovy EasyB Story with Selenium IDE

I try to google selenium and easyb, I couldn't found format of Selenium IDE to generate easyb story. So, I decided to create one myself for automated testing of grails project.

Thanks to the post from David, Generating RSpec Tests with Selenium IDE the "Groovy - EasyB - Selenium RC" format is based on his code, easyb Story Example and Java - Selenium RC format come with Selenium IDE.

Download it. from here.
Install it. Open Selenium IDE, select "Options" menu - > "Options ..." menu item. Select "Formats" and click on "Add" button at the left bottom of the screen, you will see two fields, one tiny, one huge. In the tiny field, type "Groovy - EasyB - Selenium RC". In the huge field paste the entire contents of the downloaded file to it and click "OK" button.
Use it. After recorded a test case. Select "File" menu -> "Export Test Case As ..." menu item -> "Groovy - EasyB - Selenium RC" menu item. Please make sure you save the file name as *Story.groovy, for example SimpleGoogleStory.groovy. As easyb's story file name must end with Story.

If you make improvements to this file, please let me know. I’d like to benefit from them as well. Any feedback and suggestion of improvement to the "Groovy - EasyB - Selenium RC" format is welcome.

P/S: Along the way I learn easyb, I found out two important points that seems obvious but not easy for beginner to grasp (I suggest the webmaster of easyb.org website put these two statements in obvious location):
1) The easyb's story file name must be *Story.groovy or *.story and easyb's specification file name must be *Specification.groovy or *.specification. [More Infor]
2) When to use Story and when to use Specification?
Borrow a statement from Richard Vowles, "Guidelines from The RSpec Book, which says - test APIs with Specifications (as they are more like unit tests) and UI (e.g. controllers) with stories". [More Infor]