I got a problem when implementing IntegrationTest with Finatra on Scala. I'm just following their official docs for early implementation, but I got error
[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] ^
Here is my module
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
}
And here is my test suite
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]
...
}
If you want to look at the full source code, here it is https://github.com/hellowin/kanca-api/tree/try-module simply run sbt test
. For comparison, look at master
branch, which I don't implement DI yet and it works perfectly.
What's wrong with my implementation?
I've solve it, basically it's because of missing TestDependencies on
build.sbt
. I tried with this dependencies, and all went well.Here is my own PR https://github.com/hellowin/kanca-api/pull/3/files