Home | History | Annotate | only in /external/robolectric-shadows
Up to higher level directory
NameDateSize
Android.mk22-Oct-20206K
annotations/22-Oct-2020
CODE_OF_CONDUCT.md22-Oct-20203.2K
gen_test_config.mk22-Oct-20201.4K
images/22-Oct-2020
java-timeout22-Oct-20203.4K
junit/22-Oct-2020
LICENSE22-Oct-20201.1K
list_failed.sh22-Oct-2020737
OWNERS22-Oct-2020129
processor/22-Oct-2020
README.md22-Oct-20203K
report-internal.mk22-Oct-20202.1K
resources/22-Oct-2020
robolectric/22-Oct-2020
robotest-internal.mk22-Oct-20204.1K
robotest.sh22-Oct-20204.3K
run_robolectric_module_tests.mk22-Oct-20205.8K
run_robotests.mk22-Oct-20209.5K
sandbox/22-Oct-2020
shadowapi/22-Oct-2020
shadows/22-Oct-2020
src/22-Oct-2020
utils/22-Oct-2020
wrapper.sh22-Oct-20202.5K
wrapper_test.sh22-Oct-20203.3K

README.md

      1 <a name="README">[<img src="https://rawgithub.com/robolectric/robolectric/master/images/robolectric-horizontal.png"/>](http://robolectric.org)</a>
      2 
      3 [![Build Status](https://travis-ci.org/robolectric/robolectric.svg?branch=master)](https://travis-ci.org/robolectric/robolectric)
      4 [![GitHub release](https://img.shields.io/github/release/robolectric/robolectric.svg?maxAge=60)](https://github.com/robolectric/robolectric/releases)
      5 
      6 Robolectric is the industry-standard unit testing framework for Android. With Robolectric, your tests run in a simulated Android environment inside a JVM, without the overhead of an emulator.
      7 
      8 ## Usage
      9 
     10 Here's an example of a simple test written using Robolectric:
     11 
     12 ```java
     13 @RunWith(RobolectricTestRunner.class)
     14 public class MyActivityTest {
     15 
     16   @Test
     17   public void clickingButton_shouldChangeResultsViewText() throws Exception {
     18     Activity activity = Robolectric.setupActivity(MyActivity.class);
     19 
     20     Button button = (Button) activity.findViewById(R.id.press_me_button);
     21     TextView results = (TextView) activity.findViewById(R.id.results_text_view);
     22 
     23     button.performClick();
     24     assertThat(results.getText().toString(), equalTo("Testing Android Rocks!"));
     25   }
     26 }
     27 ```
     28 
     29 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](http://robolectric.org).
     30 
     31 ## Install
     32 
     33 ### Starting a New Project
     34 
     35 If you'd like to start a new project with Robolectric tests you can refer to `deckard` (for either [maven](http://github.com/robolectric/deckard-maven) or [gradle](http://github.com/robolectric/deckard-gradle)) as a guide to setting up both Android and Robolectric on your machine.
     36 
     37 #### build.gradle:
     38 
     39 ```groovy
     40 testImplementation "org.robolectric:robolectric:4.1"
     41 ```
     42 
     43 ## Building And Contributing
     44 
     45 Robolectric is built using Gradle. Both IntelliJ and Android Studio can import the top-level `build.gradle` file and will automatically generate their project files from it.
     46 
     47 You will need to have portions of the Android SDK available in your local Maven artifact repository in order to build Robolectric. Copy all required Android dependencies to your local Maven repo by running:
     48 
     49     ./scripts/install-dependencies.rb
     50 
     51 *Note*: You'll need Maven installed, `ANDROID_HOME` set and to have the SDK and Google APIs for API Level 27 downloaded to do this.
     52 
     53 Robolectric supports running tests against multiple Android API levels. The work it must do to support each API level is slightly different, so its shadows are built separately for each. To build shadows for every API version, run:
     54 
     55     ./gradlew clean assemble install compileTest
     56 
     57 ### Using Snapshots
     58 
     59 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.
     60 
     61 #### build.gradle:
     62 
     63 ```groovy
     64 repositories {
     65     maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
     66 }
     67 
     68 dependencies {
     69     testImplementation "org.robolectric:robolectric:4.2-SNAPSHOT"
     70 }
     71 ```
     72