Python 使用nose分别运行单元测试和集成测试(驻留在不同的目录中)
我想知道这一点已经有一段时间了,但我不知道如何将选项传递到Python 使用nose分别运行单元测试和集成测试(驻留在不同的目录中),python,unit-testing,testing,integration-testing,nose,Python,Unit Testing,Testing,Integration Testing,Nose,我想知道这一点已经有一段时间了,但我不知道如何将选项传递到nosetests,以运行驻留在不同子目录中的不同测试。包目录结构的示例: my_package/ |-- my_module1/ |-- tests/ |-- unit/ | ... a bunch of unit tests |-- integration/ |... a bunch of integration tests |-- my_module2/
nosetests
,以运行驻留在不同子目录中的不同测试。包目录结构的示例:
my_package/
|-- my_module1/
|-- tests/
|-- unit/
| ... a bunch of unit tests
|-- integration/
|... a bunch of integration tests
|-- my_module2/
|-- tests/
|-- unit/
| ... a bunch of unit tests
|-- integration/
|... a bunch of integration tests
如果我只想在我的所有模块中执行单元测试(在tests/unit/
子目录中的所有测试),我将如何使用nosetests库来执行呢?我认为--where
或--match
nosetests参数可以帮助您:
-w WHERE,--WHERE=WHERE
在此目录中查找测试。可以指定
多次。传递的第一个目录将是
用作工作目录,代替当前目录
工作目录,这是默认目录。其他人会的
将添加到要执行的测试列表中。[NOSE_WHERE]
-m REGEX,--match=REGEX,--testmatch=REGEX
文件、目录、函数名和类名
将考虑与此正则表达式匹配的
测验。默认值:(?:^ |[\b./-])[Tt]est
[鼻子测试匹配]
另外,请参见
但是,实际上,我更喜欢在根级别使用tests dir:谢谢,关键是我不想在传递
-w
选项时逐个指定每个目录(假设我有一个大型项目)。我也查看了-m
,但到目前为止还没有弄清楚。我想我得再深入一点。