Skip to content

Introduce @BooleansSource for use with @ParameterizedTest #4507

@overwave

Description

@overwave

Our team extensively utilizes JUnit Jupiter, particularly the @ParameterizedTest feature, to streamline our testing processes.

A common pattern we have observed involves the use of the @ValueSource annotation with the booleans attribute. Typically, this attribute is used to check whether our code behaves consistently when a feature flag is enabled versus when it is not. Consequently, the majority of our tests require a boolean array containing both true and false values.

To address this need, we have developed several custom annotations that utilize @ValueSource(booleans = {true, false}). However, we believe this pattern is prevalent enough to warrant inclusion in the standard library, reducing redundancy and simplifying test code across projects.

Would it be possible to consider adding a default boolean array {true, false} option for the @ValueSource annotation in future JUnit releases? We believe this addition would benefit many users by eliminating the need to create custom annotations for such a common use case.

I can implement the feature myself, it it would be any help to this.

Thank you for your consideration of this proposal. I look forward to any feedback or questions you might have.

Rodion.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions