ScalaでFinatraとIntegrationTestを実装する際に問題が発生しました。私はちょうど早期実施のために彼らの公式ドキュメントを以下だが、私はここでエラーFinatra IntegrationTestが "object TwitterModuleがcom.twitter.injectパッケージのメンバーではありません"
[error] D:\Workspace\OpenSource\kanca-api\src\test\scala\io\kanca\GraphTestModule.scala:4:8: object TwitterModule is not a member of package com.twitter.inject
[error] import com.twitter.inject.TwitterModule
[error] ^
[error] D:\Workspace\OpenSource\kanca-api\src\test\scala\io\kanca\GraphTestModule.scala:7:32: not found: type TwitterModule
[error] object GraphTestModule extends TwitterModule {
[error] ^
を得たことは、私のモジュールであり、必要であれば
import com.google.inject.{Provides, Singleton}
import com.twitter.inject.TwitterModule
import io.kanca.fbgraph.Graph
object GraphTestModule extends TwitterModule {
@Singleton
@Provides
def providesGraph: Graph = new Graph
}
そしてここでは、私のテストスイート
import com.twitter.inject.IntegrationTest
import com.twitter.inject.app.TestInjector
class MySQLSpec extends IntegrationTest {
def injector =
TestInjector(
modules =
Seq(GraphTestModule))
.create
val graph = injector.instance[Graph]
...
}
です完全なソースコードを見るには、ここではhttps://github.com/hellowin/kanca-api/tree/try-moduleはsbt test
を実行するだけです。比較のため、まだDIを実装していないmaster
ブランチを見てください。完全に動作します。
私の実装で何が問題になっていますか?