什么是单元测试、集成测试、冒烟测试和回归测试? [英] What are unit tests, integration tests, smoke tests, and regression tests?
问题描述
什么是单元测试、集成测试、冒烟测试和回归测试?它们之间有什么区别,我可以分别使用哪些工具?
What are unit tests, integration tests, smoke tests, and regression tests? What are the differences between them and which tools can I use for each of them?
例如,我使用 JUnit 和 NUnit 用于单元测试和集成测试.是否有任何工具可用于冒烟测试或回归测试?
For example, I use JUnit and NUnit for unit testing and integration testing. Are there any tools for the last two, smoke testing or regression testing?
推荐答案
单元测试:指定和测试一个类的单一方法的契约的一点.这应该有一个非常狭窄和明确定义的范围.存根或模拟.
Unit test: Specify and test one point of the contract of single method of a class. This should have a very narrow and well defined scope. Complex dependencies and interactions to the outside world are stubbed or mocked.
集成测试:测试多个子系统的正确互操作.从测试两个类之间的集成,到测试与生产环境的集成,范围很广.
Integration test: Test the correct inter-operation of multiple subsystems. There is whole spectrum there, from testing integration between two classes, to testing integration with the production environment.
冒烟测试(又名 健全性 检查):一个简单的集成测试,我们只需检查当被测系统被调用时,它会正常返回并且不会炸毁.
Smoke test (aka sanity check): A simple integration test where we just check that when the system under test is invoked it returns normally and does not blow up.
- Smoke testing is both an analogy with electronics, where the first test occurs when powering up a circuit (if it smokes, it's bad!)...
- ... and, apparently, with plumbing, where a system of pipes is literally filled by smoke and then checked visually. If anything smokes, the system is leaky.
回归测试:在修复错误时编写的测试.它确保不会再次发生此特定错误.全称是非回归测试".它也可以是在更改应用程序之前进行的测试,以确保应用程序提供相同的结果.
Regression test: A test that was written when a bug was fixed. It ensures that this specific bug will not occur again. The full name is "non-regression test". It can also be a test made prior to changing an application to make sure the application provides the same outcome.
对此,我要补充:
验收测试:测试功能或用例是否正确实施.它类似于集成测试,但侧重于提供的用例而不是所涉及的组件.
Acceptance test: Test that a feature or use case is correctly implemented. It is similar to an integration test, but with a focus on the use case to provide rather than on the components involved.
系统测试:将系统作为黑盒进行测试.对其他系统的依赖在测试过程中经常被嘲笑或存根(否则它会更像是一个集成测试).
System test: Tests a system as a black box. Dependencies on other systems are often mocked or stubbed during the test (otherwise it would be more of an integration test).
飞行前检查:在类似生产的环境中重复进行的测试,以缓解在我的机器上构建"综合症.这通常是通过在类似生产的环境中进行验收或冒烟测试来实现的.
Pre-flight check: Tests that are repeated in a production-like environment, to alleviate the 'builds on my machine' syndrome. Often this is realized by doing an acceptance or smoke test in a production like environment.
这篇关于什么是单元测试、集成测试、冒烟测试和回归测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!