如何在Visual Studio 2015中的“创建单元测试”的右键单击上下文菜单中添加现有的测试项目?
它只显示一个测试项目(项目是使用右键单击上下文操作创建的)。另一个项目是使用新项目向导创建的,未显示。
有没有办法将现有的单元测试项目添加到下拉列表中?
答案 0 :(得分:1)
我没有确定哪些步骤是强制性的,但下面是允许我将现有项目添加到Intellitest"创建单元测试"列表:
Microsoft.Pex.Framework
汇编<TestProjectType>"UnitTest"</TestProjectType>
node <PropertyGroup>
标记
<IsCodedUITest>False</IsCodedUITest>
node 中添加<PropertyGroup>
标记(可能不需要) <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")]