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.

@CartesianProductTest extension

See original GitHub issue

Overview

Provide a similar, but complete and fleshed-out, extension that provides a @CartesianProductTest annotation implemention.

Usage outline

@CartesianProductTest({"0", "1"})
void threeBits(String a, String b, String c) {
	int value = Integer.parseUnsignedInt(a + b + c, 2);
	assertTrue((0b000 <= value) && (value <= 0b111));
}

@CartesianProductTest
@DisplayName("S ⨯ T ⨯ U")
void nFold(String string, Class<?> type, TimeUnit unit, TestInfo info) {
	assertTrue(string.endsWith("a"));
	assertTrue(type.isInterface());
	assertTrue(unit.name().endsWith("S"));
	assertTrue(info.getTags().isEmpty());
}

static CartesianProductTest.Sets nFold() {
	return new CartesianProductTest.Sets()
			.add("Alpha", "Omega")
			.add(Runnable.class, Comparable.class, TestInfo.class)
			.add(TimeUnit.DAYS, TimeUnit.HOURS);
}

Implementation idea

https://github.com/junit-team/junit5-samples/tree/master/junit5-jupiter-extensions/src/main/java/com/example/cartesian

Todos

  • Copy sources from junit5-jupiter-extensions and adopt to pioneers’ (package) structure.
  • Write unit and integration tests for the @CartesianProductTest and its provider.
  • Support more basic types in the annotation, in addition to String?
  • Document usage and limitations

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sormurascommented, Nov 10, 2018

Ideally the @CartesianProductTest would be able to reuse any existing argument source, including the @RangeSource described in #123. For example:

@CartesianProductTest
@EnumSource(TimeUnit.class)
@ValueSource(ints = {1, 2, 3})
@RangeSource(2, 10, 2)
void test(TimeUnit unit, int a, int b) {...}
0reactions
matthieu-vergnecommented, Jan 25, 2021

I like the idea of tagging the parameters. If an issue is open on that topic, please share its link here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cartesian Product of Parameters [removed in 2.0]
The JUnit 5 (Jupiter) extension @CartesianProductTest adds a variant of parameterized tests that executes a test for each possible combination of input ...
Read more >
junit-team/junit5 - Gitter
@jahluwalia Are you looking for something like @CartesianProductTest ? ... jupiter-extensions/src/test/java/com/example/cartesian/CartesianProductTests.java.
Read more >
Parameterize both class and tests in JUnit 5 - Stack Overflow
JUnit Pioneer. There is the JUnit Pioneer extension pack for JUnit Jupiter. It comes with @CartesianProductTest . Using the extended the example ...
Read more >
JUnit Pioneer 1.0 - nipafx.dev
There you go, all ten Jupiter extensions in just three tests ... The @CartesianProductTest annotation lets you specify values for each ...
Read more >
JUnit Pioneer - SlideShare
JUnit Pioneer is an extension library for JUnit 5 (Jupiter). ... product of all inputs Use @CartesianProductTest instead of Jupiter @Test ...
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