Question

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.

Was it helpful?

Solution

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")
}

OTHER TIPS

Actually, I believe this is already a feature of easyb via the ANT integration. Check out http://www.easyb.org/running.html, under the section "Story Printing".

As an extension of SJG's answer here is a code snippet to do this programmatically.

The easyb documentation at http://www.easyb.org/running.html only describes how create the 'Story' text view from the command line. It's a simple task to do this with Groovy code...

import org.easyb.BehaviorRunner

def params=["C:/temp/teststory.story", "-txtstory", "C:/temp/testoutput.html"] as String[]
BehaviorRunner.main(params)

You can use a similar approach for the HTML reporting and XML reporting using -html or -xml as the 2nd parameter.

I'm still not sure which parameters are required so that just the reports are created without running the tests. This should be possible, see issue 165 fixed It would be nice to add this as the last part of a story so that the 'user' documentation is always created, the snippet above causes the tests to be executed so can't be included in the same story file otherwise it would get into a recursive loop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top