I just created Roboelectric 3.2.2 with a new application, and I wrote my first simple test:
@RunWith(RobolectricTestRunner.class) @Config(manifest="src/main/AndroidManifest.xml", packageName="my.pacakge.name.debug") public class MainActivityTest { @Test public void clickButton() { MainActivity mainActivity = Robolectric.setupActivity(MainActivity.class); String text = ((TextView)mainActivity.findViewById(R.id.text_main)).getText().toString(); assertEquals("Should equal Hello World!", "Hello World!", text); } }
I followed all the settings and instructions here and here , but I still get this error every time I try to run a test:
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x0 in packages [android, my.package.name.debug]
This exception occurs in the first line of the test, where I call setupActivity() .
android android-studio robolectric robolectric-gradle-plugin
uncle_tex
source share