Skip to content

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged

Conversation

ksunandr
Copy link
Contributor

@ksunandr ksunandr commented Jun 4, 2025

TG-23051
Changed annotations

@ksunandr ksunandr requested a review from Copilot June 4, 2025 08:15
Copy link

@Copilot Copilot AI left a 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 with throwException and throwExceptionFactory properties
  • Update pom.xml and README.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>

@ksunandr ksunandr requested a review from a team June 6, 2025 08:40
@ksunandr ksunandr changed the title Ksan/tg 23051 update version 1.6.0 Update version to 1.6.0 Jun 6, 2025
* @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;

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?

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.

Copy link
Contributor Author

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)

Copy link
Contributor Author

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;

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..

@ksunandr ksunandr changed the base branch from develop to ksan/TG-23051-throwException-throwExceptionFactory June 6, 2025 09:34
@ksunandr ksunandr force-pushed the ksan/TG-23051-throwException-throwExceptionFactory branch from 770e711 to c31323f Compare June 6, 2025 10:21
@ksunandr ksunandr force-pushed the ksan/TG-23051-update-version-1.6.0 branch from 233c278 to a0d1ab6 Compare June 6, 2025 10:22
@ksunandr ksunandr force-pushed the ksan/TG-23051-throwException-throwExceptionFactory branch from c31323f to 17f8845 Compare June 6, 2025 10:25
@ksunandr ksunandr force-pushed the ksan/TG-23051-update-version-1.6.0 branch from a0d1ab6 to 1c4f518 Compare June 6, 2025 10:26
Base automatically changed from ksan/TG-23051-throwException-throwExceptionFactory to develop June 6, 2025 10:26
@ksunandr ksunandr merged commit 5e59637 into develop Jun 6, 2025
1 check passed
@ksunandr ksunandr deleted the ksan/TG-23051-update-version-1.6.0 branch June 6, 2025 10:45
@ksunandr ksunandr mentioned this pull request Jun 6, 2025
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.

3 participants