Visual Studio 测试播放列表架构在哪里?

Where is the Visual Studio test playlist schema?

我在 Visual Studio 2017 年使用 NUnit 测试适配器从测试资源管理器 window 进行测试。我使用一个测试播放列表文件,其中包含我想要 运行 的测试。该文件的内容如下所示:

<Playlist Version="1.0">
    <Add Test="MyAssemblyName.MyTestFixture.MyTestMethod()" />
</Playlist>

这些 Visual Studio 播放列表文件有架构吗?如果是这样,它在哪里?如果没有,您能否在此处提供播放列表文件的有效 XML 属性列表(<Add> 除外)?

我也试图找到一个 XSD,但我没有,所以我挖掘了 Visual Studio dll 并找到了这个 Microsoft.VisualStudio.TestWindow.Core.dll 我用 dnSpy 查看 C# 代码,我在 namespace Microsoft.VisualStudio.TestWindow.Internal.Playlists

中找到了这个 class PropertyRule

属性 个名字都是有效的

PropertyRule.properties = ImmutableArray.Create<ValueTuple<string, TestPropertyType, string>>(new ValueTuple<string, TestPropertyType, string>[]
{
    new ValueTuple<string, TestPropertyType, string>("Solution", TestPropertyType.Solution, string.Empty),
    new ValueTuple<string, TestPropertyType, string>("Project", TestPropertyType.ProjectName, "TestWindow_ProjectName"),
    new ValueTuple<string, TestPropertyType, string>("Namespace", TestPropertyType.NamespaceName, "TestWindow_NamespaceName"),
    new ValueTuple<string, TestPropertyType, string>("Class", TestPropertyType.ClassName, "TestWindow_ClassName"),
    new ValueTuple<string, TestPropertyType, string>("TargetFramework", TestPropertyType.TargetFramework, "TestWindow_TargetFramework"),
    new ValueTuple<string, TestPropertyType, string>("Outcome", TestPropertyType.Outcome, "TestWindow_Outcome"),
    new ValueTuple<string, TestPropertyType, string>("Trait", TestPropertyType.Trait, "TestWindow_Traits"),
    new ValueTuple<string, TestPropertyType, string>("Test", TestPropertyType.FullyQualifiedName, "TestWindow_FullyQualifiedName"),
    new ValueTuple<string, TestPropertyType, string>("TestWithNormalizedFullyQualifiedName", TestPropertyType.NormalizedFullyQualifiedName, "TestWindow_TestGroup"),
    new ValueTuple<string, TestPropertyType, string>("DisplayName", TestPropertyType.DisplayName, "TestWindow_DisplayName")
});

查看 Match 属性的代码

using System;
    
namespace Microsoft.VisualStudio.TestWindow.Internal.Playlists
{
  [Flags]
  public enum PropertyRuleMatchFlags
  {
    Contains = 0,
    Not = 1,
    Equals = 2,
    Subset = 4
  }
}

阅读代码,我能够编辑我的播放列表 XML 以忽略某些项目,因此所有其他项目都会自动添加!