• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

annotations/23-Nov-2023-838526

images/23-Nov-2023-

junit/23-Nov-2023-380300

processor/23-Nov-2023-4,3883,445

resources/23-Nov-2023-30,35219,473

robolectric/23-Nov-2023-71,29557,049

sandbox/23-Nov-2023-6,9225,319

shadowapi/23-Nov-2023-1,137806

shadows/23-Nov-2023-75,43554,993

soong/23-Nov-2023-135101

src/main/resources/META-INF/services/23-Nov-2023-66

utils/23-Nov-2023-2,5941,812

.gitignoreD23-Nov-2023318 4736

Android.bpD23-Nov-20236.5 KiB224199

Android.mkD23-Nov-2023646 2214

CODE_OF_CONDUCT.mdD23-Nov-20233.2 KiB7556

LICENSED23-Nov-20231.1 KiB2217

METADATAD23-Nov-202339 43

OWNERSD23-Nov-2023166 88

README.mdD23-Nov-20233 KiB7245

gen_test_config.mkD23-Nov-20231.4 KiB2511

java-timeoutD23-Nov-20233.4 KiB9542

list_failed.shD23-Nov-2023737 2915

report-internal.mkD23-Nov-20232.4 KiB5940

robotest-internal.mkD23-Nov-20234.6 KiB10270

robotest.shD23-Nov-20234.3 KiB14198

run_robolectric_module_tests.mkD23-Nov-20236.1 KiB9766

run_robotests.mkD23-Nov-202310 KiB225121

wrapper.shD23-Nov-20232.5 KiB7727

wrapper_test.shD23-Nov-20233.3 KiB173149

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
6Robolectric 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
10Here's an example of a simple test written using Robolectric:
11
12```java
13@RunWith(RobolectricTestRunner.class)
14public 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
29For 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
35If 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
40testImplementation "org.robolectric:robolectric:4.1"
41```
42
43## Building And Contributing
44
45Robolectric 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
47You 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
53Robolectric 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
59If 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
64repositories {
65    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
66}
67
68dependencies {
69    testImplementation "org.robolectric:robolectric:4.2-SNAPSHOT"
70}
71```
72