I looked at the sample code and documentation for astroboy for RoboGuice 2, and I'm honestly a dead end. Hope you can all help me to try. The goal here is to check the module to make sure it is loaded and that the IoC is working / connected.
I have a test similar to their example: http://code.google.com/p/roboguice/source/browse/astroboy/src/test/java/org/roboguice/astroboy/controller/Astroboy2Test.java?name= roboguice-2.0b3 & r = ba37ef680410c64f7f1fe90f5b7b482958d276b5
Mine differs in two ways ... My module is in a library class that is identical to the syntax:
public class MyTestModule extends AbstractModule { @Override protected void configure() { bind(Vibrator.class).toInstance(vibratorMock); } }
I also have roboguice.xml in the library class in the values ββfolder
<resources> <string-array name=roboguice_modules> <item>com.yourdomain.MyTestModule</item> </string-array> <resources>
The test project refers to the application project, which references and exports the library project.
In a test project, it looks like this:
@RunWith(RobolectricTestRunner.class) public class MyTest { @Before public void setup() {
During installation, errors always occur with some one exception. I violated this, and especially with the newDefaultRoboModule method. I know that Robolectric.application is not null, and I know that the new MyTestModule is also not null. Although when navigating through the debugger, I found that MyTestModule.binder is NULL, so I don't know if this was a problem.
error stack trace:
java.lang.NoClassDefFoundError: javax/inject/Provider at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at javassist.Loader.findClass(Loader.java:379) at com.xtremelabs.robolectric.bytecode.RobolectricClassLoader.findClass(RobolectricClassLoader.java:72) at javassist.Loader.loadClass(Loader.java:311) at java.lang.ClassLoader.loadClass(Unknown Source) at com.xtremelabs.robolectric.bytecode.RobolectricClassLoader.loadClass(RobolectricClassLoader.java:49) at roboguice.RoboGuice.newDefaultRoboModule(RoboGuice.java:144) at test.yourdomain.MyTest.setup(MyTest.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at com.xtremelabs.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:284) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.ClassNotFoundException: javax.inject.Provider at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at javassist.Loader.delegateToParent(Loader.java:428) at javassist.Loader.loadClassByDelegation(Loader.java:406) at javassist.Loader.loadClass(Loader.java:308) at java.lang.ClassLoader.loadClass(Unknown Source) at com.xtremelabs.robolectric.bytecode.RobolectricClassLoader.loadClass(RobolectricClassLoader.java:49) ... 36 more
Where else should I look? I feel lost because of how all this connects through testing.
Thanks for watching, Kelly