Here's an example easyb scenario from the easyb website:
before "start selenium", {
given "selenium is up and running", {
selenium = new DefaultSelenium("localhost",
4444, "*firefox", "http://acme.racing.net/greport")
selenium.start()
}
}
scenario "a valid person has been entered", {
when "filling out the person form with a first and last name", {
selenium.open("http://acme.racing.net/greport/personracereport.html")
selenium.type("fname", "Britney")
selenium.type("lname", "Smith")
}
and "the submit link has been clicked", {
selenium.click("submit")
}
then "the report should have a list of races for that person", {
selenium.waitForPageToLoad("5000")
values = ["Mclean 1/2 Marathon", "Reston 5K", "Herndon 10K", "Leesburg 10K"]
for(i in 0..<values.size()){
selenium.getText("//table//tr[${(i+3)}]/td").shouldBeEqualTo values[i]
}
}
}
after "stop selenium" , {
then "selenium should be shutdown", {
selenium.stop()
}
}
Is it possible to separate the Groovy from the English, to present something more like this:
scenario "a valid person has been entered"
given "the website is running"
when "filling out the person form with a first and last name"
and "the submit link has been clicked"
then "the report should have a list of races for that person"
That way my PHB won't get all confused by the braces and Groovy.
Probably not with justifiable effort. Nevertheless, you can easily define the code closures externally. The "human readable" parts would then look like this:
scenario "a valid person has been entered", {
when "filling out the person form with a first and last name",
fillOutPersonForm
and "the submit link has been clicked",
clickSubmitLink
then "the report should have a list of races for that person",
checkRacesList
}
Make sure that the closure names are descriptive and self-documenting. Actually, I find them easier to read than the fully-written descriptions ...
The closure definitions were defined like that:
def fillOutPersonForm = {
selenium.open("http://acme.racing.net/greport/personracereport.html")
selenium.type("fname", "Britney")
selenium.type("lname", "Smith")
}