Iaroslav Baranov
Iaroslav Baranov

Reputation: 1120

Run UiAutomator API from Android Studio (v0.8)

When I work with tests - I add class in special module and run test configuration. Class extend (for example) TestCase and work well.

But when I extend UiAutomatorTestCase - I get error

java.lang.RuntimeException: Stub!
    at com.android.uiautomator.testrunner.UiAutomatorTestCase.<init>  (UiAutomatorTestCase.java:5) ...

My simple class:

import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class AutoTest extends UiAutomatorTestCase {
    public void testSome() throws UiObjectNotFoundException {
        getUiDevice().pressHome();
    }
}

How to run it in Android Studio IDE?

Upvotes: 4

Views: 4171

Answers (1)

Tim Boland
Tim Boland

Reputation: 1972

Well, if you'd be interested in giving it another try....I was able to get a UIAutomator project started in Android Studio with the following [Github project] (https://github.com/wiliamsouza/bluetooth)

  1. Clone the project locally.
  2. Edit the gradle.properties file to point to your sdk, target and build tools
  3. Import into Android Studio, if prompted be sure to select Gradle.

The accompanying [blog post] (http://wiliamsouza.github.io/#/2013/10/30/android-uiautomator-gradle-build-system) has more details.

I modified with my own test cases and is working well.

Upvotes: 2

Related Questions