• This repository has been archived on 18/Nov/2021
  • Stars
    star
    353
  • Rank 120,322 (Top 3 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle plugin for Spoon.

Spoon Gradle Plugin

Gradle plugin for Spoon. Allows you to run spoon with almost no effort under new Android build system.

Build Status

Plugin generates spoon${TEST_VARIANT} tasks for every test variation in your application project.

Usage

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
  }
}

apply plugin: 'spoon'

// This section is optional
spoon {
  // for debug output
  debug = true

  // To run a single test class
  className = 'fully.qualified.TestCase'

  // To run a single method in TestCase
  methodName = 'testMyApp'

  // To execute the tests device by device */
  sequential = true

  // To grant permissions to Android M >= devices */
  grantAllPermissions = true
}

After applying the plugin you'll find spoon${TEST_VARIANT} tasks in your project.

You may run all the test variations with

gradle spoon

Generated reports are available at build/spoon/${TEST_VARIANT} folder.

For making screenshots add spoon-client dependency to your tests compile configuration:

dependencies {
  androidTestCompile 'com.squareup.spoon:spoon-client:1.6.4'
}

By default the plugin runs tests on all the connected devices. In order to run them on some concrete devices instead, you may specify their serial numbers:

spoon {
  devices = ['333236E9AE5800EC']
  skipDevices = ['serial-you-want-to-skip']
}

It is also allowed to specify specify size of tests that should be run. You may run all the tests annotated as @SmallTest with the following line:

gradle spoonSmall

Run gradle tasks for details about size rules.

You may also setup your project to take parameters for class/method to be run from command line. E.g.:

gradle spoon -PspoonClassName=fully.qualified.TestCase

And project configuration:

spoon {
  if (project.hasProperty('spoonClassName')) {
    className = project.spoonClassName  
  }
}

Test Sharding

You can configure test sharding using the numShards and shardIndex properties (documentation):

spoon {
  numShards = 4
  shardIndex = 0
}

If you are specifying sharding for multiple devices, you may use spoon's built in auto-sharding by specifying:

spoon {
  shard = true
}

This will automatically shard across all specified serials, and merge the results.

Custom instrumentation arguments

Use the instrumentationArgs property on spoon extension to pass custom parameters to your tests:

spoon {
  instrumentationArgs = ["foo=bar", "name=value"]
}

Code Coverage

You can configure spoon to calculate code coverage by using codeCoverage property on spoon extension:

spoon {
  codeCoverage = true
}

This option requires your app to have the WRITE_EXTERNAL_STORAGE permission.

Known issues

If you have troubles with running Android Lint after this plugin is applied, try the following workaround

buildscript {
  // ...
  dependencies {
    classpath('com.stanfy.spoon:spoon-gradle-plugin:1.2.2') {
      exclude module: 'guava'
    }
    classpath 'com.google.guava:guava:17.0'
  }
}

You can find details in the related issue.

Testing

After making editions, run

./gradlew integrationTest

This will install the plugin to local maven repo and run spoon task in the example project.

License

Copyright 2013-2016 Stanfy Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

gson-xml

Java library for XML deserialization
Java
200
star
2

enroscar

A set of Android tools that facilitate apps development
Java
182
star
3

SwiftyMock

This repository contains helpers that make mocking in Swift much easier
Swift
77
star
4

goro

Android library for organizing your asynchronous tasks in queues
Java
63
star
5

helium

DSL for REST API specification, verification, and code generation.
Groovy
47
star
6

submit-to-appstore-objc

Checklist for iOS developer before submitting app to AppStore
41
star
7

ios-components-bikeshedding

often we create same components again and again. read this before estimation!
27
star
8

gradle-android-apt

Makes sources generated by annotation processors visible in Android Studio
Groovy
26
star
9

behave-rest

BDD-style Rest API testing tool
Python
20
star
10

parse-server-ansible

Create Parse Server backend based on MongoRocks and Parse Dashboard.
Shell
19
star
11

enroscar-async

Makes it easy to put your asynchronous operations behind Android's Loader
Java
12
star
12

cintegration

Scripts for iOS Continious Integration
Shell
10
star
13

xcode-templates

8
star
14

SFObjectMapping

Object mapping for JSON <-> PONSO transformations
Objective-C
5
star
15

SFCoreUtils

Number of useful beans: DateFormatter, UIView macroses, non-retaining arrays etc
Objective-C
5
star
16

hotandroid

Set of samples and tasks for HotCode conference.
Java
4
star
17

SFTransitionManager

Objective-C
3
star
18

ironman-bulb

Ironman bulb project based on ESP8266
Arduino
2
star
19

icfpc2014

Our rep for icfpc2014
Java
2
star
20

java-code-style

Stanfy checkstyle rules and IDE configuration for Java developers
Shell
2
star
21

mattock

JUnit4 tests runner for Android
Groovy
2
star
22

git-pulse

JavaScript
1
star