Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminated test status without any failure message in Android Studio 2.0 while unit testing

Issue:

I upgraded to Android Studio 2.0 from 1.5 yesterday on Ubuntu. When I unit-test in Android Studio 2.0, it shows Terminated test status even though all tests are passed. Sometimes it shows only some of the tests passed. I'm pretty sure my code is working and tests are correct, because I had same setup on Android Studio 1.5.

For example I have 22 tests. Sometimes it shows all 22 tests passed, on the next run it shows 21 of 22 tests passed, sometimes Stopped. 20 of 22 tests passed, other times it shows all 20 tests passed even though I have 22 test. It all happens randomly. No failure message is shown.

Tried solutions so far:

I found an answer about Android studio on a similar IntelliJ issue that turning off Instant Run to Hot Swap resolves the issue. But that didn't solve the problem.

I tried running tests in Android Studio 1.5 but no problems.

Has anyone encountered any such issues in Android Studio 2.0, did you find any fix for this? Any help is much appreciated. Thanks!

like image 622
Yogesh Umesh Vaity Avatar asked Apr 11 '16 16:04

Yogesh Umesh Vaity


People also ask

Why do you use the Android Junitrunner when running UL tests?

When you use AndroidJUnitRunner to run your tests, you can access the context for the app under test by calling the static ApplicationProvider. getApplicationContext() method. If you've created a custom subclass of Application in your app, this method returns your custom subclass's context.

What is Robolectric?

Robolectric is a framework that allows you to write unit tests and run them on a desktop JVM while still using Android API. Robolectric provides a JVM compliant version of the android. jar file.

How do I run unit test on Android?

To run all tests in a class or a specific method, open the test file in the Code Editor and do either of the following: Press the Run test icon in the gutter. Right-click on the test class or method and click Run . Select the test class or method and use shortcut Control+Shift+R .


2 Answers

This sounds like a known bug. The description on the bug report does not indicate some test not being run occasionally though.[1] I am running into similar issues but all the tests are run.

There seems to be a fix on the way probably in Android Studio 2.1.

[1] https://code.google.com/p/android/issues/detail?id=201968

like image 77
iisulop Avatar answered Oct 01 '22 10:10

iisulop


I would like to confirm that Android Studio 2.1 has been released. I just updated to Android Studio 2.1 and Android Gradle plugin 2.1.0 and this issue has been fixed.

like image 34
Yogesh Umesh Vaity Avatar answered Oct 01 '22 11:10

Yogesh Umesh Vaity