什么是DDT
ddt是Python的第三方库。ddt模块提供了创建数据驱动的测试。
安装DDT:
PS D:\Python\Scripts> D:\Python\Scripts\pip.exe install ddt
Collecting ddt
Downloading https://files.pythonhosted.org/packages/cf/f5/f83dea32dc3fb3be1e5afab8438dce73ed587740a2a061ae2ea56e04a36d/ddt-1.2.1-py2.py3-none-any.whl
Installing collected packages: ddt
Successfully installed ddt-1.2.1
PS D:\Python\Scripts>
新建待测类:
__author__ = 'Hello'
class PrintMsg:
def fun_1(self,a):
print("获取的参数是%s"%a)
def fun_2(self,a,b):
print("获取的第A个参数是%s"%a)
print("获取的第B个参数是%s"%b)
def fun_3(self,a,b,c):
print("获取的第A个参数是%s"%a)
print("获取的第B个参数是%s"%b)
print("获取的第C个参数是%s"%c)
写一个测试类:
__author__ = 'Hello'
import unittest
from class_ddt.print_msg import PrintMsg
class TestPrintMsg(unittes