具有随机结果的集成测试
我想为我正在创建的纸牌游戏编写一些集成测试。然而,它是基于随机播放的。我能想到的获得可预测测试结果的唯一解决方案是存根随机播放,但是我对在集成测试中进行任何存根感到不舒服。有其他策略吗?
I'd like to write some integration tests for a card game I'm creating. However, it's based on a shuffle. The only solution I can think of to get predictable results to test is stubbing the shuffle, however I'm uncomfortable doing any stubbing in an integration test. Are there any alternative strategies?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试的目的是什么?
在我看来,集成测试中的存根很好,所有测试都应该只测试被测组件。另一种选择是允许随机播放种子。
What is the aim of the test?
Stubbing in an integration test is IMO fine, all tests should only test the components under test. One other option would be to allow the Shuffle to take a seed.