クラスをテストしようとしています
@Singleton
class Foo @Inject()(bar: Bar)(implicit ec: ExecutionContext) {
def doSomething = bar.doSomethingInBar
}
class Bar {
def doSomethingInBar = true
}
Specification
下記のクラスを通して
class FooTest @Inject()(foo: Foo) extends Specification {
"foo" should {
"bar" in {
foo.doSomething mustEqual (true)
}
}
}
これを実行すると、次のエラーが表示されます
Can't find a constructor for class Foo
ここに記載されている解決策に従いました
そして定義されたInjector
object Inject {
lazy val injector = Guice.createInjector()
def apply[T <: AnyRef](implicit m: ClassTag[T]): T =
injector.getInstance(m.runtimeClass).asInstanceOf[T]
}
そしてlazy val foo: Foo = Inject[Foo]
私の仕様クラスの中に。コンストラクターの初期化の問題は解決しますが、現在このエラーが発生しています。
[error] ! check the calculate assets function
[error] Guice configuration errors:
[error]
[error] 1) No implementation for scala.concurrent.ExecutionContext was bound.
[error] while locating scala.concurrent.ExecutionContext