|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| annotations/ | | 03-May-2024 | - | 838 | 526 |
| images/ | | 03-May-2024 | - | | |
| junit/ | | 03-May-2024 | - | 380 | 300 |
| processor/ | | 03-May-2024 | - | 4,388 | 3,445 |
| resources/ | | 03-May-2024 | - | 30,352 | 19,473 |
| robolectric/ | | 03-May-2024 | - | 71,295 | 57,049 |
| sandbox/ | | 03-May-2024 | - | 6,922 | 5,319 |
| shadowapi/ | | 03-May-2024 | - | 1,137 | 806 |
| shadows/ | | 03-May-2024 | - | 75,970 | 55,386 |
| soong/ | | 03-May-2024 | - | 135 | 101 |
| src/main/resources/META-INF/services/ | | 03-May-2024 | - | 6 | 6 |
| utils/ | | 03-May-2024 | - | 2,594 | 1,812 |
| .gitignore | D | 03-May-2024 | 318 | 47 | 36 |
| Android.bp | D | 03-May-2024 | 6.5 KiB | 224 | 199 |
| Android.mk | D | 03-May-2024 | 646 | 22 | 14 |
| CODE_OF_CONDUCT.md | D | 03-May-2024 | 3.2 KiB | 75 | 56 |
| LICENSE | D | 03-May-2024 | 1.1 KiB | 22 | 17 |
| METADATA | D | 03-May-2024 | 39 | 4 | 3 |
| OWNERS | D | 03-May-2024 | 166 | 8 | 8 |
| README.md | D | 03-May-2024 | 3 KiB | 72 | 45 |
| gen_test_config.mk | D | 03-May-2024 | 1.4 KiB | 25 | 11 |
| java-timeout | D | 03-May-2024 | 3.4 KiB | 95 | 42 |
| list_failed.sh | D | 03-May-2024 | 737 | 29 | 15 |
| report-internal.mk | D | 03-May-2024 | 2.4 KiB | 59 | 40 |
| robotest-internal.mk | D | 03-May-2024 | 4.6 KiB | 102 | 70 |
| robotest.sh | D | 03-May-2024 | 4.3 KiB | 141 | 98 |
| run_robolectric_module_tests.mk | D | 03-May-2024 | 6.1 KiB | 97 | 66 |
| run_robotests.mk | D | 03-May-2024 | 10 KiB | 225 | 121 |
| wrapper.sh | D | 03-May-2024 | 2.5 KiB | 77 | 27 |
| wrapper_test.sh | D | 03-May-2024 | 3.3 KiB | 173 | 149 |
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