|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| annotations/ | | 03-May-2024 | - | 829 | 518 |
| images/ | | 03-May-2024 | - | | |
| junit/ | | 03-May-2024 | - | 371 | 292 |
| processor/ | | 03-May-2024 | - | 4,373 | 3,431 |
| resources/ | | 03-May-2024 | - | 30,340 | 19,462 |
| robolectric/ | | 03-May-2024 | - | 71,073 | 56,885 |
| sandbox/ | | 03-May-2024 | - | 6,910 | 5,308 |
| shadowapi/ | | 03-May-2024 | - | 1,124 | 794 |
| shadows/ | | 03-May-2024 | - | 75,551 | 55,086 |
| soong/ | | 03-May-2024 | - | 126 | 93 |
| src/main/resources/META-INF/services/ | | 03-May-2024 | - | 6 | 6 |
| utils/ | | 03-May-2024 | - | 2,581 | 1,800 |
| .gitignore | D | 03-May-2024 | 318 | 47 | 36 |
| Android.bp | D | 03-May-2024 | 5.1 KiB | 182 | 159 |
| 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 |
| OWNERS | D | 03-May-2024 | 129 | 6 | 6 |
| 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 KiB | 96 | 65 |
| run_robotests.mk | D | 03-May-2024 | 9.8 KiB | 223 | 119 |
| 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