我已经使用以下命令安装了nose2:
pip3 install nose2我已经使用以下命令在自定义路径中安装了覆盖率:
pip3 install --target=/tmp/coverage_pkg coverage我想要执行测试用例并生成覆盖报告。有办法将安装在自定义路径中的覆盖插件映射到nose2吗?
我试图执行以下命令:
nose2 --with-coverage我得到了以下输出:
Warning: you need to install "coverage_plugin" extra requirements to use this plugin. e.g. `pip install nose2[coverage_plugin]`
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK我希望使用安装在自定义路径中的覆盖包生成覆盖率报告。
有人能解释一下我是否能做到这一点吗?
发布于 2022-11-18 14:43:43
我能够使用以下命令实现这一点:
cd <custom location where packages are installed>
python3 -m nose2 --with-coverage -s "path_to_source_dir" --coverage "path_to_source_dir"您需要停留在安装nose2和覆盖率的位置(自定义dir/例如: /tmp/ coverage _pkg)。
对于更多的配置和生成junit报告和覆盖率报告,我们可以使用unittest.cfg文件和.coveragerc来控制覆盖率报告和单元测试。
样本unittest.cfg
[unittest]
plugins = nose2.plugins.junitxml
start-dir =
code-directories =
test-file-pattern = *_test.py
test-method-prefix = t
[junit-xml]
always-on = True
keep_restricted = False
path = nose2-junit.xml
test_fullname = False
[coverage]
always-on = True
coverage =
coverage-config = .coveragerc
coverage-report = term-missing
xml样本.coveragerc
[run]
branch = True
[xml]
output =coverage.xml
[report]
show_missing = True
omit=
/test/*
/poc1.py
/bin/__init__.py使用下面的命令来使用配置文件并生成单元测试报告和覆盖率报告。
python3 -m nose2 --config "<path to config file>/unittest.cfg"发布于 2022-11-16 10:12:26
错误消息包括所需的确切命令:
pip install nose2[coverage_plugin]https://stackoverflow.com/questions/74449669
复制相似问题