I have a function that will select a random value between a min and a max value. So when I have a test where I test that the value fall between the min and max value. But as
Generally your tests should pass for all possible values of your non-deterministic code. Maybe have a loop in your test where you do the test say 100 times. That will catch more failures without changing the application code. What you suggested is also an option.