这是来自 easyb 网站的示例 easyb 场景:
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()
}
}
是否可以将 Groovy 与英语分开,以呈现更像这样的内容:
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"
这样我的 PHB 就不会被大括号和 Groovy 搞糊涂了。