识别运行缓慢的测试
在 ruby 的测试/单元中,软件指示测试运行需要多长时间,并且一系列的通过、错误和失败就像伪进度条一样。
除了使用代码分析工具或单独运行测试之外,是否有一种简单的方法可以判断哪些测试方法快,哪些测试方法慢?
In ruby's test/unit, the software indicates how long it takes for the tests to run, and the series of passes, errors and fails act like a pseudo-progress bar.
Apart from using code profiling tools or running tests individually, is there an easy way of telling which test methods are fast and which ones are slow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当我需要在大型测试套件中执行此操作时,我会覆盖 Test::Unit::TestCase 设置和拆卸。 它不能提供精确的测量结果,但可以帮助评估相对速度。
When I need to do this in a large test suite, I override Test::Unit::TestCase setup and teardown. It doesn't give precise measurements, but it can help assess relative speed.
根据Sarah的回答,我更喜欢另一种解决方案:
像Sarah写的那样设置,但是Teardown应该在列表中添加测试名称和执行时间。
所以你可以评估这个列表,进行排序或其他任何操作。 我不懂Ruby,所以我不知道它是否有效。
这是 JUnit 的一些 Java 代码来解释我的想法......
According to Sarah's answer, I would prefer another solution:
Setup like Sarah wrote, but the Teardown should add the test name and the execution time in a list.
So you can evaluate this list, for sorting or whatever. I don't know Ruby, so I don't know if it would work.
Here is some Java code for JUnit to explain my thoughts...
如果您使用测试单元 gem,以详细模式运行测试将为您提供有关每个测试花费多长时间的信息:
MiniTest 将 还有 基准测试。
If you're using the test-unit gem, running the tests in verbose mode will give you information on how long each test took:
MiniTest will also have benchmarking.