[doc] logging: explain how to enable it in junit tests
BUG= Review URL: https://codereview.chromium.org/1581983002 Cr-Commit-Position: refs/heads/master@{#370682}
This commit is contained in:
@ -17,7 +17,7 @@ import java.util.Locale;
|
||||
* the origin of logs, and enable or disable logging in different parts of the code.
|
||||
* </p>
|
||||
* <p>
|
||||
* Usage documentation: {@code //docs/logging.md}.
|
||||
* Usage documentation: {@code //docs/android_logging.md}.
|
||||
* </p>
|
||||
*/
|
||||
public class Log {
|
||||
|
@ -206,3 +206,23 @@ further.
|
||||
|
||||
For more, see the [related page on developer.android.com]
|
||||
(http://developer.android.com/tools/debugging/debugging-log.html#filteringOutput)
|
||||
|
||||
## Logs in JUnit tests
|
||||
|
||||
We use [robolectric](http://robolectric.org/) to run our JUnit tests. It
|
||||
replaces some of the Android framework classes with "Shadow" classes
|
||||
to ensure that we can run our code in a regular JVM. `android.util.Log` is one
|
||||
of those replaced classes, and by default calling `Log` methods doesn't print
|
||||
anything.
|
||||
|
||||
That default is not changed in the normal configuration, but if you need to
|
||||
enable logging locally or for a specific test, just add those few lines to your
|
||||
test:
|
||||
|
||||
```java
|
||||
@Before
|
||||
public void setUp() {
|
||||
ShadowLog.stream = System.out;
|
||||
//you other setup here
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user