If there is an algorithm that uses random numbers then it is probably not possible to write a test as the results will be based on the random number. Even in cases when that is not an issue, we usually want to make our test repeatable.

In some cases the best solution is to mock the random number generation and provide pre-defined fake random to the application.

This is what we are going to demonstrate here.