junit5 icon indicating copy to clipboard operation
junit5 copied to clipboard

Issue: #3708 add ParameterizedTest#argumentCountValidation

Open JonasJebing opened this issue 1 year ago • 1 comments

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

JonasJebing avatar Oct 04 '24 20:10 JonasJebing

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

marcphilipp avatar Oct 08 '24 13:10 marcphilipp

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

JonasJebing avatar Oct 23 '24 14:10 JonasJebing

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

JonasJebing avatar Oct 25 '24 10:10 JonasJebing

@marcphilipp do you know how to fix the DiskLruCache issue on the Windows check? I see some PRs, like #4120 are having the same issue.

JonasJebing avatar Nov 13 '24 08:11 JonasJebing

@marcphilipp do you know how to fix the DiskLruCache issue on the Windows check? I see some PRs, like #4120 are having the same issue.

Not sure. It might be a problem that started after updating Gradle to 8.11. :thinking:

marcphilipp avatar Nov 13 '24 12:11 marcphilipp

A rerun succeeded. It does seem to happen since yesterday's Gradle update. I'll keep an eye on it.

marcphilipp avatar Nov 13 '24 12:11 marcphilipp

@marcphilipp could you review the latest changes? Like you suggested, the ArgumentCountValidator now only fails the invocations that have too many arguments and still runs the other invocations that have the correct number of arguments and I also added an integration test for that case.

JonasJebing avatar Nov 13 '24 13:11 JonasJebing

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 :)

JonasJebing avatar Nov 14 '24 11:11 JonasJebing

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

JonasJebing avatar Nov 14 '24 12:11 JonasJebing

@JonasJebing Thank you for your contribution! :+1:

marcphilipp avatar Nov 17 '24 16:11 marcphilipp