如何在 Java 测试套件中包含性能目标?
有没有一种简单的方法可以在 Java 的日常构建测试中自动执行诸如“此服务必须支持每分钟 1,000 个事务”之类的目标?这是否在 JUnit 中完成过,或者有什么注意事项吗?
Is there an easy way to automatically enforce goals like "This service must support 1,000 transactions per minute" in daily build tests for Java? Is this ever done in JUnit or are there caveats to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法完全执行您想要的操作,但您可以使用 JUnitPerf 执行以下操作。
You can't do exactly what you are looking for but you can do the below using JUnitPerf.
对我来说,这不像是单元测试。它可能是一项长期运行的事务,会延迟构建的完成。您可能会重新考虑总运行时间是否比您的构建频率长。
我什至不清楚这个问题有多大意义,因为它没有考虑同时用户的情况。
您可以使用 TestNG 轻松地进行“穷人的”多线程负载测试。这在 JUnit 4.4 中是不可能的,但在更高版本中可能是。
That doesn't feel like a unit test to me. It could be a long-running transaction, one that will delay the completion of your build. You might reconsider if the total running time is longer than your build frequency.
It's not even clear to me how meaningful the question is, because it doesn't take into account simultaneous users.
You can easily do a "poor man's" multi-threaded load test like this with TestNG. It's not possible in JUnit 4.4, but it might be in a later version.