import unittest,parameterized import BeautifulReport #数据驱动 #代码驱动 #关键字驱动 data =[ ['admin','123456',True,'正常用户登录'], ['admin','111456',False,'黑名单用户登录'], ['admnn','123456',False,'冻结用户登录'] ] def login(user,password): if user=='admin' and password=='123456': return True return False class LoginTest(unittest.TestCase): @parameterized.parameterized.expand(data) def test_login(self,user,password,expect,desc): # '''登录用例''' self._testMethodDoc=desc #自已指定用例描述 result=login(user,password) self.assertEquals(expect,result) # unittest.main() bf=BeautifulReport.BeautifulReport(unittest.makeSuite(LoginTest)) bf.report(filename='KK20230302报告',description='自动化测试标题title')