Visual Studio 测试播放列表模式的位置在哪里?

3

我正在使用 NUnit Test Adapter 在 Visual Studio 2017 的测试资源管理器窗口中运行测试。我使用一个测试播放列表文件,其中包含我想要运行的测试。该文件的内容如下:

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

这些Visual Studio播放列表文件是否有模式?如果有,它在哪里?如果没有,您可以在此提供播放列表文件的有效XML属性列表吗(除了<Add>)?

你的目标是什么?我的目标是将播放列表定义为测试项目列表,而不是单个测试列表。随着我添加单元测试到我的项目中,我希望它们能够自动添加到我的播放列表中。但我还没有找到一种方法来实现这一点。 - Wallace Kelly
@WallaceKelly 看看我的回答,我能够做到你想要的。 - Alberto Monteiro
1个回答

3

我也试图寻找XSD文件,但是没有找到。所以我搜索了Visual Studio的dll文件,最终找到了Microsoft.VisualStudio.TestWindow.Core.dll。我使用了dnSpy来查看C#代码,在Microsoft.VisualStudio.TestWindow.Internal.Playlists命名空间下找到了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文件以忽略某些项目,这样所有其他项目就可以自动添加了!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接