New issue
Advanced search Search tips

Issue 771231 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature



Sign in to add a comment

Add command line flag to junit test runner for printing logs

Project Member Reported by nyquist@chromium.org, Oct 3 2017

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
 
Description: Show this description
Owner: jbudorick@chromium.org
Status: Started (was: Untriaged)
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
Project Member

Comment 3 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)
Run your robolectric tests w/ -v for fun and profit and logging to stdout.

Sign in to add a comment