Unit Testing with functions that return random results

后端 未结 11 1929
太阳男子
太阳男子 2020-12-05 01:25

I don\'t think that this is specific to a language or framework, but I am using xUnit.net and C#.

I have a function that returns a random date in a certain range. I

11条回答
  •  伪装坚强ぢ
    2020-12-05 01:52

    I don't think Unit testing is meant for this. You can use Unit testing for functions that return a stochastic value, but use a fixed seed, in which case in a way they are not stochastic, so to speak, for random seed, I dont think Unit testing is what you want, for example for RNGs what you mean to have is a system test, in which you run the RNG many many times and look at the distribution or moments of it.

提交回复
热议问题