Chromium Code Reviews| Index: testing/android/docs/junit4.md |
| diff --git a/testing/android/docs/junit4.md b/testing/android/docs/junit4.md |
| index d40583fbe545490aef7c961bb61fb5b9526bc905..fbf31af0f83c5a2c22fcbc8efbe22e9bd983551f 100644 |
| --- a/testing/android/docs/junit4.md |
| +++ b/testing/android/docs/junit4.md |
| @@ -146,24 +146,27 @@ public class MyRule implements TestRule { |
| ``` |
| -## Caveats |
| +## Common Errors |
| 1. Instrumentation tests that rely on test thread to have message handler |
| will not work. For example error message: |
| java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() |
| - Please utilize `@UiThreadTest` or |
| - `ActivityTestRule.runOnUiThread(Runnable r)` to refactor these tests. |
| - For more, check this [GitHub issue][6] |
| - |
| -1. Use `@UiThreadTest` with caution. Currently, |
| - **@UiThreadTest is only effective when UiThreadTestRule or |
| - ActivityTestRule is declared** in the test class. Please use |
| - `android.support.test.annotation.UiThreadTest`, not |
| - `android.test.UiThreadTest`. When using @UiThreadTest, **it would cause |
| - `setUp` and `tearDown` to run in Ui Thread** as well. Avoid that by simply |
| - calling [`runOnUiThread`][9] or [`runOnMainSync`][10] with a Runnable. |
| + or |
| + java.lang.IllegalStateException: The current thread must have a looper! |
|
jbudorick
2017/05/04 19:40:47
I think you need an extra blank line before this o
the real yoland
2017/05/04 19:53:28
Done
|
| + |
| + Please utilize `ActivityTestRule.runOnUiThread(Runnable r)` to refactor |
| + these tests. For more, check this [GitHub issue][6] |
| + |
| +1. Use `@UiThreadTest` with caution!! |
| + - Currently, **@UiThreadTest is only effective when UiThreadTestRule or |
| + ActivityTestRule is declared** in the test class. |
| + - Please use **`android.support.test.annotation.UiThreadTest`, NOT |
| + `android.test.UiThreadTest`**. |
| + - When using @UiThreadTest, **it would cause `setUp` and `tearDown` to |
| + run in Ui Thread** as well. Avoid that by calling [`runOnUiThread`][9] |
| + or [`runOnMainSync`][10] with a Runnable. |
| ```java |
| // Wrong test |
| @@ -218,6 +221,11 @@ public class MyRule implements TestRule { |
| `Assert.assertEquals(float a, float b, float delta)` |
| +1. Error-prone warning when disabling a javatest in JUnit4. If you get a |
|
jbudorick
2017/05/04 19:40:47
Rephrase:
1. Errorprone expects all methods star
the real yoland
2017/05/04 19:53:28
Done
|
| + `[JUnit4TestNotRun] Test method will not be run; please add @Test annotation` |
| + warning. It's likely because you commented out `@Test` when adding |
| + `@DisabledTest` or `@FlakyTest`. |
| + |
| ## Common questions |
| - Q: Are `@Test` and `@LargeTest/@MediumTest/@SmallTest` annotation both |