-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore fields that are annotated with the @MockBean
and @SpyBean
annotations of Spring test
#757
Conversation
Hmm, it seems that the dependency |
Haven't had a chance to look at this in any level of detail, but one thing that seems to be happening is our existing tests failing with |
I'm a Maven user so I am not familiar with Gradle: in Maven you would simply exclude the transitive dependency, it should not be required during compile time for these two annotations. But the syntax in your scripts seems to not allow exclusions, at least I found no way to add one. (The PR is not really important for me, I just thought it might make sense to add these annotations because I needed to add some suppressions in my code. So we should not spend too much time to fix it, if the testing framework does not support it out of the box.) |
Sorry for the long delay in looking at this. I don't think the transitive dependency is the issue. For the failing test I see An alternative here is to just "stub out" the relevant Could we take the same approach in this PR, so we don't even need the dep on spring-boot-test? |
Thanks for the pointer! I'll look into those classes and try to refactor the PR in this way. |
Thanks! Note that the directory structure doesn't matter here, i.e., it doesn't need to match the package names. So I'd create a folder NullAway/nullaway/src/test/java/com/uber/nullaway/NullAwayAndroidTest.java Lines 126 to 132 in 1ff88b6
|
@uhafner Are you still working on it? We are having the same issue and are currently workarounding it by configuring NullAway with..
I know nothing about the internal architecture of NullAway, but if you're busy I may give @msridhar suggestions a shot. |
This simplifies the tests: no dependency to spring boot is required.
Thanks for fixing this up! This now LGTM assuming tests pass |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #757 +/- ##
============================================
+ Coverage 86.72% 86.80% +0.08%
Complexity 1870 1870
============================================
Files 74 74
Lines 6178 6178
Branches 1202 1202
============================================
+ Hits 5358 5363 +5
+ Misses 408 405 -3
+ Partials 412 410 -2
☔ View full report in Codecov by Sentry. |
This is a small followup to #477. When you are testing Spring (Boot) applications then you are replacing controllers that are normally injected via
@Autowired
with stubs, mocks or spies from Mockito. This is done with two similar annotations:@MockBean
@SpyBean
So it would be helpful if these are ignored as well.