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
今天了解下测试套件Test Suite,什么是测试套件,测试套件是由多个Test Case测试用例组成的,当然也可以由多个子测试套件组成. 接下来看下如果构建测试套件,构建测试套件的方法: 1.用unittest.TestSuite()实例化测试套件对象后,内部的addTest()方法对测试类内部的测试案例进行逐一添加. import unittest #导入unittest import time as t #导入time 设置别名 t from selenium import webdriv