[英]Using run method of unittest.TestCase
有人可以指出我在python中使用unittest.Testcase
的run()
方法的示例吗?
Generally, you don't need to use run()
method yourself when writing the tests. 通常,编写测试时不需要自己使用
run()
方法。 Your test classes inherit this from your test base classes. 您的测试类从您的测试基类继承了它。
When you run the tests you use a launcher like python -m unittest
the unit test runner then internally takes care of calling run()
. 当您运行测试时,您可以使用
python -m unittest
之类的启动器来运行单元测试运行器,然后在内部负责调用run()
。 Unless you have some very specific reason you do not need to care or think run()
. 除非您有一些非常具体的原因,否则您无需关心或考虑
run()
。
Examples how to run unit tests: 示例如何运行单元测试:
python -m unittest test_module1 test_module2
python -m unittest test_module.TestClass
python -m unittest test_module.TestClass.test_method
https://docs.python.org/3.4/library/unittest.html#command-line-interface https://docs.python.org/3.4/library/unittest.html#command-line-interface
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.