All test under a load path through the embodiment discover

unittest Import

# can call the Discover once more scripts
# test_dir the path to test scripts
# pattern matching rule script name
test_dir = "./test_case"
the Discover = unittest.defaultTestLoader.discover (test_dir, pattern = "* .py the Test")
# All matches start with test py file test_case directory, execute all test cases under these py file


IF __name__ == "__main__":
Runner = unittest.TextTestRunner ()
runner.run (the Discover)

Guess you like

Origin www.cnblogs.com/wenjing2019/p/11958831.html