56

In order to run Instrumentation Tests from within Android Studio, I typically select "Android Instrumentation Tests" as the test artifact to be built, via the Build Variants window. I recently upgraded to Android Studio 2 Beta 5, and the "Test Artifact" selector is no longer visible. Where did it go? Has some other configuration taken its place?

Mark McClelland
  • 4,980
  • 4
  • 35
  • 48

3 Answers3

85

I discovered this in the release notes for Android Studio 2.0 Preview 5: "The experimental test artifacts feature (where both unit test and instrumentation tests are enabled simultaneously in the IDE) has been improved further and is now enabled by default."

To disable the simultaneous building of unit and instrumentation tests, go here: File Menu -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Experimental. Then uncheck this: "Enable all test artifacts (Unit Test and Instrumentation Test) in Android projects".

Rather than navigate through Settings, you can also use the search box at the top of the Settings dialog, and just search for "instrumentation".

Mark McClelland
  • 4,980
  • 4
  • 35
  • 48
  • .. Thank you .. this was doing my head in! – Mark Apr 10 '16 at 14:11
  • 9
    On Mac: Goto Android Studio -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Experimental. – karma Apr 18 '16 at 22:00
  • Well, they haven't updated this page http://tools.android.com/tech-docs/unit-testing-support. Still has the old info. – likejudo Jun 04 '16 at 22:39
  • 11
    I do not see this option in android studio 2.2 preview 5 – ocross Jul 14 '16 at 21:29
  • I can't find any reference to the change in release notes, but it appears that unit tests and instrumentation tests are now enabled simultaneously, with no option to disable this feature. I haven't done enough testing to tell whether this results in any significant increase in build times, but I could see it being a usability setback for certain projects. – Mark McClelland Sep 27 '16 at 20:52
  • Well, I've tried all the variations from several of these threads for Android Studio 2.3, and I'm calling it quits for now - I'll trying running the unit tests from a completely separate continuous integration process. I know this is pure whinge, but I really _hate_ Gradle. And Maven. The dependency injection is magic, but the build process is poor, and the syntax is horrible. Would love to get Ant back some day - verbose, but at least I can see everything that's happening. – WillC Apr 07 '17 at 07:00
  • OK - whinge over: module --> `build.gradle` --> `dependencies{ ... testCompile 'junit:junit:4.12' }` works for me if I remove the JUnit annotations and rename my test methods as `testX`, `testY` etc. – WillC Apr 07 '17 at 07:39
5

From what I see, in Android Studio 2.3.3, this option is gone 4 ever.

@markproxy: this because that feature is no longer experimental but is embedded in Android Studio as a feature, and there is no need to disable it, I suppose.

enter image description here

Here, for anyone needs, a link to the Android Unit Test guide: Getting Started with Testing (Instrumented Unit Tests included)

ingitaly
  • 131
  • 1
  • 3
  • 5
4

Just as @markproxy said there is no "Test artifact" with "Android Instrumentation Tests" to select from. This window looked like this in Android Studio 1.5x releasesenter image description here