I am trying to incorporate ScalaTest into my Java project by replacing all JUnit ScalaTests tests. At some point I want to check if Guice Injector is entering the correct type. In Java, I have a test like this:
public class InjectorBehaviour { @Test public void shouldInjectCorrectTypes() { Injector injector = Guice.createInjector(new ModuleImpl()); House house = injector.getInstance(House.class); assertTrue(house.door() instanceof WoodenDoor); assertTrue(house.window() instanceof BambooWindow); assertTrue(house.roof() instanceof SlateRoof); } }
But I have a problem with the same as with ScalaTest:
class InjectorSpec extends Spec { describe("An injector") { it("should inject the correct types") { val injector = Guice.createInjector(new ModuleImpl) val house = injector.getInstance(classOf[House]) assert(house.door instanceof WoodenDoor) assert(house.window instanceof BambooWindow) assert(house.roof instanceof SlateRoof) } } }
He complains that the value of instanceof is not a member of Door / Window / Roof. Can't I use instanceof this way in Scala?
java scala junit scalatest
helpermethod Dec 19 '11 at 13:16 2011-12-19 13:16
source share