jeudi 8 mars 2018

Instrumentation tests crash in debug mode in Android Studio

I have some tests in my Android project. I run them in Android Studio (using "run" button, not command line) and everything is fine - so I guess configuration is correct. When I try to debug them (again, using "debug" button instead of run), it crashes with "Test framework quit unexpectedly" (after showing "Instantiating tests". No other error messages in console or in logcat. It happens both on a real device and emulator, and only in debug mode.

My tests look like this:

@RunWith(AndroidJUnit4.class)
public class InformationTest extends AbstractServiceTest {

@Test
public void testCopyResource(String resourceName, File destination) throws IOException {
        try (InputStream inputStream = getClass().getResourceAsStream(resourceName)) {
            FileUtils.copyInputStreamToFile(inputStream, destination);
        }
    }
}

I have tried to invalidate caches / restart, I do have testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" in build.gradle (found these suggestion for people who weren't able to even run the tests). Anything else I am missing?

Aucun commentaire:

Enregistrer un commentaire