unit-testing - 单元测试术语

标签 unit-testing nunit terminology

我的同事把带有测试方法的类称为夹具,但我认为这是错误的,因为“夹具”是用于测试的固定环境。

NUnit uses the (wrong?) term "TestFixture"也是。

Wikipedia说:

In generic xUnit, a test fixture is all the things that must be in place in order to run a test and expect a particular outcome.

Frequently fixtures are created by handling setUp() and tearDown() events of the unit testing framework. In setUp() one would create the expected state for the test, and in tearDown() it would clean up what had been set up.

所以我会调用设置和拆卸固定装置,而不是整个类(class)。对吗?

如何用测试用例调用类? python docs 之后的“测试套件” ?

最佳答案

一个测试用例是一个单一测试测试一个特定的东西。

测试套件一组测试用例,由于某种原因“属于一起”的一组测试。

测试夹具管理(设置/拆卸)测试用例执行前后的状态

这些是概念,如何实现这些概念取决于测试框架

例如测试用例可以是函数或类;一个测试套件可能是一个包含测试用例作为函数的类,或者只是一个带有测试用例的容器(这同样可以通过多种方式实现);测试夹具可能内置到测试框架中,例如专用函数,或者它可能只是一个 fixture 类,通过其构造和销毁来处理状态。

编辑

我认为重要的一件事是使用测试框架的术语并遵循测试框架的推荐方法(如果存在)。很多困惑来自于没有一致和相似地命名事物。这对一切都是如此。

关于unit-testing - 单元测试术语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6593290/

相关文章:

visual-studio-2008 - 运行所有测试时,如何使ReSharper忽略某些类别?

unit-testing - java.lang.ClassCastException : com. sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl无法转换为DocumentBuilderFactory

nunit - 使用 MemberData 将 xUnit 测试用例转换为 nUnit

c# - 自动异步套接字测试

.net - WMI 的非行话定义是什么?

c# - 流是什么意思?它的特点是什么?

multithreading - 什么是竞争条件?

c# - 使用 HttpClient 对发出 Http 请求的 Controller 进行单元测试

c# - 如何防止虚拟方法被模拟?

c# - 使用 Moq、Silverlight 和 NUnit 进行单元测试