开发者

Unit test terms

开发者 https://www.devze.com 2023-03-17 19:55 出处:网络
Colleagues of mine are calling a class with tes开发者_JS百科t methods a fixture, but I think that is wrong because a \"fixture\" is a fixed environment for testing.

Colleagues of mine are calling a class with tes开发者_JS百科t 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消