Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Add support for Spoon in Android test modules #106

Open
patrickhammond opened this issue May 11, 2016 · 2 comments
Open

Add support for Spoon in Android test modules #106

patrickhammond opened this issue May 11, 2016 · 2 comments

Comments

@patrickhammond
Copy link

I am trying to include Spoon in an Android test module (https://developer.android.com/tools/studio/studio-features.html#test-module), but it looks like that plugin type is not supported yet (https://github.com/stanfy/spoon-gradle-plugin/blob/master/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy#L23).

patrickhammond pushed a commit to atomicrobot/Carbon-Android that referenced this issue May 11, 2016
This doesn't work yet (can't find tests), Spoon support doesn't exist yet stanfy/spoon-gradle-plugin#106), and IDE support doesn't exist yet (https://code.google.com/p/android/issues/detail?id=201081).
@roman-mazur
Copy link
Contributor

Correct. This plugin use case is putting tests into the app module under `src/androidTest/. What you can do is configuring spoon task on your own in your test module: add the plugin artifact to the build script classpath (but do not apply it) and then do something like

import com.stanfy.spoon.gradle.SpoonRunTask
android.applicationVariants.all { variant ->
  task "spoon${variant.name.capitalize()}"(type: SpoonRunTask) {
    testSize = SpoonRunTask.TEST_SIZE_ALL
    applicationApk = variant.outputs[0].outputFile
    instrumentationApk = variant.outputs[0].outputFile
    // ... See other options https://github.com/stanfy/spoon-gradle-plugin/blob/master/src/main/groovy/com/stanfy/spoon/gradle/SpoonRunTask.groovy#L33-L90
  }
}

Or you can add another plugin to this project that can be applied to test modules.

@flyguy4444
Copy link

Hi Roman. I'm in a similar position as patrick. I have an Android library project that has about 5 different modules in it, each with their own set of unit tests. I would love to use spoon as it let's me use multiple devices and is great for granting runtime permissions for the tests.

This would be a great feature to have! But for now, I'm looking at the sample code you provided above. I'm pretty new with gradle, so I was hoping you could expand upon your sample code and maybe explain how I could get something working. For example: Not sure what you mean by "adding plugin artifact to the buildscript classpath (but do not apply it)." Also would I add that task to each of my module level build.gradle files? Or top level? My project doesn't use flavors or variants.

Sorry I'm a gradle noob, but I would love to get Spoon working so any help is appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants