-
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
Provide random values #49
Comments
And/or as a simple Usage could look like: @ExtendWith(RandomParametersExtension.class)
class RandomParametersExtensionTests {
@Test
void injectsInteger(@Random int i, @Random int j) { assertNotEquals(i, j); }
@Test
void injectsDouble(@Random double d) { assertEquals(0.0, d, 1.0); }
} |
My personal opinion is that however this is implemented, it should be possible to repeat the tests with the same random values. That makes it necessary:
As far as I see it (and as long as JUnit does not randomize test order), the only challenge for the deterministic entry point is multi-threading. I am willing to accept that limitation. Speaking of randomizing test order, it would be interesting to find out whether an extension could do that. |
junit-team/junit5#13 is still open... |
Possible features:
|
I don't see the use-case for this. You should always control your input to your tests which means no randomizing. |
I'm with @Michael1993.
So I vote to close this issue. |
Actually, random testing is quite a big thing. Be it at the top of the test automation pyramid (e.g. Sapienz) or at the bottom (e.g. QuickCheck). However, let's not get too philosophical. 😉 I agree with @Bukama that we shouldn't do this, there are excellent libs already available. I think this is out of scope and would open a can of worms. Therefore, I also vote to close this issue. |
Whoa, why does everybody want to close this? No random values in tests? Where's your sense of adventure? 🚀 I'd still like to implement this eventually:
Vote not to close 😜 |
Yes, quoting Tyler Durden and the Joker is juvenile and both are full of shit, but... it's fun. :) |
I also just now realize that it may be interesting to think about this in terms of parameterized tests:
I'm gonna unilaterally green-light this. 😁 |
To be a good issue for first contributors, this issue should describe the specific annotations to be created as well as give a rough idea how to implement them. |
When you get to the point of wanting to have reproducible runs, this looks like it might be of use: java.util.SplittableRandom |
In lieu of fleshing out this issue, I created a proof of concept. 😁 |
I think the best use for this extension is to become part of the revamped Cartesian product extension, so I don't think it makes sense to invest more time here before #415 is done. |
In randomizing data JavaFaker (https://github.com/DiUS/java-faker) does provide sensible random data, in combination with parameterized tests you do get valuable edge-case information. Certainly when testing validation stuff. |
Support use cases for random values, e.g. as parameters (like this; inspired by junit-team/junit5#839) or fields or arguments for parameterized tests.
The text was updated successfully, but these errors were encountered: