2017-01-08 33 views
1

我有一個簡單的Scala 2.11.8 + ScalaTest 3.0.1 + SBT項目。使用ScalaTest運行單個測試套件

我想運行一個單獨的ScalaTest Suite類。我創建了一個簡單的例子,測試套件org.example.TestSuite

package org.example 

import org.scalatest.FunSuite 

class TestSuite extends FunSuite { 
    test("just a simple example test") { 
    assert(1 + 1 === 2) 
    } 
} 

我可以脫離的IntelliJ完全正常運行。

當我試圖孤立在命令行中運行以下命令:

sbt test-only org.example.TestSuite 

運行所有的我的測試。

我看這裏的文檔:http://www.scalatest.org/user_guide/using_scalatest_with_sbt

它說做的正是我在做什麼,test運行一切,而test-only <qualified suite class names>道僅有指定套房。但是,它只是不工作。

這似乎非常簡單,但它只是不工作和運行所有測試。謝謝!

回答

1

在命令行中,SBT將命令與參數,如您通過封閉的命令和參數引號:

sbt 'test-only org.example.TestSuite' 

如果輸入SBT的命令行,那麼你並不需要指定引號和公正的運行命令,如:

$ sbt 
> test-only org.example.TestSuite 

注意,這最後一個例子是在您發佈的文檔鏈接的例子是如何打算使用。

請注意,在最近的SBT versions such as 0.13中,命令調用更改爲testOnly

相關問題