Skip to content
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

Only run injection once #2603

Conversation

1-alex98
Copy link
Contributor

@1-alex98 1-alex98 commented Mar 24, 2022

Add regression test that makers sure constructor injection is used when possible
Fixes #2602

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should mention Fixes #<issue number> if relevant

@1-alex98
Copy link
Contributor Author

See issue #2602 for context

@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2022

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01 ⚠️

Comparison is base (5cccfda) 85.70% compared to head (27991f0) 85.69%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2603      +/-   ##
============================================
- Coverage     85.70%   85.69%   -0.01%     
+ Complexity     2876     2874       -2     
============================================
  Files           326      326              
  Lines          8733     8727       -6     
  Branches       1078     1077       -1     
============================================
- Hits           7485     7479       -6     
  Misses          971      971              
  Partials        277      277              
Impacted Files Coverage Δ
...ernal/configuration/InjectingAnnotationEngine.java 87.50% <100.00%> (-1.64%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@1-alex98 1-alex98 marked this pull request as ready for review April 4, 2022 13:10
Copy link

@ZNhatAnhZ ZNhatAnhZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is legit

@1-alex98
Copy link
Contributor Author

1-alex98 commented Feb 21, 2023

@ZNhatAnhZ sadly nobody ever looked at it :D

The current state is a mess. My Pull Request cleans up the mess and aliens the code with what is promised in the docs. It therefore has to remove a strange integration test that tests a bug(or a feature that was never there).

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on user feedback, this is the appropriate fix after all. Running the tests one more time and then will merge it. Sorry for the long wait, it was unclear to me at the time what the appropriate behaviour of Mockito is.

ToBeMockedInTestSuperClass toBeMockedInTestSuperClass;

public TestClassToBeInitiatedViaConstructorInSuperClass(ToBeMockedInTestSuperClass toBeMockedInTestSuperClass) {
assert toBeMockedInTestSuperClass != null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These asserts need to be changed to AssertJ, as it fails the build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1-alex98 Did you see this comment? We need to change the code, not just a rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I did that locally. I am not sure why that did not make it here. I will check if I am home. I probably forgot to push or something. @TimvdLippe

@1-alex98
Copy link
Contributor Author

I will update the PR tonight if I find the time

@1-alex98 1-alex98 force-pushed the bugfix/#2602-makeSureConstructorInjectionIsUsedIfValidConstructorExists branch from 1556f76 to b4d89f9 Compare June 12, 2023 18:55
Add regression test that makers sure constructor injection is used when possible
Fixes mockito#2602
@1-alex98 1-alex98 force-pushed the bugfix/#2602-makeSureConstructorInjectionIsUsedIfValidConstructorExists branch from b4d89f9 to 27991f0 Compare June 16, 2023 13:09
@TimvdLippe TimvdLippe merged commit 8497f17 into mockito:main Jun 16, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mockito-core MockitoAnnotations::openMocks initializes class twice if said class has super class
4 participants