开发者

Should one use TestCase or FunctionTestCase for testing in python?

While trying to get a hunch of TDD in python I encountered the FunctionTestCase class. I understand, that it defi开发者_开发百科nes equivalent functions to the TestCase classes.

assertEqual = failUnlessEqual(self, first, second, msg=None)
assertNotEqual = failIfEqual(self, first, second, msg=None)
# and so on...

Is there a significant difference in using FunctionTestCase or is it a question of flavour?


FunctionTestCase can be used for easily reusing existing code. More often that not you will probably be using the TestCase class.

From unittest documentation:

Some users will find that they have existing test code that they would like to run from unittest, without converting every old test function to a TestCase subclass.

For this reason, unittest provides a FunctionTestCase class. This subclass of TestCase can be used to wrap an existing test function. Set-up and tear-down functions can also be provided.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜