Unit Testing with functions that return random results

后端 未结 11 1947
太阳男子
太阳男子 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 02:04

    Normaly I use exactly your suggested approach: Control the Random generator. Initialize it for test with a default seed (or replace him by a proxy returning numbers which fit my testcases), so I have deterministic/testable behaviour.

提交回复
热议问题