2016-07-19 146 views
5

Come è possibile aggiungere progetti di test esistenti al menu di scelta rapida con clic destro per "Creazione di test di unità" in Visual Studio 2015?Come posso aggiungere ulteriori progetti di test al menu di scelta rapida "Crea test unitari" in Visual Studio 2015?

Mostra solo uno dei progetti di test (il progetto è stato creato utilizzando l'azione di contesto del clic destro). L'altro progetto è stato creato utilizzando la nuova procedura guidata del progetto e non è mostrato.

Missing Projects Available Unit Test Projects

Esiste un modo per aggiungere progetti unit test esistenti per l'elenco a discesa?

risposta

1

non ho immobilizzato quali fasi sono obbligatori, ma al di sotto sono i passi che mi hanno permesso di aggiungere un progetto esistente al Intellitest "Crea Unit Test" lista:

  • Riferimento Microsoft.Pex.Framework assemblaggio
  • Aggiungere il file "PexAssemblyInfo.cs" nella cartella speciale del progetto Proprietà. Modifica di conseguenza.
  • In CSPROJ, aggiungere tag <TestProjectType>"UnitTest"</TestProjectType>, in <PropertyGroup> nodo
  • In CSPROJ, aggiungere tag <IsCodedUITest>False</IsCodedUITest>, in <PropertyGroup> nodo (probabilmente non richiesto)
  • In Csproj file, aggiungere "{3AC096D0- A1C2-E12C-1390-A8335801FDAB}"(test tipo di progetto) per <ProjectTypeGuids> tag

Modifica: PexAssemblyInfo.cs campione conten t

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")] 
+0

A cosa serve PexAssemblyInfo.cs? – Silthus

+0

Definisce le impostazioni specifiche per Pex, come l'assemblaggio sotto test, l'assemblaggio referenziato e così via. Puoi copiare/incollare uno di questi da un progetto Intellitest generato automaticamente. – Alexis

+0

Non riesco a trovare un Assemblaggio che si chiami PEX o simile. Inoltre, la creazione di un progetto di test Xunit tramite la procedura guidata non crea un file PexAssemblyInfo.cs. E l'aggiunta delle linee TestProjectType e IsCodedUiTest non rende il projekt show nella procedura guidata. – Silthus

Problemi correlati