Index: testing/android/docs/junit.md |
diff --git a/testing/android/docs/junit.md b/testing/android/docs/junit.md |
index 3fc14952a2ddcf9eb5b51b40a4f2df452178d5cb..96e16d11534c10c6884c10fbf190c04317bed88c 100644 |
--- a/testing/android/docs/junit.md |
+++ b/testing/android/docs/junit.md |
@@ -52,11 +52,17 @@ code on your workstation. It does this by providing a special version of the |
Android SDK jar that can run in your host JVM. Some more information about |
Robolectric can be found [here](http://robolectric.org/). |
+One on the main benefits of using Robolectric framework are [shadow classes](http://robolectric.org/extending/). |
+Robolectric comes with many prebuilt shadow classes and also lets you define |
+your own. They work like this; whenever an object is instantiated within a |
jbudorick
2017/05/15 22:56:53
nit: this; -> this:
|
+Robolectric test, Robolectric looks for a cooresponding shadow class (marked by |
jbudorick
2017/05/15 22:56:53
nit: cooresponding -> corresponding
|
+`@Implements(ClassBeingShadowed.class)`). If found, anytime a method is invoked |
jbudorick
2017/05/15 22:56:53
nit: any time
|
+on the object, the shadow class' implementation of the method is invoked first. |
jbudorick
2017/05/15 22:56:53
nit: class's, I believe, as class isn't plural
|
+This works even for static and final methods. |
+ |
#### Useful Tips |
* Use `@RunWith(LocalRobolectricTestRunner.class)` for all Chromium Robolectric tests. |
-* Use `@Config(manifest = Config.NONE)` for tests. |
- Currently, you are unable to pass your app's AndroidManifest to Robolectric. |
* You can specify the Android SDK to run your test with with `@Config(sdk = ??)`. |
> Currently, only SDK levels 18, 21, and 25 are supported in Chromium |
@@ -97,6 +103,25 @@ public class MyRobolectricJUnitTest { |
} |
``` |
+#### Example junit_binary build template. |
+ |
+```python |
+junit_binary("my_robolectric_tests") { |
+ |
+ java_files = [ |
+ "java/src/foo/bar/MyJUnitTest.java" |
+ |
+ deps = [ |
+ "//my/test:dependency", |
+ ] |
+ |
+ # Sets app's package name in Robolectric tests. You need to specify |
+ # this variable in order for Robolectric to be able to find your app's |
+ # resources. |
+ package_name = manifest_package |
+} |
+``` |
+ |
#### Example within Chromium |
See the [content_junit_tests](https://cs.chromium.org/chromium/src/content/public/android/BUILD.gn) test suite. |