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?
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.
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.
In my situation, the problem is solved by setting in the test's run configuration: Shorten command line -> JAR manifest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With