Skip to content

Avoids starting mocks "half-way" if a superclass constructor is mocked but an unmocked subclass is initiated.#2682

Merged
raphw merged 1 commit intomainfrom
avoid-subclass-constructor-call
Jun 26, 2022
Merged

Avoids starting mocks "half-way" if a superclass constructor is mocked but an unmocked subclass is initiated.#2682
raphw merged 1 commit intomainfrom
avoid-subclass-constructor-call

Conversation

@raphw
Copy link
Copy Markdown
Member

@raphw raphw commented Jun 11, 2022

Fixes #2680. Offers two implementations, one using a regular stack trace processor, one using StackWalker which is more accurate but requires a VM using Java 9 or newer.

@raphw raphw force-pushed the avoid-subclass-constructor-call branch from f28941a to 02615ff Compare June 11, 2022 21:04
@raphw raphw requested a review from TimvdLippe June 11, 2022 21:06
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 11, 2022

Codecov Report

Merging #2682 (02615ff) into main (ce4e64d) will increase coverage by 0.00%.
The diff coverage is 78.33%.

@@            Coverage Diff            @@
##               main    #2682   +/-   ##
=========================================
  Coverage     86.26%   86.26%           
- Complexity     2779     2791   +12     
=========================================
  Files           315      317    +2     
  Lines          8334     8394   +60     
  Branches       1035     1048   +13     
=========================================
+ Hits           7189     7241   +52     
- Misses          874      880    +6     
- Partials        271      273    +2     
Impacted Files Coverage Δ
...internal/creation/bytebuddy/StackTraceChecker.java 66.66% <66.66%> (ø)
...nternal/creation/bytebuddy/StackWalkerChecker.java 80.95% <80.95%> (ø)
...on/bytebuddy/InlineDelegateByteBuddyMockMaker.java 69.72% <100.00%> (+1.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce4e64d...02615ff. Read the comment docs.

Copy link
Copy Markdown
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.

Nice fix! Do you know what the performance impact on this is? Can we cache the result (I am assuming not)?

Also, can we cover a bit more of the code or is this mostly it?

@TimvdLippe
Copy link
Copy Markdown
Contributor

@raphw shall we merge this one?

@raphw raphw merged commit a6e7132 into main Jun 26, 2022
@raphw
Copy link
Copy Markdown
Member Author

raphw commented Jun 26, 2022

Yes!

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.

MockedConstruction has side effects even after close() (with Sub-/Superclass)

3 participants