Eugene
Eugene

Reputation: 60184

Run tests from Android Studio but terminal

I'm using decard-gradle to run my junit tests in Android Studio.

It's all fine if you run tests from terminal, i.e. ./gradlew clean test, but if you want to debug during your tests execution you need to run them from IDE (Android Studio in my case).

In order to debug you need to add a new Gradle configuration in your Run/Debug Configurations - clean test - and if you want the only one test class to execute then you create a JUnit configuration where you put 'launch another configuration' and specify gradle conf you created in prev step.

Sometimes I can see a list of tests within my test class with results, sometimes - not. I experimented a lot but didn't find a way how to make them always show. That's not really about debbuging only, this also applies to simple test run - sometimes you can see a list of tests, sometimes - not.

Configuration: Android Studio 0.8.14 gradle-2.1 'com.android.tools.build:gradle:0.13.2'

Upvotes: 0

Views: 837

Answers (1)

nenick
nenick

Reputation: 7438

When i understood correct, then you like to run single tests in Android Studio. I can tell you different ways:

  1. Use Intellij with Android Plugin, thats the way supported by deckard-gradle.
  2. The robolectric-gradle-plugin "support" run tests in Android Studio it but need much manual effort also explained here at the last "obsolete" part https://github.com/nenick/android-gradle-template/wiki/Tests-in-Android-Studio---IntellJ
  3. Switch robolectric support plugin https://github.com/novoda/gradle-android-test-plugin and here is a "deckard project" https://github.com/nenick/android-gradle-template/tree/novoda
  4. Switch robolectric support plugin https://github.com/JCAndKSolutions/android-unit-test which his extra created Android Studio plugin. It contains a sample and you can also find a sample here https://github.com/nenick/android-gradle-template

Upvotes: 1

Related Questions