2012-11-19 2 views
1

를 사용하여 주문하십시오. 테스트 문자열이 너무 오래했기 때문에 지정 시험 specs2 (스칼라/플레이 프레임 워크)를 Specs2 라이브러리를 사용하여 스칼라 재생 응용 프로그램 나는 현재 일련의 테스트를 쓰고 있어요

나는 컴파일 과정에서 일부 스택 오버플로 오류가 있었다, 그래서 나는 여러 클래스로 분할했습니다.

문제는 검사가 동시에 멀티 스레드 프로세스를 사용하여 실행된다는 것이다. 그 테스트의 순서를 지정해야합니다. 이것을 할 수있는 방법이 있습니까? 문안 인사.

+0

에 유래에 오신 것을 환영합니다. 코드의 관련 부분만큼 시도한 것을 게시 할 것을 고려하십시오. 그렇지 않으면 아무도 당신을 도울 수 없을 것입니다 –

답변

5

당신은 시험이 사양에 sequential을 추가하여 순차적으로 실행해야 함을 지정할 수 있습니다. 당신이 단위 스타일의 테스트를 사용하는 경우

, 당신의 검사 결과 위의 라인 (examples borrowed from specs docs을) 문 sequential을 넣어 : 당신이 수용 스타일의 테스트를 사용하는 경우, 단지 is

의 정의 내에서 순차적를 추가

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") 
     } 
    } 
    } 

보조 노트으로

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") 
    } 

, 당신은 아마보다는 소프트웨어에 오류에서 스택 오버플로 오류를 얻고있다 테스트가 너무 길다.

+0

고마워요! 그것은 완벽하게 작동, 그리고 수출 _JAVA_OPTIONS의 =으로 유래의 preblem를 해결하기 위해 성공 "- Xss4m을" 건배! – tbronchain

+0

듣기 좋고 스레드 스택 크기에 대해 알려 주셔서 감사합니다. http://stackoverflow.com/q/4967885/828757 – Jack

+0

그래서 테스트가 순차적으로 실행되도록하는 방법이 있습니다. 고마워. –

0
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) 

당신을 도울 수 있습니다!