unittest基本原理: ♦整个平台的搭建使用的是python的unittest测试框架,这里简单介绍下unittest模块的简单应用. ♦unittest是python的标准测试库,相比于其他测试框架是python目前使用最广的测试框架. ♦unittest有四个比较重要的概念是test fixture, test case, test suite, test runner, . ♦test fixture:The test fixture is everything we need to…
接上一篇doCleanups说明,这次介绍下另一个很好用的函数:addCleanup 还是老规矩,看官方文档说明: addCleanup(function, *args, **kwargs)¶ Add a function to be called after tearDown() to cleanup resources used during the test. Functions will be called in reverse order to the order they are a…
找出要测试的testcase,并加入到Testsuite,运行Testsuite并把结果给TestResult1.创建TestSuite实例对象suite = unittest.TestSuite() 2.构建suite a. suite = unittest.TestLoader().discover("文件夹名或者包名") suite = unittest.TestLoader().discover("xxx文件夹") b. suite = unittest.T…
四个部分: test fixture A test fixture represents(代表) the preparation needed to perform one or more tests, and any associate cleanup actions. This may involve, for example, creating temporary or proxy databases, directories, or starting a server process.…
偶看unittest官方文档中,发现一个很好用的功能函数doCleanups,看看官方是怎么解释的: doCleanups() This method is called unconditionally after tearDown(), or after setUp() if setUp() raises an exception. It is responsible for calling all the cleanup functions added by addCleanup(). If…