一.问题描述
在做自动化测试时,想要同时执行多个case文件,便创建了run_case.py作为多个case文件执行的总入口
目录结构如下:
seleniumpython下chapter3文件夹,
chapter3下case文件夹(存放case),其下case有:
chapter3下run文件夹(执行多个模块下的case)
run_case.py文件代码如下:
#coding=utf-8
import unittest
import os
class RunCase(unittest.TestCase):
def test001(self):
print("当前工作目录--->",os.getcwd())
# dir = os.getcwd() + "\chapter3\case"
dir = os.path.join(os.getcwd(),"/chapter3/case")
pattern = "unittest_case4*.py"
suite = unittest.defaultTestLoader.discover(dir,pattern)
unittest.TextTestRunner().run(suite)
if(__name__ == "__main__"):
unittest.main()
在终端以.py方式运行报错: