【问题标题】:Exclude Selenium test methods in C# test project using VSTS使用 VSTS 在 C# 测试项目中排除 Selenium 测试方法
【发布时间】:2018-03-28 13:54:03
【问题描述】:

我有一个 Selenium 测试项目,该项目已签入 VSTS 存储库,我正在尝试在 VSTS 中创建计划构建定义,以运行构建项目程序集“SeleniumTest.dll”中包含的测试函数子集。

作为构建定义的一部分,我有一个 VS 测试任务,如下所示:

为了排除我不想运行的所有测试类,我包含了以下运行设置文件。

<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Configuration>
          <CodeCoverage>

            <Functions>  
              <Exclude>  
                <!-- Exclude methods in the SeleniumTests.Tests\ZoneTest: --> 
                <Function>SeleniumTests.Tests\.LoginTest\..*</Function>
                <Function>SeleniumTests.Tests\.ProfileTest\..*</Function>
              </Exclude>  
            </Functions>   

          </CodeCoverage>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

我不确定是否需要运行设置文件来实现这一目标。如果不是应该使用什么方法?

【问题讨论】:

    标签: selenium azure-devops build-definition


    【解决方案1】:

    Visual Studio task 包含可以过滤测试的测试过滤条件设置。

    允许的运算符:

    • = 表示完全匹配

    • != 表示完全不匹配

    • ~ 表示包含查找

    更多信息:TestCase filter

    顺便说一句,您提供的 runsettings 文件用于 CodeCoverage 而不是运行过滤器测试。

    【讨论】:

    • 我相信这仅限于 .NET CORE 和 .NETStandard 项目。不幸的是,我的项目是一个传统的 .NET Framework 项目。我最后的办法是将项目转换为 .NET CORE
    猜你喜欢
    • 2016-08-10
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    相关资源
    最近更新 更多