gpt4 book ai didi

visual-studio - 如何将其他测试项目添加到 Visual Studio 2015 中的 "Create Unit Tests"上下文菜单?

转载 作者:行者123 更新时间:2023-12-04 15:54:50 25 4
gpt4 key购买 nike

如何将现有的测试项目添加到 Visual Studio 2015 中“创建单元测试”的右键单击上下文菜单中?

它只显示一个测试项目(该项目是使用右键单击上下文操作创建的)。另一个项目是使用新项目向导创建的,未显示。

Missing Projects
Available Unit Test Projects

有没有办法将现有的单元测试项目添加到下拉列表中?

最佳答案

我还没有确定哪些步骤是强制性的,但下面是允许我将现有项目添加到 Intellitetest“创建单元测试”列表的步骤:

  • 引用 Microsoft.Pex.Framework组装
  • 在 Properties 项目的特殊文件夹中添加“PexAssemblyInfo.cs”文件。相应地进行编辑。
  • 在 .csproj 文件中,添加 <TestProjectType>"UnitTest"</TestProjectType>标签,在 <PropertyGroup>节点
  • 在 .csproj 文件中,添加 <IsCodedUITest>False</IsCodedUITest>标签,在 <PropertyGroup>节点(可能不需要)
  • 在 .csproj 文件中,将“{3AC096D0-A1C2-E12C-1390-A8335801FDAB}”(测试项目类型)添加到 <ProjectTypeGuids>标签


  • 编辑: PexAssemblyInfo.cs 内容示例
    using Microsoft.Pex.Framework.Coverage;
    using Microsoft.Pex.Framework.Creatable;
    using Microsoft.Pex.Framework.Instrumentation;
    using Microsoft.Pex.Framework.Settings;
    using Microsoft.Pex.Framework.Validation;

    // Microsoft.Pex.Framework.Settings
    [assembly: PexAssemblySettings(TestFramework = "xunit-2.0")]

    // Microsoft.Pex.Framework.Instrumentation
    [assembly: PexAssemblyUnderTest("{YOUR-PROJECT-NAME}")]
    [assembly: PexInstrumentAssembly("System.Runtime.Extensions")]
    [assembly: PexInstrumentAssembly("System.Linq.Expressions")]
    [assembly: PexInstrumentAssembly("System.Threading")]
    [assembly: PexInstrumentAssembly("System.Reflection.Extensions")]
    [assembly: PexInstrumentAssembly("System.Reflection")]
    [assembly: PexInstrumentAssembly("System.Diagnostics.Debug")]
    [assembly: PexInstrumentAssembly("System.Runtime")]
    [assembly: PexInstrumentAssembly("System.Threading.Tasks")]
    [assembly: PexInstrumentAssembly("System.Collections")]

    // Microsoft.Pex.Framework.Creatable
    [assembly: PexCreatableFactoryForDelegates]

    // Microsoft.Pex.Framework.Validation
    [assembly: PexAllowedContractRequiresFailureAtTypeUnderTestSurface]
    [assembly: PexAllowedXmlDocumentedException]

    // Microsoft.Pex.Framework.Coverage
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Runtime.Extensions")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Linq.Expressions")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Threading")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Reflection.Extensions")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Reflection")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Diagnostics.Debug")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Runtime")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Threading.Tasks")]
    [assembly: PexCoverageFilterAssembly(PexCoverageDomain.UserOrTestCode, "System.Collections")]

    关于visual-studio - 如何将其他测试项目添加到 Visual Studio 2015 中的 "Create Unit Tests"上下文菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38454994/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com