借鉴文章:https://cloud.tencent.com/developer/article/1504824
脚本工具:PyCharm
这篇主要是想记录下我操作过程中遇到的:(忽略的的case报错!)
问题一:Directory目录与Python package目录
问题二:普通的打印脚本与unittest case脚本
#一键执行所有脚本 import unittest def all_case(): case_dir = "/Users/meizhuo/Documents/XX/interfaceTest/testcases/scdn_center" testcase = unittest.TestSuite() discover = unittest.defaultTestLoader.discover(case_dir,pattern="*.py",top_level_dir=None) for test_suit in discover: for test_case in test_suit: print(test_case) testcase.addTest(test_case) print(testcase) return testcase if __name__ == '__main__': runner = unittest.TextTestRunner() runner.run(all_case())
import os import sys # lst = os.listdir(os.getcwd()) # # for c in lst: # if os.path.isfile(c) and c.endswith('.py') and c.find("all_test") == -1: # print(c) # os.system(os.path.join(os.getcwd(),c)) from testcases.tool_case import get_all_edges, get_all_rooms sys.modules['get_all_edges'].__dict__.clear() sys.modules['get_all_rooms'].__dict__.clear() get_all_edges.py get_all_rooms.py