9

I'm using IntelliJ IDEA 15.0.2 (Community Edition) under Windows 7 and Windows 10 Pro, Gradle 2.9, JDK 1.7.0_65. Operating systems installed as guests under VMware Workstation 11.1.3

I have created Android Gradle application with single empty activity and wanted to check how unit test support works. There is a single unit test module ApplicationTest.java created by IDE, it contains only constructor. Right-clicking on [java] folder I created 'All in Module' JUnit3 test configuration.

Tests complete successfully when I Run them, however fail if I Debug the configuration. Failure reason says 'Terminated' (screenshot, IDEA log) which explained in the documentation as 'Test terminated. This status is assigned to tests that were cancelled by clicking the Stop button'. Just want to confirm that I didn't click the Stop button.

Logcat logs don't report any failures, IDE log reports 2 tests passed too. However problem remains as IntelliJ still reports a termination.

Sometimes I also getting 'Test framework quit unexpectedly' error and no tests succeed.

I've done some research and found similar questions, no real solutions mentioned. Have strong suspicion that this is a configuration issue.

What do I do wrong?

Andriy
  • 707
  • 1
  • 7
  • 16

4 Answers4

2

In my company's case, the fix was to:

  1. Open Edit Configuration... for All tests (or whatever you renamed it into).
  2. Switch to Debugger tab.
  3. And finally, in Debug mode combo-box, select the Java option, because:
    • Although we have lots of Native codes, Android-studio 3.2.1 (which we were using) does not seem to support debugging both (but Java only mode works fine).

Note that we've seen above since Android-studio 3.2.1 until Android-studio 2022.x, but above might not be required in some newer version.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
  • Bro I am dealing with this issue for hours. I thought the crash is because of memory related. So I changed VM options, did many changes to increase memory usage. Found out that it wasn't the reason. Your suggestion just saved me. Thank you!!! – Burak Jun 06 '23 at 16:22
0

Gabor's suggestion seemed to fix this issue for me. On a Mac (and I presume on a Windows machine, but with a different route to get there) go to Preferences:

From the menu bar at the top Android Studio → Preferences

or

Hit ⌘ and , to jump straight to it.

Then in the menu search box type "instant". Uncheck the box that says "Enable instant run..", which looks like the image below.

enter image description here

That fixed it for me; didn't even need to restart/kill ADB.

It seems to be enabled by default, and I use it often to hot-swap changes during development, so I didn't think to turn it off when running Espresso tests.

MattMatt
  • 2,242
  • 33
  • 30
  • 2
    I'm not sure about corresponding option in Android Studio under Windows OS, however original question was about **IntelliJ IDEA**, which does not have "Instant Run" switch – Andriy Feb 07 '16 at 20:11
0

In my situation, the problem is solved by setting in the test's run configuration: Shorten command line -> JAR manifest.

Fox
  • 417
  • 4
  • 13
-1

To get rid of unit test problems in debug mode, I deleted all test folders in android studio explorer, then I commented three test implementation lines in build.gradle(module) file. Then I changed the combobox in android studio menu (top of the IDE) from "all in app" to "app".

https://i.stack.imgur.com/alPrS.png

  • Thank you for suggestion. Please note that original question was about IntelliJ IDEA, so this solution is not applicable – Andriy Mar 31 '19 at 19:57