Skip to content

Issues 938-document inheritance support#5708

Open
swatichauhan814 wants to merge 2 commits into
junit-team:mainfrom
swatichauhan814:issues/938-document-inheritance-support
Open

Issues 938-document inheritance support#5708
swatichauhan814 wants to merge 2 commits into
junit-team:mainfrom
swatichauhan814:issues/938-document-inheritance-support

Conversation

@swatichauhan814
Copy link
Copy Markdown

@swatichauhan814 swatichauhan814 commented May 28, 2026

issue: Document which classes support inheritance and which do not #938

I hereby agree to the terms of the JUnit Contributor License Agreement.

Signed-off-by: Swati Chauhan <swati.chauhan814@gmail.com>
@swatichauhan814 swatichauhan814 force-pushed the issues/938-document-inheritance-support branch from c4743d5 to b9cd9a1 Compare May 28, 2026 14:04
@mpkorstanje
Copy link
Copy Markdown
Member

mpkorstanje commented May 29, 2026

I'd be very happy to review your work!

@jbduncan all yours.

@testlens-app

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@jbduncan jbduncan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start! I have some thoughts on how it could be improved further; see below.

@mpkorstanje, I was wondering if I could have your input on these too as a JUnit maintainer?

* {@link ArgumentsAccessor} if an error occurs while accessing
* or converting an argument.
*
* <p>This class is not intended to be extended by clients.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptions are a bit unusual. The base JUnitException is definitely designed for extension (as is RuntimeException for that matter), and I think it's fair to say that the JUnit maintainers may want to extend ArgumentAccessException in the future too, so we should give users the same right.

How about a header like this (inspired by Assertions.java) to make the wording on extension more prominent?

 * <h2>Extensibility</h2>
 *
 * <p>This class is designed for extension.

@mpkorstanje, do you have any thoughts on all this?

Copy link
Copy Markdown
Member

@mpkorstanje mpkorstanje Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fair to say that the JUnit maintainers may want to extend ArgumentAccessException in the future too, so we should give users the same right.

As far as I can tell, the ArgumentAccessException shouldn't ever be created from user code. So this would have to be the "This class is not intended to be extended by clients." warning. But I'm not 100% sure about that.

In the user guide I see that users might implement the ArgumentsAccessor interface which would require them to be able to throw ArgumentAccessException.

https://docs.junit.org/6.1.0/writing-tests/parameterized-classes-and-tests.html#argument-aggregation

In this context, an indexed parameter is an argument for a given index in the Arguments provided by an ArgumentsProvider that is injected into a field annotated with @Parameter(index). An aggregator is any @Parameter-annotated field of type ArgumentsAccessor or any field annotated with @AggregateWith.

But I'm not sure if the user guide is correct here, I couldn't find a code path that would make that possible and I think that instead of ArgumentsAccessor the guide should omit the type and say:

An aggregator is any @Parameter-annotated field or any field annotated with @AggregateWith.

@jbduncan you could help me out here by double checking if this indeed the case.

Signed-off-by: Swati Chauhan <swati.chauhan814@gmail.com>
@swatichauhan814 swatichauhan814 requested a review from jbduncan May 30, 2026 05:13
Copy link
Copy Markdown
Contributor

@jbduncan jbduncan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swatichauhan814 LGTM! Consider it approved on my end. Great work. 👍

I believe we need a review from a JUnit maintainer to get this merged in, so now we wait.

@mpkorstanje mpkorstanje self-requested a review May 31, 2026 20:40
Copy link
Copy Markdown
Member

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jbduncan one remark for you to look into.

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