【发布时间】:2012-11-19 08:43:02
【问题描述】:
我正在尝试使用 Specs2 验收样式测试让我的测试按顺序执行,但我没有任何运气。
override def is = {
"Template Project REST Specification" ^
p ^
"The server should" ^
"Respond with greeting on root path" ! serverRunning ^
p ^
"For CLIENT json objects" ^
"Return an empty list if there are no entities" ! getEmptyClientList ^
"Create a new entity" ! createClient ^
"Return a non-empty list if there some entities" ! getNonEmptyClientList ^
"Read existing" ! todo ^
"Update existing" ! todo ^
"Delete existing" ! todo ^
"Handle missing fields" ! todo ^
"Handle invalid fields" ! todo ^
"Return error if the entity does not exist" ! todo ^
end
}
运行测试时,createClient 测试会在getEmptyClientList 测试有机会执行之前不断创建新的客户端元素。
如果我在createClient 测试之前添加一整堆getEmptyClientList 测试,那么除了最后一个之外的所有测试都将在调用createClient 之前执行。但是createClient 总是会击败最后一个getEmptyClientList 调用,这会导致它失败。
如何强制它按顺序执行?使用 Specs2 单元测试风格,我只是在测试前添加了 sequential 关键字,一切都会好起来的。
【问题讨论】: