Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
956 views
in Technique[技术] by (71.8m points)

java - Unit tests terminated in Debug mode

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...