Unit testing a method with random behaviour

前端 未结 6 391
梦如初夏
梦如初夏 2020-12-17 08:44

I am writing unit test cases for a game I am working on. When the game starts, the player is positioned randomly, and I have two problems with that:

  1. Since the
6条回答
  •  没有蜡笔的小新
    2020-12-17 09:08

    One approach you can take is to split out the random-position generation into a separate class/interface, so that you can override it in your test, and therefore control it.

提交回复
热议问题