How to run individual test method in Android Studio v0.5.2

By : Dan J
Source: Stackoverflow.com
Question!

In Android Studio v0.4.2 I was able to right click on individual methods within my test classes and run a single automated test. After updating to v0.5.2 I can't do that any more.

When I upgraded to v0.5.2, it automatically updated me to the v0.9 Gradle plugin. I had to follow the migration instructions, which included renaming "instrumentTest" to "androidTest".

Before this update, I was able to right click on individual methods within a test class and run them individually. After the update, the default option is to Run 'MyProject - App Engine DevAppServer, which doesn't apply to my project, so it doesn't run the test.

run individual test method

Does anybody know how to change that default so my tests run individually? Some of my tests extend the simple JUnit TestCase, but most of them extend AndroidTestCase. At the moment both are treated as App Engine tests.

Right clicking and running an entire test class still works completely fine.

run test class

I'm running Mac OS X 10.9.2.

By : Dan J


Answers

Try updating to Android Studio v0.5.8 (or greater - I'm now seeing that v0.5.9 is available for download) via "Help->Check for update".

I can right-click and run an individual test method within a class on Android Studio v0.5.8 on Windows 7 Enterprise 64bit:

enter image description here

The above class is from the OneBusAway Android project on Github, if you want to try with this project and eliminate your project/source as the cause of the issue.

Here are my full Android Studio / JDK details:

enter image description here



This video can help you solving your question :)
By: admin