我正在使用Nose从脚本运行测试。我希望能够指定xunit xml输出文件。文档说我可以使用--xunit-file = FILE选项来实现。

我有

noseargs = ['--with-xunit', '--xunit-file=output.xml', '--tests=mytest']
nose.run(argv=noseargs)


运行此命令后,不存在output.xml文件。我发现是否可以交换两个参数,因此它看起来像:

noseargs = ['--xunit-file=output.xml', '--with-xunit', '--tests=mytest']
nose.run(argv=noseargs)


它将在我的工作目录中创建一个nesttests.xml文件。因此,看起来--with-xunit参数首先需要处理,然后需要指定文件。关于我应该如何指定丢失的文件,有什么特别之处吗?

最佳答案

鼻子吃了argv的第一个参数,因为在命令行上它是程序的名称。

这适用于:

noseargs = ['foo', '--with-xunit', '--xunit-file=output.xml', '--tests=mytest']
nose.run(argv=noseargs)

关于python - 如何以编程方式为 Nose 指定xml输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14969265/

10-12 21:01