Skip to content

TG-23051 throwException and throwExceptionFactory for @InTestsMock #35

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

Conversation

ksunandr
Copy link
Contributor

@ksunandr ksunandr commented Jun 4, 2025

TG-23051
Changed annotations

@ksunandr ksunandr changed the title TG-23051 Specifying throwException and throwExceptionFactory for @In… TG-23051 throwException and throwExceptionFactory for @InTestsMock Jun 6, 2025
@ksunandr ksunandr requested review from a team and Copilot June 6, 2025 08:38
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

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 NoException marker class under exceptions package.
  • Add throwException and throwExceptionFactory attributes to InTestsMock.

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 throwException and throwExceptionFactory to ensure the new behavior is correctly supported.
Class<?> throwException() default NoException.class;

@ksunandr ksunandr mentioned this pull request Jun 6, 2025
@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-throwException-throwExceptionFactory branch from c31323f to 17f8845 Compare June 6, 2025 10:25
@ksunandr ksunandr merged commit f45b875 into develop Jun 6, 2025
1 check passed
@ksunandr ksunandr deleted the ksan/TG-23051-throwException-throwExceptionFactory branch June 6, 2025 10:26
@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.

2 participants