Coder Social home page Coder Social logo

robolectric-gradle-plugin's Introduction

Robolectric Gradle Plugin

Build Status

A Gradle plugin which enables Robolectric tests.

This plugin piggy-backs on the unit testing support added in version 1.1.0 of the Android Gradle plugin and configures the test tasks to work correctly with Robolectric.

Compatibility

Currently compatible with version 1.2.x of the Android Gradle plugin.

Basic Usage

Add the plugin to your buildscript's dependencies section:

classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'

Apply the org.robolectric plugin:

apply plugin: 'org.robolectric'

Add test-only dependencies using the testCompile configuration:

testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'

Place your tests in src/test/java. You can also add per-build type and per-flavor tests by using the same folder naming conventions (e.g., src/testPaid/java, src/testDebug/java). Run your tests by calling gradle clean test. For more details, see the unit testing docs for the Android Gradle plugin.

Configuration

The underlying Test tasks can be configured via

android.testOptions.unitTests.all {
    // Configure includes / excludes
    include '**/*Test.class'
    exclude '**/espresso/**/*.class'

    // Configure max heap size of the test JVM
    maxHeapSize = '2048m'

    // Configure the test JVM arguments - Does not apply to Java 8
    jvmArgs '-XX:MaxPermSize=512m', '-XX:-UseSplitVerifier'

    // Specify max number of processes (default is 1)
    maxParallelForks = 4

    // Specify max number of test classes to execute in a test process
    // before restarting the process (default is unlimited)
    forkEvery = 150

    // configure whether failing tests should fail the build
    ignoreFailures true

    // use afterTest to listen to the test execution results
    afterTest { descriptor, result ->
        println "Executing test for ${descriptor.name} with result: ${result.resultType}"
    }
}

See the DSL reference for more information.

License

Copyright 2013 Square, Inc.
          2014 - 2015 Pivotal Labs

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.

robolectric-gradle-plugin's People

Contributors

erd avatar jakewharton avatar christiankatzmann avatar mag avatar frankdu avatar blundell avatar cyrret avatar skyisle avatar frownlee avatar jaredsburrows avatar ytolsk avatar ry4n1m3 avatar matthewmichihara avatar scompt avatar bbergler avatar chrisjenx avatar friederbluemle avatar gdaniels avatar dodgex avatar marcinkwiatkowski avatar thorikawa avatar roman-mazur avatar avh4 avatar

Watchers

changyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.