Is there any way to get the seed of `kotlin.random...
# stdlib
d
Is there any way to get the seed of
kotlin.random.Random
? I want to use
Random
in a test with random seed which I could print in case the test fails.
o
Get a random value and re-seed with it?
d
Yes, there is an option to use
Random(seed)
function. So I guess the answer is “no”.
m
I believe that using MockK you can mock
Random
constructor and always set your own seed or store one that was set. https://mockk.io/#constructor-mocks
😱 1
😅 1
Though I believe it would be easier to generate random seed every time, print it and then use it.
d
I ended up doing this
val random = Random(seed = Random.nextInt().printed("seed="))
👍 1
140 Views