GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add ParameterizedTest#argumentCountValidation by JonasJebing · Pull Request #4045 · junit-team/junit-framework

Conversation

@JonasJebing

@JonasJebing JonasJebing commented Oct 4, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Overview

This allows parameterized tests to fail
when there are more arguments provided than declared by the test method. This is done in a backwards compatible way
by only enabling that validation when the new
junit.jupiter.params.argumentCountValidation is set to strict or ParameterizedTest#argumentCountValidation is set to ArgumentCountValidationMode.STRICT.

Open Questions

  • Should these additions be declared as experimental or stable?
  • Should this feature be documented in the User Guide and Release Notes, given that it is declared as experimental?
  • Should the new precondition be documented on org.junit.jupiter.params.ParameterizedTestExtension#provideTestTemplateInvocationContexts, even though it is just an interface override and none of the existing preconditions are documented there?

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


Definition of Done

  • There are no TODOs left in the code
  • Method preconditions are checked and documented in the method's Javadoc
  • Coding conventions (e.g. for logging) have been followed
  • Change is covered by automated tests including corner cases, errors, and exception handling
  • Public API has Javadoc and @API annotations
  • Change is documented in the User Guide and Release Notes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eugef reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jonas-jebing-at-ebay @JonasJebing
Issue: junit-team#3708 add ParameterizedTest#argumentCountValidation
2e56d56
This allows parameterized tests to fail
when there are more arguments provided than declared by the test method.
This is done in a backwards compatible way
by only enabling that validation when the new
`junit.jupiter.params.argumentCountValidation` is set to `strict`
or `ParameterizedTest#argumentCountValidation` is set to
`ArgumentCountValidationMode.STRICT`.
@JonasJebing
JonasJebing force-pushed the argument-count-validation-mode branch from 2b42de8 to 2e56d56 Compare October 5, 2024 20:30
marcphilipp
marcphilipp requested changes Oct 8, 2024
View reviewed changes
Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java Outdated
Comment on lines +151 to +152
logger.warn(() -> String.format(
"Ignored invalid configuration '%s' set via the '%s' configuration parameter.", value, key));

@marcphilipp marcphilipp Oct 8, 2024

Copy link
Copy Markdown
Member

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.

The error message should be the same as in EnumConfigurationParameterConverter. Unfortunately, we can't (easily) reuse that here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JonasJebing JonasJebing Oct 23, 2024

Copy link
Copy Markdown
Contributor Author

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.

Is there some way that we could make it more easily reusable across the project? Maybe I could add another PR to address that after merging this one.
For now, I basically copied the messages from EnumConfigurationParameterConverter.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestIntegrationTests.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread jupiter-tests/src/test/java/org/junit/jupiter/params/ParameterizedTestIntegrationTests.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@marcphilipp marcphilipp linked an issue Oct 8, 2024 that may be closed by this pull request
@ParameterizedTest ignores additional arguments beyond formal parameter list #3708
Closed
@marcphilipp

marcphilipp commented Oct 8, 2024

Copy link
Copy Markdown
Member
  • Should these additions be declared as experimental or stable?

Our guideline is to introduce new features as "experimental".

  • Should this feature be documented in the User Guide and Release Notes, given that it is declared as experimental?

I think we should add a small sample to the User Guide otherwise the chance to get feedback is slim.

  • Should the new precondition be documented on org.junit.jupiter.params.ParameterizedTestExtension#provideTestTemplateInvocationContexts, even though it is just an interface override and none of the existing preconditions are documented there?

Documenting preconditions is mainly interesting for public API so we can omit it here since ParameterizedTestExtension is package-private.

JonasJebing reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JonasJebing added 3 commits October 23, 2024 12:17
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
3d40ebe
# Conflicts:
#	junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java
#	junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java
@JonasJebing
address PR comments
98cdf69
- add `writing-tests-parameterized-tests-argument-count-validation`
  section to the user guide.
- cache configuration parameter in `ExtensionContext.Store`
- adjust log and error messages

Issue junit-team#3708
@JonasJebing
gradle spotlessApply
89a7443
Issue junit-team#3708
@JonasJebing

JonasJebing commented Oct 23, 2024

Copy link
Copy Markdown
Contributor Author

Thank you for all the pointers and comments on this PR @marcphilipp. I've addressed all your comments. Could you have another look?

marcphilipp reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JonasJebing
JonasJebing requested a review from marcphilipp October 23, 2024 14:24
JonasJebing added 4 commits October 23, 2024 16:37
@JonasJebing
move example to .adoc because it's a test that should error
5c71632
Issue junit-team#3708
@JonasJebing
fix newline char assertion for Windows
edd9f46
Issue junit-team#3708
@JonasJebing
gradle spotlessApply
beb53ab
Issue junit-team#3708
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
b117b69
@JonasJebing
JonasJebing marked this pull request as ready for review October 23, 2024 15:59
marcphilipp
marcphilipp requested changes Oct 24, 2024
View reviewed changes

@marcphilipp marcphilipp left a comment

Copy link
Copy Markdown
Member

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.

Thanks for making those changes! I think we're very close now. Please also add an entry to the 5.12.0-M1 release notes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ArgumentCountValidationMode.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

JonasJebing and others added 7 commits October 24, 2024 09:58
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
37216f8
@JonasJebing
add change to release-notes 5.12.0-M1
f87404f
release-notes-5.12.0-M1-junit-jupiter-new-features-and-improvements
to be exact

Issue junit-team#3708
@JonasJebing @marcphilipp
fix ArgumentCountValidationMode javadoc typo
14a071b
Co-authored-by: Marc Philipp <[email protected]>
@JonasJebing @marcphilipp
improve ParameterizedTest javadoc
762c39a
Co-authored-by: Marc Philipp <[email protected]>
@JonasJebing @marcphilipp
use underscores for unused lambda parameter
8a84dc2
Co-authored-by: Marc Philipp <[email protected]>
@JonasJebing @marcphilipp
use root context store for caching config value
09ced82
Co-authored-by: Marc Philipp <[email protected]>
@JonasJebing
remove mention of experimental status from release note
0bf0b05
@JonasJebing
JonasJebing force-pushed the argument-count-validation-mode branch from 65cd018 to 0bf0b05 Compare October 24, 2024 08:43
JonasJebing
JonasJebing commented Oct 24, 2024
View reviewed changes
Comment thread documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JonasJebing
JonasJebing requested a review from marcphilipp October 24, 2024 08:57
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
f189f07
@JonasJebing

JonasJebing commented Oct 25, 2024

Copy link
Copy Markdown
Contributor Author

@marcphilipp could you review again? I applied all suggestions and added a release note.

marcphilipp reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

marcphilipp
marcphilipp requested changes Oct 25, 2024
View reviewed changes
Comment thread documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread documentation/src/docs/asciidoc/release-notes/release-notes-5.12.0-M1.adoc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread documentation/src/docs/asciidoc/user-guide/writing-tests.adoc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JonasJebing @marcphilipp
@ParameterizedTests to Parameterized tests
36e7729
Co-authored-by: Marc Philipp <[email protected]>
@JonasJebing

JonasJebing commented Nov 14, 2024

Copy link
Copy Markdown
Contributor Author

Looks good! I've only two small suggestions. Please let me know if you have time to do those or whether I should take over.

Thanks! I'll make those changes you suggested today or tomorrow :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JonasJebing added 2 commits November 14, 2024 12:48
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
1151f6b
@JonasJebing
add small ArgumentCountValidator perf optimisations
906881c
Issue junit-team#3708
@JonasJebing

JonasJebing commented Nov 14, 2024

Copy link
Copy Markdown
Contributor Author

@marcphilipp could you merge the PR? And of course feel free to review the small change you suggested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JonasJebing added 2 commits November 15, 2024 14:37
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
89ceaec
@JonasJebing
Merge branch 'main' into argument-count-validation-mode
9619c36
marcphilipp
marcphilipp approved these changes Nov 17, 2024
View reviewed changes
@marcphilipp marcphilipp changed the title Issue: #3708 add ParameterizedTest#argumentCountValidation Add ParameterizedTest#argumentCountValidation Nov 17, 2024
@marcphilipp
marcphilipp merged commit 6082336 into junit-team:main Nov 17, 2024
@marcphilipp

marcphilipp commented Nov 17, 2024

Copy link
Copy Markdown
Member

@JonasJebing Thank you for your contribution! 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JonasJebing JonasJebing mentioned this pull request Nov 18, 2024
Introduce support for zero invocations in test templates and parameterized tests #1477
Closed
@marcphilipp marcphilipp mentioned this pull request Nov 19, 2024
Rename new @ParameterizedTest attributes to avoid confusion #4137
Closed
1 task done
This was referenced Feb 24, 2025
Bump junit from 5.11.4 to 5.12.0 kousen/java_8_recipes#125
Closed
Bump junit from 5.11.4 to 5.12.0 kousen/IntroGroovy#128
Closed
Bump junit from 5.11.4 to 5.12.0 kousen/junit5_workshop#251
Closed
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.0 kousen/http-client-demo#43
Merged
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.0 kousen/functional_modern_java#31
Closed
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.0 kousen/java_upgrade#44
Merged
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.0 kousen/java_9_recipes#45
Closed
Bump junit from 5.11.4 to 5.12.0 kousen/java_groovy_kotlin#194
Merged
This was referenced Mar 17, 2025
Bump junit from 5.11.4 to 5.12.1 kousen/java_8_recipes#127
Closed
Bump junit from 5.11.4 to 5.12.1 kousen/IntroGroovy#130
Closed
Bump junit from 5.11.4 to 5.12.1 kousen/junit5_workshop#254
Merged
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.1 kousen/java_9_recipes#46
Closed
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.1 kousen/functional_modern_java#32
Closed
This was referenced Apr 14, 2025
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.2 kousen/java_9_recipes#47
Closed
Bump org.junit.jupiter:junit-jupiter from 5.11.4 to 5.12.2 kousen/functional_modern_java#33
Closed
Bump junit from 5.11.4 to 5.12.2 kousen/java_8_recipes#131
Closed
Bump junit from 5.11.4 to 5.12.2 kousen/IntroGroovy#132
Closed
@sbrannen sbrannen mentioned this pull request Nov 23, 2026
Fix NamespacedHierarchicalStore memory leak #6311
Merged
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@marcphilipp marcphilipp marcphilipp approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

@ParameterizedTest ignores additional arguments beyond formal parameter list

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@JonasJebing @marcphilipp @jonas-jebing-at-ebay
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.