-
Notifications
You must be signed in to change notification settings - Fork 0
Update version to 1.6.0 #36
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for specifying exception types and factories in the @InTestsMock
annotation and bumps the project version to 1.6.0.
- Introduce
NoException
marker to indicate “no exception” in mocks - Extend
InTestsMock
withthrowException
andthrowExceptionFactory
properties - Update
pom.xml
andREADME.md
to reflect version 1.6.0
Reviewed Changes
Copilot reviewed 4 out of 4 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 for “no exception” behavior |
src/main/java/com/diffblue/cover/annotations/InTestsMock.java | Added throwException and throwExceptionFactory annotation fields |
pom.xml | Bumped cover-annotations version from 1.5.0 to 1.6.0 |
README.md | Updated Gradle coordinates to 1.6.0 |
Comments suppressed due to low confidence (5)
src/main/java/com/diffblue/cover/annotations/InTestsMock.java:96
- Consider restricting this to Class<? extends Throwable> to enforce that only throwable types can be used as exception types in the annotation.
Class<?> throwException() default NoException.class;
src/main/java/com/diffblue/cover/annotations/InTestsMock.java:102
- [nitpick] The JavaDoc could clarify the precedence and expected input format when both throwException and throwExceptionFactory are provided.
String throwExceptionFactory() default "";
README.md:39
- [nitpick] Ensure that any other usage examples (e.g., Maven snippets) are also updated to version 1.6.0 to keep docs consistent.
compileOnly("com.diffblue.cover:cover-annotations:1.6.0")
src/test/java/com/diffblue/cover/annotations/InTestsMockTest.java:1
- Add unit tests to verify that the annotation processor correctly handles throwException and throwExceptionFactory.
// TODO: add tests covering throwException and throwExceptionFactory usage
pom.xml:19
- [nitpick] If there are additional modules in this multi-module project, verify their version tags are bumped in sync to prevent mismatches.
<version>1.6.0</version>
* @return exception type to throw when the mocked {@link #method()} is called. Defaults to {@link | ||
* NoException} to indicate no exception should be thrown. | ||
*/ | ||
Class<?> throwException() default NoException.class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make it nullable
instead and default to null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, potentially does need the new Exception class to keep things simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this goes from the restriction in Java’s annotation model, you cannot use null as the default value for an annotation member every default must be a compile-time constant (constant expression) link, link2, linkstackoverflow)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I messed up this PR. all these changes must be in #35
I will change the base branch, and probably your commentswill disappear
* @return exception type to throw when the mocked {@link #method()} is called. Defaults to {@link | ||
* NoException} to indicate no exception should be thrown. | ||
*/ | ||
Class<?> throwException() default NoException.class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot had a reasonable sounding point about maybe it should be Class<? implements Throwable>, is it reasonable? It might be that it doesnt make sense in the use case..
src/main/java/com/diffblue/cover/annotations/exceptions/NoException.java
Outdated
Show resolved
Hide resolved
770e711
to
c31323f
Compare
233c278
to
a0d1ab6
Compare
c31323f
to
17f8845
Compare
a0d1ab6
to
1c4f518
Compare
TG-23051
Changed annotations
@InTestsMock
- new attributesthrowException
andthrowExceptionFactory
Supported 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]