Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
Created February 16, 2018 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakatsuka/01fcb4f1f07889f9b2999b73bd79663b to your computer and use it in GitHub Desktop.
Save dakatsuka/01fcb4f1f07889f9b2999b73bd79663b to your computer and use it in GitHub Desktop.
trait Foo {
def execute(): Unit
}
object Foo extends Foo {
def execute(): Unit = println("foo")
}
trait Bar {
val foo: Foo = Foo
}
object Main extends App {
object FooMock extends Foo {
def execute(): Unit = println("mock dayo")
}
val bar = new Bar {
override val foo: Foo = FooMock // Mockに差し替え
}
bar.foo.execute()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment