2013-12-17 30 views
0

我想共享數據庫/知識庫,以進行一組測試。我希望它可以用於任何測試套件。我正在使用featureSpecfixture.FeatureSpec/withFixture(OneArgTest)問題

繼文檔之後,我使用了fixture.FeatureSpec。

截至目前我已經定義如下:

trait InteractionKbFixtureTrait { this: fixture.Suite => 

type FixtureParam = InteractionKB 

def withFixture(test: OneArgTest): Unit = { 

    val kb = KbFactory.createKb("", "") // create the fixture 

    try { 

    this.withFixture(test.toNoArgTest(kb)) // "loan" the fixture to the test 

    } finally { 

//kb.stop() // clean up the fixture 

} 

} 

}其次

class ExampleSpec extends fixture.FeatureSpec with InteractionKbFixtureTrait { 


} 

我收到以下錯誤

:在特質

類型覆蓋方法withFixture套件類型(測試:ExampleSpec.this.OneArgTest)org.scalatest.Outcome; 方法與性質InteractionKbFixtureTrait類型(測試:ExampleSpec.this.OneArgTest)單位具有不兼容類型InteractionKbFixtureTrait.scala

任何幫助嗎?

回答

1

方法def withFixture應該返回類型org.scalatest.Outcome,而您的def withFixture返回Unit。錯誤消息說得很清楚。

因此,對於固定它您需要更改行:

def withFixture(test: OneArgTest): Unit = { 

像這樣:

def withFixture(test: OneArgTest): org.scalatest.Outcome = {