New issue
Advanced search Search tips

Issue 910747 link

Starred by 1 user

Issue metadata

Status: Available
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Task



Sign in to add a comment

Convert java unit tests to robolectric (for performance)

Project Member Reported by ntfschr@chromium.org, Nov 30

Issue description

A quick codesearch tells me that we have 2 instrumentation test suites which are effectively unit tests:

https://cs.chromium.org/chromium/src/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java?l=23&rcl=1a157ed53531646a002bd5e74836364ac90a1e66
https://cs.chromium.org/chromium/src/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientCallbackHelperTest.java?l=38&rcl=c40a10c176b8375b6f9e3d949497f4d3952a2971

It seems we could alleviate CQ a bit by converting these to robolectric. It would also serve as an example for how to write AW robolectric tests. If we think there's potential benefits, should someone investigate this?

As a warning for anyone taking this on, you'll need to modify the presubmit I wrote in http://crrev/c/1184234 to allow the robolectric test runner, or move robolectric tests to a different folder.
 
$ out/Emulator/bin/run_webview_instrumentation_test_apk --num_retries=0 ---gtest_filter=AwLayoutSizerTest#*
C   38.154s Main  ********************************************************************************
C   38.154s Main  Summary
C   38.154s Main  ********************************************************************************
C   38.154s Main  [==========] 18 tests ran.
C   38.154s Main  [  PASSED  ] 18 tests.
C   38.154s Main  ********************************************************************************

^ The above takes 44 sec on my machine (on an emulator). Note this doesn't include compilation time. If robolectric can beat that, seems like a valuable refactor.
Owner: stonebraker@chromium.org
We can expand the list:

https://cs.chromium.org/search/?q=AwJUnit4ClassRunner+-AwTestContainerView+-AwActivityTestRule+file:test.java&type=cs
(File operation and garbage collection tests couldn't be moved out, but FindAddressTest.java could be.)

stonebraker@, could you take a look?

I'm writing a guide on testing (http://crrev/c/1399053). If we follow-through, let's add docs on robolectric to the markdown file.

Sign in to add a comment