Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for specifying an exception or an exception factory on the @InTestsMock annotation and introduces a marker class to represent “no exception.”
- Introduce
NoExceptionmarker class underexceptionspackage. - Add
throwExceptionandthrowExceptionFactoryattributes toInTestsMock.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/com/diffblue/cover/annotations/exceptions/NoException.java | New marker class to indicate the absence of an exception. |
| src/main/java/com/diffblue/cover/annotations/InTestsMock.java | Added throwException and throwExceptionFactory attributes. |
Comments suppressed due to low confidence (2)
src/main/java/com/diffblue/cover/annotations/InTestsMock.java:96
- Restrict the return type to Class<? extends Throwable> for
throwException()to enforce at compile time that only exception types are allowed.
Class<?> throwException() default NoException.class;
src/main/java/com/diffblue/cover/annotations/InTestsMock.java:96
- Add unit tests that verify annotation processing for
throwExceptionandthrowExceptionFactoryto ensure the new behavior is correctly supported.
Class<?> throwException() default NoException.class;
Merged
ahuggett26
approved these changes
Jun 6, 2025
770e711 to
c31323f
Compare
…estsMock when the mocked method is called
c31323f to
17f8845
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TG-23051
Changed annotations
@InTestsMock- new attributesthrowExceptionandthrowExceptionFactorySupported by Diffblue Cover from 2025.06.02
See https://docs.diffblue.com/features/cover-annotations/mocking-annotations for more details
Full Changelog: [v1.5.0]...[v1.6.0]