mstest - 单元测试运行持续时间
到目前为止,我们的项目中有 621 个单元测试。执行这些测试大约持续 35 秒。这些是典型的单元测试,不应处理网络或磁盘操作。我认为最昂贵的操作应该带有反射(通过 StructureMap 和 AutoMapper)。
那么:
1 - 使用 MSTest 在 35 秒内执行 621 个单元测试是不是很糟糕?
2 - 如果这些是 nunit 测试,会更快吗?
3 - 如果有的话,您的基准是什么?我们是否应该调查测试中是否运行了一些不需要的代码?
In our project so far we have 621 unit tests. executing these tests lasts ~35 seconds. these are typical unit tests, which should not deal with network or disk operations. I think the most costly operations should come with reflection (coming via StructureMap and AutoMapper).
So:
1 - Does it smell bad to execute 621 unit tests in 35 seconds using MSTest?
2 - Would it be faster if these were nunit tests?
3 - What are your benchmarks, if you have any? Should we look into, if there is some unwanted code running in tests?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要检查的一件快速事情是查看每个 AppDomain 是否发生一次昂贵的初始化操作,或者每个测试发生一次,或者每个测试装置发生一次。通过确保 StructureMap、AutoMapper、NHibernate 和其他组件仅在执行的所有单元测试中初始化一次,我们大大加快了测试速度。
One quick thing to check is to see if expensive initialization operations are happening once per AppDomain, or once per test, or once per test fixture. We sped up our tests quite a bit by making sure that StructureMap, AutoMapper, NHibernate and others were only initialized once for ALL unit tests executed.