简体   繁体   English

使用unittest.TestCase的运行方法

[英]Using run method of unittest.TestCase

有人可以指出我在python中使用unittest.Testcaserun()方法的示例吗?

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.

相关问题 是否可以从 python unittest.TestCase 运行单个测试方法并引用该方法? - Is it possible to run a single test method from a python unittest.TestCase with a reference to the method? 对于unittest.TestCase子类,当run table执行runcases时无法获取class属性 - For unittest.TestCase subclass, unable to get class attribute when testcases are executed by run method 使用unittest.TestCase子类Python的方法调用测试方法 - Invoking Test Methods with a Method for a unittest.TestCase Subclass Python 验证数组长度相等的Unittest.TestCase方法 - Unittest.TestCase Method to Verify Arrays are of Equal Length 在unittest.TestCase中重载了failUnlessEqual - Overloading failUnlessEqual in unittest.TestCase 在python中重载unittest.testcase - overloading unittest.testcase in python __init__ 用于 unittest.TestCase - __init__ for unittest.TestCase 运行所有使用..import导入的unittest.TestCase * - Running all unittest.TestCase imported using from .. import * 如何重用使用unittest.testcase编写的测试 - how to reuse tests written using unittest.testcase 我正在使用unittest.TestCase如果我有多个测试用例,它将无法运行。 仅运行1个测试用例 - I am using unittest.TestCase if i have more than 1 test case it will not run. Only 1 test case runs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM