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

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

问题描述

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

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: somepath\TestResults\{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...

推荐答案

参见@AnaFranco的答案-显然自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.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions\Microsoft.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.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions\Microsoft.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天全站免登陆