commit | f44800ea1c67a3effd8e4652fc4df7b2c63e6aba | [log] [tgz] |
---|---|---|
author | Fr Jeremy Krieg <fr.jeremy@stnectarios.org.au> | Sat Aug 09 19:04:40 2014 +0930 |
committer | Fr Jeremy Krieg <fr.jeremy@stnectarios.org.au> | Thu Oct 23 05:08:28 2014 +1030 |
tree | d2ee3a46c61b9289fd93f6a03a12920425fad22d | |
parent | d69b3f8f19e6ea4d33f7d1a079fea87745129953 [diff] |
Added .factorypath to .gitignore
Robolectric is a testing framework that de-fangs the Android SDK so you can test-drive the development of your Android app.
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.setupActivity(MyActivity.class); 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.
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.
Alternatively, you can install Robolectric for your current project by adding the following to your pom.xml:
<dependency> <groupId>org.robolectric</groupId> <artifactId>robolectric</artifactId> <version>2.3</version> <scope>test</scope> </dependency>
Robolectric requires the Google APIs for Android (specifically, the maps JAR) and Android support-v4 library. 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" mvn install:install-file -DgroupId=com.android.support \ -DartifactId=support-v4 \ -Dversion=19.0.1 \ -Dpackaging=jar \ -Dfile="$ANDROID_HOME/extras/android/support/v4/android-support-v4.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.
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.