Giter Site home page Giter Site logo

facebook / robolectric Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robolectric/robolectric

60.0 16.0 35.0 27.93 MB

Android Unit Testing Framework

Home Page: http://robolectric.org

License: MIT License

Java 99.40% Shell 0.42% Ruby 0.13% Batchfile 0.04%

robolectric's Introduction

Build Status

Robolectric is a testing framework that de-fangs the Android SDK so you can test-drive the development of your Android app.

Usage

Here's an example of a simple test written using Robolectric:

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class MyActivityTest {

  @Test
  public void clickingButton_shouldChangeResultsViewText() throws Exception {
    Activity activity = Robolectric.setupActivity(MyActivity.class);

    Button button = (Button) activity.findViewById(R.id.press_me_button);
    TextView results = (TextView) activity.findViewById(R.id.results_text_view);

    button.performClick();
    assertThat(results.getText().toString(), equalTo("Testing Android Rocks!"));
  }
}

For more information about how to install and use Robolectric on your project, extend its functionality, and join the community of contributors, please visit http://robolectric.org.

Install

Starting a New Project

If you'd like to start a new project with Robolectric you can use deckard (for either maven or gradle). These project will guide you through setting up both Android and Robolectric on your machine.

Gradle

testCompile "org.robolectric:robolectric:3.0"

Maven

<dependency>
   <groupId>org.robolectric</groupId>
   <artifactId>robolectric</artifactId>
   <version>3.0</version>
   <scope>test</scope>
</dependency>

Building And Contributing

Robolectric is built using Maven. Both Eclipse (with the M2Eclipse plug-in) and IntelliJ can import the pom.xml file and will automatically generate their project files from it. You will need to have portions of the Android SDK available in your local Maven repo in order to build Robolectric.

Mavenize all required dependencies by running:

./scripts/install-dependencies.rb

Because Robolectric's shadows are compiled against the Android APIs that they target, you must build the shadows for all API levels before being able to run any of the tests. You can build all of Robolectric by running:

./scripts/install-robolectric.sh

After doing this once, you can build and test against the specific API level you care about:

mvn install -P android-18 (for example)

Using Snapshots

If you would like to live on the bleeding edge, you can try running against a snapshot build. Keep in mind that snapshots represent the most recent changes on master and may contain bugs.

Gradle

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
    testCompile "org.robolectric:robolectric:3.1-SNAPSHOT"
}

Maven

<repository>
  <id>sonatype-snapshpots</id>
  <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

<dependency>
   <groupId>org.robolectric</groupId>
   <artifactId>robolectric</artifactId>
   <version>3.1-SNAPSHOT</version>
   <scope>test</scope>
</dependency>

robolectric's People

Contributors

adamcohenrose avatar avh4 avatar blurpy avatar cessationoftime avatar coreydowning avatar dnkoutso avatar ecgreb avatar erd avatar erichaugh avatar gesellix avatar jakewharton avatar jberkel avatar joemoore avatar jongerrish avatar lexs avatar macarse avatar mportuesisf avatar msama avatar palfrey avatar pforhan avatar rcdickerson avatar rjrjr avatar roberttaylor426 avatar roman-mazur avatar ry4n1m3 avatar seadowg avatar thorikawa avatar tylerschultz avatar xian avatar yuzhong-google avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.