简体   繁体   English

如何从几个模块运行所有测试用例?

[英]How to run all test-cases from several modules?

I have several modules full of test-cases and would like to create one module that runs them all. 我有几个充满了测试用例的模块,并且想创建一个可以运行所有模块的模块。 I tried loading the tests in each of the modules using TestLoader.loadTestFromModule , but it always returns empty test-suites. 我尝试使用TestLoader.loadTestFromModule在每个模块中加载测试,但它始终返回空的测试套件。 What is the easiest way to achieve this? 最简单的方法是什么?

Have a look at nose . 看看鼻子 It can also be called programmatically, and it may thus be used to call your tests once you've configured it. 也可以通过编程方式调用它,因此在配置它后可以将其用于调用测试。

Ok, the problem there was that I handed in the modules-names as strings, when I should have been handing in module-objects like this: 好的,问题是当我应该像这样处理模块对象时,将模块名称作为字符串处理:

import unittest
import SomeTestModule

loader = unittest.TestLoader()
loader.loadTestsFromModule(SomeTestModule)

Really a beginners mistake. 真的是初学者的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 ERROR: usage: _jb_pytest_runner.py error running the SHAP test-cases with PyCharm? - How to solve the ERROR: usage: _jb_pytest_runner.py error running the SHAP test-cases with PyCharm? 从多个模块聚合多个测试用例以在PyDev TestRunner中运行 - Aggregating multiple test cases from multiple modules to run in PyDev TestRunner 为 python setuptools 入口点插件编写测试用例 - Write test-cases for python setuptools entry-points plugins 如何仅运行测试套件中添加的测试用例而不是该类中可用的所有测试用例? - How to run only the test cases added in a test suite and not all the test cases available in the class? [Test Setup for Test Modules] CANoe中如何运行所有的TestModule - How to run all TestModule in [Test Setup for Test Modules] CANoe 如何运行 python 中编写的 Cypress 测试用例? - how to run Cypress test cases written in python? 如何按照声明的顺序运行单元测试测试用例 - How to run unittest test cases in the order they are declared 如何在机器人框架中运行特定的测试用例 - how to run specific test cases in robot framework 如何在套件设置中运行测试用例? - How to run test cases as part of suite setup? 如何使用 Robot Framework 从测试套件运行特定的测试用例 - How to run specific test cases from a test suite using Robot Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM