gpt4 book ai didi

testing - 是否可以将 easyb 的 Groovy 与简单的英语场景定义分开?

转载 作者:行者123 更新时间:2023-11-28 21:06:20 24 4
gpt4 key购买 nike

这是来自 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 弄糊涂了。

最佳答案

可能没有合理的努力。不过,您可以轻松地在外部定义代码闭包。 “人类可读”部分将如下所示:

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
}

确保闭包名称是描述性的和 self 记录的。实际上,我发现它们比完整的描述更容易阅读......

闭包定义是这样定义的:

def fillOutPersonForm = {
selenium.open("http://acme.racing.net/greport/personracereport.html")
selenium.type("fname", "Britney")
selenium.type("lname", "Smith")
}

关于testing - 是否可以将 easyb 的 Groovy 与简单的英语场景定义分开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4224168/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com