python除了unittest,还有一款更快捷的nose,nose可以说是对unittest的一种简化吧
但是他不需要unittest那种必须有固有的格式,他只需要文件,类名,方法名等含有test就可以
unittest是需要手动来写discover函数来遍历用例的
- Name my test modules/files starting with ‘test_’.
- Name my test functions starting with ‘test_’.
- Name my test classes starting with ‘Test’.
- Name my test methods starting with ‘test_’.
- Make sure all packages with test code have an ‘init.py’ file.
官网地址http://pythontesting.net/framework/nose/nose-introduction/
举例说明,比如我有一个这样的目录:
先不管那个main.py,那个test目录下有一个test.py文件,内容如下,注意,这里没有unittest的任何影子:
def Testfunc()