zorzella / guiceberry

Leverage Guice to achieve Dependency Injection on your JUnit tests
Apache License 2.0
28 stars 13 forks source link

Guiceberry 3.0.2 throws: No implementation for com.google.common.testing.TearDownAccepter was bound. #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
For me, I have a GuiceBerryEnv module with an empty configuration, that I use 
to annotate a test case.

@GuiceBerryEnv(FooGuiceBerryEnv.NAME)
public class Foo extends TestCase {
   @Inject
   private SomeClass sc;

   protected void setUp() {
      super.setUp();

      GuiceBerryJunit3.setUp(this);
   }
}

This code throws: 
Binding error in the GuiceBerry Env 
'com.foo.bar.testing.guiceberry.BarGenGuiceBerryEnv': 'Guice configuration 
errors:

1) No implementation for com.foo.common.testing.TearDownAccepter was bound.
  while locating com.foo.common.testing.TearDownAccepter

1 error'.
    at com.foo.guiceberry.GuiceBerryUniverse$TestCaseScaffolding.wrappedGetInstance(GuiceBerryUniverse.java:130)
    at com.foo.guiceberry.GuiceBerryUniverse$TestCaseScaffolding.runBeforeTest(GuiceBerryUniverse.java:101)
    at com.foo.inject.testing.guiceberry.junit3.GuiceBerryJunit3.doSetUp(GuiceBerryJunit3.java:155)
    at com.foo.inject.testing.guiceberry.junit3.GuiceBerryJunit3.setUp(GuiceBerryJunit3.java:136)

What version of the product are you using? On what operating system?
3.0.2 on linux.

This code works fine on 2.9

Original issue reported on code.google.com by mschein5...@gmail.com on 2 Sep 2010 at 6:20

GoogleCodeExporter commented 9 years ago
Will you paste here the BarGenGuiceBerryEnv.java class itself?

Original comment by zorze...@gmail.com on 2 Sep 2010 at 6:30

GoogleCodeExporter commented 9 years ago
I strongly suspect you are not installing the required GuiceBerryModule (or its 
old incarnation, BasicJunit3Module). That being the case, the error message is 
lousy (I'll fix that), but you do need to install it...

Original comment by zorze...@gmail.com on 2 Sep 2010 at 6:41

GoogleCodeExporter commented 9 years ago

public class BarGuiceBerryEnv extends GuiceBerryJunit3Env {
  public static final String NAME =
      "com.foo.testing.guiceberry.BarGuiceBerryEnv";

  @Override
  protected void configure() {
    install(override(new FooTwoModule()).with(new MockFooTwoModule()));
    bind(FakeClock.class).asEagerSingleton();
    bind(Clock.class).to(FakeClock.class);
    install(new TemplateServicesModule());
    install(new BareratorModule());
    install(new SampleBarerationModule());
  }
}

So, I don't have the GuiceBerryModule, but I do extend GuiceBerryJunit3Env.

Original comment by mschein5...@gmail.com on 2 Sep 2010 at 8:26

GoogleCodeExporter commented 9 years ago
You want to call

super.configure();

at the beginning of your configure.

Original comment by zorze...@gmail.com on 7 Sep 2010 at 4:44

GoogleCodeExporter commented 9 years ago
Ok, I'll try that.  Thanks :-).

Original comment by mschein5...@gmail.com on 7 Sep 2010 at 5:57

GoogleCodeExporter commented 9 years ago
The issue itself was invalid, but it brought to my attention the lack of a 
helpful error message, which is addressed by:

http://code.google.com/p/guiceberry/source/detail?r=259

Original comment by zorze...@gmail.com on 3 Nov 2010 at 12:08

GoogleCodeExporter commented 9 years ago
all looks good, Z.

Original comment by ffa...@google.com on 3 Nov 2010 at 1:22