如何使用 dotnet test 命令发布结果 [英] How to publish results using dotnet test command

查看:20
本文介绍了如何使用 dotnet test 命令发布结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 dotnet core 编写的测试项目.这需要以 XML 或 HTML 格式发布结果.有没有办法可以使用相同的命令将结果发布到特定目录?
--result-directory 对我不起作用

I have a test project written in dotnet core. This need to publish the results in an XML or HTML format. Is there a way I can publish the results to a particular directory using the same command?
--result-directory is not working for me

推荐答案

您可以通过执行 dotnet test --help 来查看所有 dotnet test 选项.其中一个选项是 -l, --logger,它提供了一些重要信息:

You can see all the dotnet test options by executing dotnet test --help. One of the options is -l, --logger, which gives some great information:

Specify a logger for test results.
Examples:
Log in trx format using a unqiue file name: --logger trx
Log in trx format using the specified file name: --logger "trx;LogFileName=<TestResults.trx>"
More info on logger arguments support:https://aka.ms/vstest-report

该支持链接 https://aka.ms/vstest-report 包含完整信息.

That support link https://aka.ms/vstest-report, has the full information.

所以要回答你的具体问题,你可以说

So to answer your specific question, you can say

dotnet test -l:trx;LogFileName=C: empTestOutput.xml

将结果发布到特定目录.

To publish the results to a particular directory.

另一个选项是在 test.csproj 中设置 MSBuild 属性:

Another option is setting MSBuild properties in your test.csproj:

<PropertyGroup>
  <VSTestLogger>trx</VSTestLogger>
  <VSTestResultsDirectory>C:	emp</VSTestResultsDirectory>
</PropertyGroup>

它告诉记录器将文件放在 C: emp 目录中.

Which tells the logger to put the file in the C: emp directory.

这篇关于如何使用 dotnet test 命令发布结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆