GithubHelp home page GithubHelp logo

sirithink / robolectric Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robolectric/robolectric

0.0 2.0 0.0 40.24 MB

Android Unit Testing Framework

Home Page: http://robolectric.org/

License: MIT License

robolectric's Introduction

Robolectric

Build Status

Robolectric is a unit test 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(RobolectricTestRunner.class)
public class MyActivityTest {

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

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

    pressMeButton.performClick();
    String resultsText = results.getText().toString();
    assertThat(resultsText, 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

You can install Robolectric for your project by adding the following to your pom.xml:

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

Dependencies

Google API Jars

Robolectric requires the Google APIs for Android (specifically, the maps JAR). To download this onto your development machine use the Android SDK tools and then run the following to install them to your local Maven repository:

mvn install:install-file -DgroupId=com.google.android.maps \
  -DartifactId=maps \
  -Dversion=18_r3 \
  -Dpackaging=jar \
  -Dfile="$ANDROID_HOME/add-ons/addon-google_apis-google-18/libs/maps.jar"

You will need to either replace or have ANDROID_HOME set to your local Android SDK for Maven to be able to install the jar.

Building And Contributing

Robolectric can be built using either Maven or Ant. Both Eclipse (with the M2Eclipse plug-in) and IntelliJ can import the pom.xml file and will automatically generate their project files from it.

Guides on to extending Robolectric can be found here and the contributor guidlines can be found here.

robolectric's People

Contributors

acc15 avatar adamcohenrose avatar cessationoftime avatar coreydowning avatar cwperry avatar dnkoutso avatar edenman avatar erd avatar erichaugh avatar felly avatar gesellix avatar jakewharton avatar jberkel avatar joemoore avatar leviwilson avatar macarse avatar mportuesisf avatar msama avatar palfrey avatar pforhan avatar rcdickerson avatar rdehuyss avatar rjrjr avatar roberttaylor426 avatar roman-mazur avatar seadowg avatar thorikawa avatar tylerschultz avatar xaethos avatar xian avatar

Watchers

 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.