-
Notifications
You must be signed in to change notification settings - Fork 117
Add deterministic random class #1255
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
base: main
Are you sure you want to change the base?
Add deterministic random class #1255
Conversation
...ure-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/random/DeterministicRandom.java
Outdated
Show resolved
Hide resolved
...ure-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/random/DeterministicRandom.java
Outdated
Show resolved
Hide resolved
| import org.apiguardian.api.API.Status; | ||
|
|
||
| @API(since = "1.1.16", status = Status.MAINTAINED) | ||
| public class DeterministicRandom extends Random { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to create a new interface for obtaining the Random instance and the seed value.
It is to avoid using the DeterministicRandom directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback! 🙂
I created a new interface named RandomSource to obtain Random instances and seed values.
I also implemented DeterministicRandomSource that encapsulates the caching logic,
so the internal implementation is no longer exposed.
7077b4a to
237fa16
Compare
38a7176 to
84e0308
Compare
Summary
Implement DeterministicRandom class with seed-based Random instance caching for deterministic test reproducibility.
Description
DeterministicRandomclass that extendsRandomnextLong()generated values as keysgetRandomInstance(long seed)to retrieve cached Random instances by seedgetCurrentSeedRandom()to get the Random instance for the current seedHow Has This Been Tested?
./gradlew :fixture-monkey-api:testpasses successfullynextLong(), instance retrieval, cache size limit (≤32), deterministic behavior, and seed independenceIs the Document updated?
Not yet.