基于 Java 的回归测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7502113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java-Based Regression Testing
提问by IAmYourFaja
How is regression testing performed in Java? Are there automated regression test frameworks or do you just write (JUnit) unit tests that help ensure against regressions?
在 Java 中如何进行回归测试?是否有自动回归测试框架,或者您是否只是编写 (JUnit) 单元测试来帮助防止回归?
Is there a way or set of best practices for coding unit tests so that they also serve the dual purpose of being regression tests, or do you need to keep regression tests separate from your unit tests?
是否有一种编码单元测试的方法或一组最佳实践,以便它们也用于作为回归测试的双重目的,或者您是否需要将回归测试与单元测试分开?
采纳答案by Uri
JUnit is generally aimed for unit tests rather than full-scale functional testing (of which regression testing is an example if one is looking at the system as a whole).
JUnit 通常针对单元测试而不是全面的功能测试(如果从整体上看系统,回归测试就是一个例子)。
However, it is not uncommon to use a separate test suit to perform "heavy" functional and integration tests that connect to actual backends, etc., and verify results against expectations.
但是,使用单独的测试套件来执行连接到实际后端等的“繁重”功能和集成测试并根据预期验证结果的情况并不少见。
One reason for the use of JUnit here is the ability to go from 'mocked tests' to actual functional tests using dependency injection. You could provide, for example, a mock collaborator in the lighter test, and an actual collaborator instance in the full functional test.
在这里使用 JUnit 的一个原因是能够使用依赖注入从“模拟测试”到实际的功能测试。例如,您可以在轻量级测试中提供模拟协作者,在完整功能测试中提供实际协作者实例。
回答by Woot4Moo
Regression testing has nothing to do with a language. It is a technique that is used to ensure future code changes do not break existing features. In Java you can use junit or testng or anything else. Typically a regression test is a functional test and is not a pure unit test.
回归测试与语言无关。这是一种用于确保未来代码更改不会破坏现有功能的技术。在 Java 中,您可以使用 junit 或 testng 或其他任何东西。通常,回归测试是功能测试,而不是纯粹的单元测试。
回答by Garrett Hall
A regression test is any test that catches regressions.
回归测试是任何捕捉回归的测试。
If you want acceptance tests I've heard good things about FitNesse.
如果您想要验收测试,我听说过有关FitNesse 的好消息。