-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable parameterised tests selectively #170
Conversation
The initial code was really just to quickly show a non-declarative solutions. I pondered it for a while - here are my thoughts:
What about this? @ParameterizedTest
@CsvSource({ "1, a", "1, b", "1, c", "2, a", "2, b", "2, c", "3, a", "3, b", "3, c" })
public void test(int number, String text) {
Disable.whenPasses(() -> assertThat(number).is(5));
Disable.whenAllPass(
() -> assertThat(number).is(5),
() -> assertThat(text).is("c"));
Disable.whenAnyPasses(
() -> assertThat(number).is(5),
() -> assertThat(text).is("c"));
} Compared to
Maybe I'm overlooking some obvious failure, but I really like it. I'm really curious to learn what you think! |
I mean I still don't fully understand the use of this feature. You could just write: @ParameterizedTest
@CsvSource({"1, a", "2, b", "3, c", "4, d", "5, e", "6, f"}
public void test(int number, String text) {
if (!(number > 1 && number <= 4 || text.equals("f"))) {
//the actual test
}
} Isn't that effectively the same thing? |
No, it's not the same thing. :) With an ordinary Unless, as you mentioned elsewhere, we added a method |
This is not only outdated but the approach is outright wrong, so I'm closing this. |
Mostly copy-paste work. Hope it's OK. Closes #163
I hereby agree to the terms of the JUnit Pioneer Contributor License Agreement.