Robolectric annotations are ignored |
|||
Issue descriptionFrom "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?
,
Feb 21 2018
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.
,
Feb 21 2018
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.
,
Feb 21 2018
Excellent, thank you! I'll try it and send out a CL to fix this issue.
,
Apr 11 2018
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 |
|||
Comment 1 by jbudorick@chromium.org
, Feb 20 2018