Add command line flag to junit test runner for printing logs |
|||
Issue description
OS: Android
What steps will reproduce the problem?
(1) Write a test using JUnit and the Robolectric test runner.
(2) Add some log statements:
org.chromium.base.Log.d("nyquist", "This is great!");
(3) Run the test
$ ./out/Default/bin/run_base_junit_tests
What is the expected result?
Logs are printed to stdout when running the test, if it fails.
What happens instead?
No logs are printed.
What do I want?
A command line argument to the junit test runner that enables something like:
- Always print logs
- Only print logs on failure (default)
- Do not print logs
Workaround available?
Yes, a developer can do this manually by adding the following statement to the test:
@Before
public void setUp() {
ShadowLog.stream = System.out;
//you other setup here
}
See: https://chromium.googlesource.com/chromium/src/+/db3d89459575f0c658c562baa2d3d55648e6767c/docs/android_logging.md#Logs-in-JUnit-tests
,
Nov 9 2017
Looked into this while working on the 3.4.2 upgrade. Turns out it's super easy: https://github.com/robolectric/robolectric/blob/6fa38fc48242cbdcb08b54f4bd5b5a0a8dbee6f2/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLog.java#L186
,
Nov 13 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/fafce15e45962f57a03b67dece8aa1eb0f0cc4f9 commit fafce15e45962f57a03b67dece8aa1eb0f0cc4f9 Author: John Budorick <jbudorick@chromium.org> Date: Mon Nov 13 21:21:35 2017 [android] Send robolectric logcat to stdout if running w/ verbosity>=1. Bug: 771231 Change-Id: I18fe47904ae828f98fbfca7186c2cdf4cffe05cf Reviewed-on: https://chromium-review.googlesource.com/762409 Reviewed-by: Yoland Yan <yolandyan@chromium.org> Commit-Queue: John Budorick <jbudorick@chromium.org> Cr-Commit-Position: refs/heads/master@{#516053} [modify] https://crrev.com/fafce15e45962f57a03b67dece8aa1eb0f0cc4f9/build/android/pylib/local/machine/local_machine_junit_test_run.py
,
Nov 13 2017
Run your robolectric tests w/ -v for fun and profit and logging to stdout. |
|||
►
Sign in to add a comment |
|||
Comment 1 by nyquist@chromium.org
, Oct 3 2017