|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| .devcontainer/ | H | 25-Apr-2025 | - | 103 | 83 |
| .github/ | H | 25-Apr-2025 | - | 759 | 545 |
| annotations/ | H | 25-Apr-2025 | - | 2,886 | 1,779 |
| buildSrc/ | H | 25-Apr-2025 | - | 1,075 | 796 |
| errorprone/ | H | 25-Apr-2025 | - | 1,205 | 984 |
| gradle/ | H | 25-Apr-2025 | - | 277 | 206 |
| images/ | H | 25-Apr-2025 | - | | |
| integration_tests/ | H | 25-Apr-2025 | - | 39,825 | 30,687 |
| junit/ | H | 25-Apr-2025 | - | 580 | 440 |
| nativeruntime/ | H | 25-Apr-2025 | - | 7,227 | 4,713 |
| pluginapi/ | H | 25-Apr-2025 | - | 709 | 333 |
| plugins/maven-dependency-resolver/ | H | 25-Apr-2025 | - | 1,013 | 856 |
| preinstrumented/ | H | 25-Apr-2025 | - | 463 | 379 |
| processor/ | H | 25-Apr-2025 | - | 5,567 | 4,491 |
| resources/ | H | 25-Apr-2025 | - | 31,756 | 20,662 |
| robolectric/ | H | 25-Apr-2025 | - | 135,563 | 109,765 |
| sandbox/ | H | 25-Apr-2025 | - | 8,332 | 6,479 |
| scripts/ | H | 25-Apr-2025 | - | 859 | 645 |
| shadowapi/ | H | 25-Apr-2025 | - | 1,550 | 1,094 |
| shadows/ | H | 25-Apr-2025 | - | 139,152 | 102,581 |
| soong/ | H | 25-Apr-2025 | - | 135 | 101 |
| testapp/ | H | 25-Apr-2025 | - | 1,835 | 1,558 |
| utils/ | H | 25-Apr-2025 | - | 4,987 | 3,692 |
| .gitignore | H A D | 25-Apr-2025 | 552 | 67 | 54 |
| ARCHITECTURE.md | H A D | 25-Apr-2025 | 12.2 KiB | 214 | 175 |
| Android.bp | H A D | 25-Apr-2025 | 13.7 KiB | 346 | 323 |
| CODE_OF_CONDUCT.md | H A D | 25-Apr-2025 | 3.2 KiB | 75 | 56 |
| LICENSE | H A D | 25-Apr-2025 | 12.6 KiB | 234 | 192 |
| METADATA | H A D | 25-Apr-2025 | 307 | 16 | 15 |
| MODULE_LICENSE_MIT | HD | 25-Apr-2025 | 0 | | |
| NOTICE | H A D | 25-Apr-2025 | 1.1 KiB | 22 | 17 |
| OWNERS | H A D | 25-Apr-2025 | 84 | 5 | 4 |
| README.md | H A D | 25-Apr-2025 | 2.9 KiB | 71 | 46 |
| WORKSPACE | H A D | 25-Apr-2025 | 36 | 1 | 1 |
| build.gradle.kts | H A D | 25-Apr-2025 | 7.1 KiB | 223 | 185 |
| gradle.properties | H A D | 25-Apr-2025 | 714 | 20 | 14 |
| gradlew | H A D | 25-Apr-2025 | 8.6 KiB | 253 | 105 |
| gradlew.bat | H A D | 25-Apr-2025 | 2.9 KiB | 95 | 73 |
| harddiff.sh | H A D | 25-Apr-2025 | 1.2 KiB | 55 | 40 |
| settings.gradle.kts | H A D | 25-Apr-2025 | 1.5 KiB | 65 | 60 |
README.md
1<a name="README">[<img src="https://rawgithub.com/robolectric/robolectric/master/images/robolectric-horizontal.png"/>](https://robolectric.org)</a>
2
3[](https://github.com/robolectric/robolectric/actions?query=workflow%3Atests)
4[](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 and flakiness of an emulator. Robolectric tests routinely run 10x faster than those on cold-started emulators.
7
8Robolectric supports running unit tests for *14* different versions of Android, ranging from Lollipop (API level 21) to U (API level 34).
9
10## Usage
11
12Here's an example of a simple test written using Robolectric:
13
14```java
15@RunWith(AndroidJUnit4.class)
16public class MyActivityTest {
17
18 @Test
19 public void clickingButton_shouldChangeResultsViewText() {
20 Activity activity = Robolectric.setupActivity(MyActivity.class);
21
22 Button button = (Button) activity.findViewById(R.id.press_me_button);
23 TextView results = (TextView) activity.findViewById(R.id.results_text_view);
24
25 button.performClick();
26 assertThat(results.getText().toString(), equalTo("Testing Android Rocks!"));
27 }
28}
29```
30
31For more information about how to install and use Robolectric on your project, extend its functionality, and join the community of contributors, please visit [robolectric.org](https://robolectric.org).
32
33## Install
34
35### Starting a New Project
36
37If you'd like to start a new project with Robolectric tests, you can refer to `deckard` (for either [Maven](https://github.com/robolectric/deckard-maven) or [Gradle](https://github.com/robolectric/deckard-gradle)) as a guide to setting up both Android and Robolectric on your machine.
38
39### `build.gradle`
40
41```groovy
42testImplementation "junit:junit:4.13.2"
43testImplementation "org.robolectric:robolectric:4.13"
44```
45
46## Building and Contributing
47
48Robolectric is built using Gradle. Both Android Studio and IntelliJ can import the top-level `build.gradle.kts` file and will automatically generate their project files from it.
49
50To get Robolectric up and running on your machine, check out
51[this guide](https://robolectric.org/building-robolectric/).
52
53To get a high-level overview of Robolectric's architecture, check out
54[ARCHITECTURE.md](ARCHITECTURE.md).
55
56## Using Snapshots
57
58If 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 the `master` and may contain bugs.
59
60### `build.gradle`
61
62```groovy
63repositories {
64 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
65}
66
67dependencies {
68 testImplementation "org.robolectric:robolectric:4.14-SNAPSHOT"
69}
70```
71