单元测试术语
我的同事将带有测试方法的类称为固定装置,但我认为这是错误的,因为“固定装置”是用于测试的固定环境。
NUnit 也使用(错误?)术语“TestFixture”。
维基百科 说:
在通用 xUnit 中,测试夹具是 所有必须就位的事情 为了运行测试并期望 具体结果。
固定装置通常由以下人员创建 处理setUp()和tearDown()事件 单元测试框架。在 setUp() 会创建预期的 测试状态,并在tearDown()中 它会清理已经设置的内容 向上。
所以我会调用设置和拆卸装置,但不会调用整个类。这是正确的吗?
以及如何调用带有测试用例的类? python 文档之后的“测试套件”?
Colleagues of mine are calling a class with test methods a fixture, but I think that is wrong because a "fixture" is a fixed environment for testing.
NUnit uses the (wrong?) term "TestFixture" too.
Wikipedia says:
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.
So I would call setup and teardown fixtures but not the whole class. Is that correct?
And how to call the class with the test cases? A "test suite" following the python docs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试用例是测试特定事物的单个测试。
测试套件是将测试用例分组到一组测试中,这些测试由于某种原因“属于在一起”。
测试装置管理(设置/拆卸)测试用例执行之前和之后的状态。
这些都是概念,如何实现这些概念取决于测试框架。
例如,测试用例可以是一个函数或一个类;测试套件可能是一个包含测试用例作为函数的类,或者只是一个包含测试用例的容器(这也可以通过多种方式实现);测试装置可以作为专用函数内置到测试框架中,或者它可能只是一个通过构造和销毁来处理状态的装置类。
编辑
我认为重要的一件事是使用测试框架的术语并遵循测试框架的推荐方法(如果存在)。很多混乱是由于没有一致和相似地命名事物而产生的。这对一切都是如此。
A test case is a single test testing a particular thing.
A test suite is a grouping of test cases into a set of tests that for some reason "belong together".
A test fixture manages (setup/teardown) the state before and after a test case is being executed.
These are concepts and how these are implemented depends on the test framework.
E.g. a test case can be a function or a class; a test suite might be a class containing test cases as functions or just a container with test cases (this again can be implemented in various ways); a test fixture might be built-in into the test framework as e.g. dedicated functions, or it might just be a fixture class taking care of the state through its construction and destruction.
Edit
One thing I believe is important is to use the terminology of the test framework and follow the recommended approach of the test framework (if such exists). A lot of confusion comes through not naming things consistently and similarly. This is true for everything.