我目前正在使用Specs2库为Scala Play应用程序编写一组测试。使用specs2(scala/play框架)指定测试订单
我在编译过程中发生了一些堆栈溢出错误,因为测试字符串太长,所以我把它分成了几个类。
问题是测试使用多线程进程同时运行。我需要指定这些测试的顺序。有没有办法做到这一点?问候。
我目前正在使用Specs2库为Scala Play应用程序编写一组测试。使用specs2(scala/play框架)指定测试订单
我在编译过程中发生了一些堆栈溢出错误,因为测试字符串太长,所以我把它分成了几个类。
问题是测试使用多线程进程同时运行。我需要指定这些测试的顺序。有没有办法做到这一点?问候。
您可以指定测试必须按顺序执行,将sequential
添加到您的规范中。
如果您使用的单元式的测试,把声明sequential
在你上面的测试线(examples borrowed from specs docs):
import org.specs2.mutable._
class HelloWorldSpec extends Specification {
sequential
"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
}
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
}
"end with 'world'" in {
"Hello world" must endWith("world")
}
}
}
如果您正在使用验收风格测试,只是添加的is
import org.specs2._
class HelloWorldSpec extends Specification { def is =
sequential ^
"This is a specification to check the 'Hello world' string" ^
p^
"The 'Hello world' string should" ^
"contain 11 characters" ! e1^
"start with 'Hello'" ! e2^
"end with 'world'" ! e3^
end
def e1 = "Hello world" must have size(11)
def e2 = "Hello world" must startWith("Hello")
def e3 = "Hello world" must endWith("world")
}
作为一个侧面说明,你可能得到的堆栈溢出错误,从错误中你的软件,而不是测试时间太长。
谢谢!这完美的作品,我成功地解决了出口的计算器_JAVA_OPTIONS =“ - Xss4m” 干杯! – tbronchain
非常感谢,并感谢您了解线程堆栈大小。更多在这里:http://stackoverflow.com/q/4967885/828757 – Jack
所以* *是一种使测试顺序执行的方法。感谢那。 –
class UsersSpec extends Specification with BeforeAll with Before {
def is = sequential^s2"""
We can create in the database
create a user $create
list all users $list
"""
import DB._
def create = {
val id = db.createUser("me")
db.getUser(id).name must_== "me"
}
def list = {
List("me", "you").foreach(db.createUser)
db.listAllUsers.map(_.name).toSet must_== Set("me", "you")
}
// create a database before running anything
def beforeAll = createDatabase(databaseUrl)
// remove all data before running an example
def before = cleanDatabase(databaseUrl)
它可以帮助你!
欢迎使用stackoverflow。考虑只要您的代码的相关部分发布您尝试过的内容。否则没有人能够帮助你 –