我想从Python脚本运行NoseTest . 但我不仅要运行它,还要测量测试覆盖率 .
刚才我有以下代码:
import os
import sys
import nose
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
import tests
if __name__ == "__main__":
config = nose.config.Config(verbosity=3, stopOnError=False, argv=["--with-coverage"])
result = nose.run(module=tests, config=config)
我应该添加什么来获取我的报道?
2 回答
编辑:要使用nose.run()运行插件,您需要使用'plugins'关键字:
http://nose.readthedocs.org/en/latest/usage.html#using-plugins
您的代码已全部设置 - 您需要通过跑步者启用覆盖 . 简单地像这样运行鼻子:
这里有更多选择:
http://nose.readthedocs.org/en/latest/plugins/cover.html
仅供参考,您可能需要运行以下内容才能获得覆盖率:
地狱啊!经过鼻子测试的一些小调试后,我成功了!