tfs - 在 TFS 中,如何使用自定义记录器执行测试运行?

标签 tfs automated-tests

我想使用自定义记录器在 TFS 中运行我的自动化测试。通常,您可以通过将类似 /Logger:MyCustomLogger 的内容添加到 Visual Studio 测试任务的 Other Console Options 部分来执行此操作。

您可以选择按装配、测试运行 ID 或测试计划来选择测试。如果选择测试运行或测试计划,则无法设置其他控制台选项值。根据文档:

Other console options that can be passed to vstest.console.exe, as documented here.

These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.

我认为那是因为它使用 TCM.exe 而不是 VSTest.Console.Exe,并且 TCM 不采用相同的控制台选项,但不完全确定。

根据上面的引述,“可以使用设置文件来指定选项”。我的问题是:什么设置文件允许您提供记录器? RunSettings 不支持它(虽然可以解决 here )。

那么有解决办法吗?有没有办法在运行测试计划时提供记录器?

最佳答案

请查看this documentation :

Runsettings via Logger node in the LoggerRunSettings section. Here is a sample on how this can be specified:

<RunSettings>
    <LoggerRunSettings>
        <Loggers>
            <Logger friendlyName="sampleLoggerwithParameters">
                <Configuration>
                    <Key1>Value1</Key1>
                    <Key2>Value2</Key2>
                </Configuration>
            </Logger>
            <Logger uri="logger://sample/sampleLoggerWithoutParameters1"
                    friendlyName="sampleLoggerWithoutParameters1" />
            <Logger uri="logger://sample/sampleLoggerWithoutParameters2"
                    assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,

Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" friendlyName="sampleLoggerWithoutParameters2" />

This loads and initializes:

  • Logger with friendlyName="sampleLoggerwithParameters". Key1=Value1 and Key2=Value2 are passed as dictionary parameters to the logger while initialization. i.e.
    SampleLoggerWithParameters.Initialize(TestLoggerEvents events,<br/> Dictionary<string, string> parameters) is invoked with parameters = {{"Key1", "Value1"}, {"Key2", "Value2"}}
  • Logger with uri="logger://sample/sampleLoggerWithoutParameters1". FriendlyName is ignored in this case as uri takes more precedence.
  • Logger with assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,<br/> Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral,<br/> PublicKeyToken=xxxxxxxxxxxxxxxx". Uri and friendlyName are ignored in this case as assemblyQualifiedName takes more precedence.

关于tfs - 在 TFS 中,如何使用自定义记录器执行测试运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51212536/

相关文章:

visual-studio-2012 - 对 VS 2012 合并工具的命令行访问

c# - TFS API - 如何从特定团队项目中获取工作项

testing - 手动测试用例中的自定义参数

c# - 如何使用MTM将参数值从TFS中的测试用例传递到单元测试方法中的测试方法?

java - 如何在 Selenium Webdriver Java 中设置多个代理

selenium - 使用 Phantomjs/Selenium(来自 R)进行网页抓取,设置元素值

testing - 我使用的测试技术有名称吗?

git - 如何与 Jenkins 持续集成管理数据库

tfs - 无法导入工作项类型定义: Microsoft. TeamFoundation.WorkItemTracking.Server.ProvisioningImportEventsCallback

java - 开始时的 LeanFT 空指针