我目前正在使用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。考慮只要您的代碼的相關部分發布您嘗試過的內容。否則沒有人能夠幫助你 –