New issue
Advanced search Search tips

Issue 813774 link

Starred by 1 user

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocked on:
issue 809356



Sign in to add a comment

Robolectric annotations are ignored

Project Member Reported by bsazonov@chromium.org, Feb 20 2018

Issue description

From "Building a library of Custom Shadows" section at http://robolectric.org/extending/, it looks like @Implementation, @Resetter and other Robolectric won't work without special annotation processor (org.robolectric.annotation.processing.RobolectricProcessor).

Chrome build files don't add this annotation processor, so currently these annotations don't work.

The only usage of @Resetter is in ShadowRecordHistogram: https://cs.chromium.org/chromium/src/base/android/junit/src/org/chromium/base/metrics/test/ShadowRecordHistogram.java?l=26&rcl=ed2fb50e8f5a7666e08ffef881373dbe396492ae, so it's not a big deal. @Implementation is more widespread, but it shouldn't change the behavior, it just checks that such a method exists in the class that's being shadowed.

I couldn't find any easy way to enable this annotation processor with our build templates for Java (they support processor_args_javac, but don't allow adding processors).

John, is there a simple way of adding this processor that I am missing?
 
Did you look at using annotation_processor_deps w/ //third_party/robolectric:robolectric_processor (https://codesearch.chromium.org/chromium/src/third_party/robolectric/BUILD.gn?rcl=cdf4d3da16899677b769324fa79384a361cb08b7&l=149) ?
Thanks, John!
Sorry, I somehow missed that one. Is it enabled for all Java sources? I'm pretty sure that @Resetter method hasn't been invoked in my tests.
No, I think we currently only use it for the robolectric java_library targets themselves. I believe we'd have to add

  annotation_processor_deps = [
    "//third_party/robolectric:robolectric_processor"
  ]

to //base:base_junit_tests.
Owner: bsazonov@chromium.org
Status: Assigned (was: Untriaged)
Excellent, thank you!
I'll try it and send out a CL to fix this issue.
Blockedon: 809356
Status: Started (was: Assigned)
Enabling Robolectic annotation processor triggers a bunch of errorprone warnings in the generated code. These warning have been fixed in Robolectric 3.7, so marking this as blocked on Robolectric update.

Sign in to add a comment