Python script to write test cases

1. Test case writing has setup and teardown
2. Single function-test-test case-one start and end;
3. Multiple functions-separate test-multiple test cases-two same start and end
4. Consider The beginning and end of the merger are encapsulated into a class
5. Currently, all functions and functions to be tested are written in the same python script,
which is inconvenient to manage, so now you need to write your own script for each function and function;

The implementation of the two use cases is different:

if __name__=='__main__':
    unittest.main():
if __name__=='__main__':
    runner=unittest.TextTestRunner()
    runner.run(suite)

Python files can be used as modules (import and import) and directly used:

__name__ is a built-in attribute of the module in Python, which is a .python calling method;

__main__ is used directly;

if __name__=='__main__':
	unittest.main():
#按照ASCII编码的顺序来执行

 

Published 22 original articles · praised 5 · visits 1040

Guess you like

Origin blog.csdn.net/weixin_37018468/article/details/105477323
Recommended