question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@CartesianCsvSource for @CartesianProductTest

See original GitHub issue

Following #409, it would be nice to have @CartesianCsvSource which mimics @CsvSource.

Example:

@CartesianProductTest
@CartesianValueSource(ints = { 1, 2 })
@CartesianCsvSource({
  "A, B",
  "C, D",
  "E, F",
})
void moreParams(int i, String s1, String s2) {
  // some test code
}

should generate 6 tests:

Test # i s1 s2
1 1 A B
2 2 A B
3 1 C D
4 2 C D
5 1 E F
6 2 E F

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Michael1993commented, Jan 27, 2021

I’m wondering though, why there exists such a limitation? I think it would be nicer if one could use JUnit’s standard param annotations instead of the the practically similar @CartesianX ones.

@mizosoft There is a bit of a clash.

When you create a @ParameterizedTest, you supply a single (!) @ArgumentsSource annotation where you define every test case. This is also the reason why annotations annotated with @ArgumentsSource (e.g.: @CsvSource or @ValueSource) are not @Repeatable.

This is different from @CartesianProductTest, where you want to define argument sets for each parameter individually and let the extension define the test cases. This is an entirely different approach from @ParameterizedTest.

We cannot support the annotations used by @ParameterizedTest because we would need them to be @Repeatable. They (probably) never will be repeatable because their design philosophy is different from what we need.

0reactions
nipafxcommented, Apr 28, 2022

Can you two take another look at this and come to a decision whether something could be done here given the new approach to Cartesian tests and what that “something” could look like?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cartesian Product of Parameters
The JUnit 5 (Jupiter) extension @CartesianTest adds a variant of parameterized tests that executes a test for each possible combination of input arguments....
Read more >
Introduce ArgumentsProvider that computes the cartesian ...
Introduce ArgumentsProvider that computes the cartesian product ... Different test methods could so easily use different sets of dimensions.
Read more >
Cleaner parameterized tests with JUnit 5 - Codeleak.pl
The general idea of parameterized unit tests is to run the same test method for different data. Creating parameterized tests in JUnit 4...
Read more >
How to pass multiple parameters to @ValueSource
It lets you specify a single array of literal values and can only be used for providing a single argument per parameterized test...
Read more >
CartesianProductTest (junit-pioneer 1.4.1 API) - javadoc.io
@CartesianProductTest is a JUnit Jupiter extension that marks a test to be executed with all possible input combinations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found