0

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?

ausan
  • 76
  • 2
  • 7

2 Answers2

1

After a long time, I accidentally found a solution. The tests run fine in debug mode if I disable instant run in Android Studio. (File -> Settings -> Build, Execution, Deployment -> Instant Run, uncheck "enable instant run").

ausan
  • 76
  • 2
  • 7
  • 1
    Nice but [disabling native-code debug](https://stackoverflow.com/a/63399650/8740349) was the fix for me ;-) – Top-Master Aug 13 '20 at 16:48
0

In my case (as mentioned in another post) the fix was to:

  1. Open Edit Configuration... for All tests (or what ever you renamed it into).
  2. Switch to Debugger tab.
  3. In Debug mode combo, select the Java option:
    • Although we have lots of Native codes, lets try to not debug them while we debug our Integration-tests ;-)

Note: We use Android-studio 3.2.1 and above might not be required in newer versions.

Top-Master
  • 5,262
  • 5
  • 23
  • 45