为 vstest.console.exe 指定结果文件名 [英] Specifying results filename for vstest.console.exe

查看:27
本文介绍了为 vstest.console.exe 指定结果文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个愚蠢的问题,但有人知道如何指定 VSTEST.Console.exe 运行的输出 filename 吗?我的命令行如下:

May be a silly question, but does anybody know how to specify the output filename of a VSTEST.Console.exe run? My command line is as follows:

 vstest.console.exe [assembly] /logger:trx

在运行结束时,控制台中出现以下内容:

At the end of the run, the following comes up in the console:

 ResultsFile: somepathTestResults{username}_{workstation} {timestamp}.trx

我尝试使用 .runsettings 文件来指定输出位置,但这似乎只能控制输出目录,而不能控制输出文件.还没有发现任何其他似乎可以控制它的东西.

I tried using the .runsettings file to specify the output location, but that only seems to control the output directory, but not the output file. Have not found anything else that would seem to control it.

我想解析 TRX 文件并从中生成报告(这已经有效,但如果我无法指定 TRX 文件的输出路径,我将不知道从脚本!)

I want to parse the TRX file and generate a report out of it (this already works, but if I can't specify the output path of the TRX file, I won't know where to pick it up from in the scripts!)

我必须在这里遗漏一些东西......

I have to be missing something here...

推荐答案

See @AnaFranco's answer - 显然从 VS2017 开始,文件名可以这样配置:

See @AnaFranco's answer - apparently since VS2017 the file name can be configured like so:

vstest.console.exe [assembly] /logger:trx;LogFileName=[filename].trx

我会将旧答案留给后代和 2017 年之前的版本.

I'll leave the old answer for posterity and pre-2017 versions.

不,您没有遗漏任何东西.TRX 记录器不支持任何参数(与 TFS 发布者记录器不同).

Nope, you're not missing anything. The TRX logger doesn't support any parameters (unlike the TFS publisher logger).

记录器程序集位于 "C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDECommonExtensionsMicrosoftTestWindowExtensionsMicrosoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll".如果您在您最喜欢的 .NET 反编译器中查看它,您将看到方法 TrxLogger.GetTrxFileName.它使用有关当前测试运行的一些基本知识来生成表单 {username}_{workstation} {timestamp}.trx 的损坏名称,并且没有明显的可配置方式.

The logger assembly is located in "C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDECommonExtensionsMicrosoftTestWindowExtensionsMicrosoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll". If you check it out in your favorite .NET decompiler, you'll see the method TrxLogger.GetTrxFileName. It uses some basic knowledge about the current test run to produce the mangled name of form {username}_{workstation} {timestamp}.trx and is in no appreciable way configurable.

据我所知,除非另有配置,否则 TRX 文件是在当前工作目录下的 TestResults 文件夹中创建的.你可以做的是:

As far as I can tell, the TRX file is created in the TestResults folder under the current working directory unless otherwise configured. What you can do is:

  • 创建一个新的临时文件夹
  • 将当前目录更改为它
  • 运行测试运行器
  • 使用您最喜欢的递归文件搜索方法扫描结果 .trx 文件的文件夹,您就完成了
  • Create a new temporary folder
  • Change the current directory to it
  • Run the test runner
  • Scan the folder for the result .trx file using your favorite recursive file search method and you're done

至少这就是我在我们的构建中所做的(MSBuild,sob):

At least that is what I do in our build (MSBuild, sob):

<ItemGroup>
  <TestResult Include="***.trx"/>
</ItemGroup>

即收集当前目录下的所有.trx文件,塞进@(TestResult)项组中进行进一步处理.

I.e, gather all .trx files under the current directory and stuff them into the @(TestResult) item group for further processing.

这篇关于为 vstest.console.exe 指定结果文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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