├── .gitattributes ├── .gitignore ├── CreateUnitTests.xUnit ├── CreateUnitTests.xUnit.csproj ├── Properties │ └── AssemblyInfo.cs ├── packages.config ├── xUnitFrameworkProvider.cs ├── xUnitSolutionManager.cs ├── xUnitUnitTestClassManager.cs └── xUnitUnitTestProjectManager.cs ├── README.md ├── xUnit.net.TestGenerator.sln └── xUnit.net.TestGenerator ├── Properties └── AssemblyInfo.cs ├── license.txt ├── packages.config ├── preview.png ├── source.extension.vsixmanifest ├── xUnit.net.TestGenerator.csproj └── xUnit.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/CreateUnitTests.xUnit.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A} 8 | Library 9 | Properties 10 | xUnit.net.TestGenerator 11 | xUnit.net.TestGenerator 12 | v4.7.2 13 | 512 14 | 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 68 | 69 | ..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll 70 | False 71 | False 72 | 73 | 74 | False 75 | True 76 | c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies\envdte80.dll 77 | 78 | 79 | ..\packages\Microsoft.VisualStudio.OLE.Interop.16.10.31320.204\lib\net45\Microsoft.VisualStudio.OLE.Interop.dll 80 | 81 | 82 | ..\packages\Microsoft.VisualStudio.Shell.Interop.16.10.31320.204\lib\net45\Microsoft.VisualStudio.Shell.Interop.dll 83 | 84 | 85 | ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.16.10.31320.204\lib\net45\Microsoft.VisualStudio.Shell.Interop.8.0.dll 86 | 87 | 88 | ..\packages\Microsoft.VisualStudio.TestPlatform.14.0.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll 89 | 90 | 91 | ..\packages\Microsoft.VisualStudio.TestPlatform.14.0.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll 92 | 93 | 94 | C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestGeneration\Microsoft.VisualStudio.TestPlatform.TestGeneration.dll 95 | 96 | 97 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.16.10.31320.204\lib\net45\Microsoft.VisualStudio.TextManager.Interop.dll 98 | 99 | 100 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.16.10.31320.204\lib\net45\Microsoft.VisualStudio.TextManager.Interop.8.0.dll 101 | 102 | 103 | ..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll 104 | False 105 | False 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | ..\packages\VSSDK.VSLangProj.7.0.4\lib\net20\VSLangProj.dll 118 | False 119 | False 120 | 121 | 122 | ..\packages\VSSDK.VSLangProj.7.0.4\lib\net20\VSLangProj2.dll 123 | False 124 | False 125 | 126 | 127 | ..\packages\VSSDK.VSLangProj.8.8.0.4\lib\net20\VSLangProj80.dll 128 | False 129 | False 130 | 131 | 136 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CreateUnitTests.xUnit")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CreateUnitTests.xUnit")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2c19e5de-4d51-44b2-a885-49cab0e73c9a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/xUnitFrameworkProvider.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Copyright (c) 2017 Yowko Tsai 3 | // *********************************************************************** 4 | 5 | using System; 6 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Data; 7 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; 8 | using System.ComponentModel.Composition; 9 | using EnvDTE; 10 | //using static VSLangProj.PrjKind; 11 | using System.Linq; 12 | using VSLangProj80; 13 | using VSLangProj; 14 | 15 | namespace xUnit.net.TestGenerator 16 | { 17 | /// 18 | /// The provider for the NUnit 3 unit test framework. 19 | /// 20 | [Export(typeof(IFrameworkProvider))] 21 | public class xUnitFrameworkProvider : FrameworkProviderBase 22 | { 23 | /// 24 | /// Unsupported testable project type guids. 25 | /// 26 | private readonly Guid[] unsupportedProjects = 27 | { 28 | Guid.Parse("BC8A1FFA-BEE3-4634-8014-F334798102B3"), // Windows Store 29 | Guid.Parse("C089C8C0-30E0-4E22-80C0-CE093F111A43"), // Phone Silverlight 30 | Guid.Parse("76F1466A-8B6D-4E39-A767-685A06062A39"), // Phone Appx 31 | Guid.Parse("786C830F-07A1-408B-BD7F-6EE04809D6DB"), // Portable app 32 | Guid.Parse("A1591282-1198-4647-A2B1-27E5FF5F6F3B"), // Silverlight 33 | }; 34 | 35 | /// 36 | /// Service provider reference. 37 | /// 38 | private readonly IServiceProvider serviceProvider; 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The service provider to use to get the interfaces required. 44 | /// The configuration settings object to be used to determine how the test method is generated. 45 | /// The naming object used to decide how projects, classes and methods are named and created. 46 | /// The directory object to use for directory operations. 47 | [ImportingConstructor] 48 | public xUnitFrameworkProvider(IServiceProvider serviceProvider, IConfigurationSettings configurationSettings, INaming naming, IDirectory directory) 49 | : base(new xUnitSolutionManager(serviceProvider, naming, directory), new xUnitUnitTestProjectManager(serviceProvider, naming), new xUnitUnitTestClassManager(configurationSettings, naming)) 50 | { 51 | this.serviceProvider = serviceProvider; 52 | } 53 | 54 | 55 | /// 56 | /// Gets the name of the provider. 57 | /// 58 | public override string Name => "xUnit.net 2.0"; 59 | 60 | /// 61 | /// Gets the name of the assembly. 62 | /// 63 | public override string AssemblyName => "xunit.core"; 64 | 65 | /// 66 | /// Returns a value indicating whether a is a test project for the unit test framework. 67 | /// 68 | /// 69 | /// In addition to the standard implementation, this checks for a reference to the MSTestv2Framework assembly used to test Windows Store Apps. 70 | /// 71 | /// The to check. 72 | /// True if is a unit test project, false otherwise. 73 | public override bool IsTestProject(Project project) 74 | { 75 | bool result = false; 76 | 77 | if (project == null) 78 | { 79 | throw new ArgumentNullException(nameof(project)); 80 | } 81 | result = base.IsTestProject(project); 82 | if (!result) 83 | { 84 | if (project.Kind == PrjKind.prjKindCSharpProject || project.Kind == PrjKind.prjKindVBProject) 85 | result = ProjectHasReference(project, "xunit.core"); 86 | } 87 | 88 | return result; 89 | } 90 | 91 | /// 92 | /// Check if the current project is a testable project; i.e. tests can be generated for this project. 93 | /// 94 | /// The project. 95 | /// True if project if tests can be generated for this project. 96 | public override bool IsTestableProject(Project project) 97 | { 98 | // Base IsTestableProject filters C# and VB projects. 99 | //if (!base.IsTestableProject(project)) 100 | if (!(project.Kind == PrjKind.prjKindCSharpProject || project.Kind == PrjKind.prjKindVBProject)) 101 | { 102 | return false; 103 | } 104 | 105 | // Further restrict projects to C# desktop 106 | foreach (var projectGuid in project.ProjectTypeGuids(this.serviceProvider)) 107 | { 108 | if (this.unsupportedProjects.Contains(projectGuid)) 109 | { 110 | return false; 111 | } 112 | } 113 | 114 | return true; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/xUnitSolutionManager.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Copyright (c) 2017 Yowko Tsai 3 | // *********************************************************************** 4 | 5 | using System; 6 | using EnvDTE; 7 | using EnvDTE80; 8 | using Microsoft.VisualStudio.TestPlatform.TestGeneration; 9 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Data; 10 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Logging; 11 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; 12 | using VSLangProj80; 13 | 14 | namespace xUnit.net.TestGenerator 15 | { 16 | public class xUnitSolutionManager : SolutionManagerBase 17 | { 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The service provider to use to get the interfaces required. 22 | /// The naming object used to decide how projects, classes and methods are named and created. 23 | /// The directory object to use for directory operations. 24 | public xUnitSolutionManager(IServiceProvider serviceProvider, INaming naming, IDirectory directory) 25 | : base(serviceProvider, naming, directory) 26 | { 27 | } 28 | 29 | /// 30 | /// Performs any preparatory tasks that have to be done after a new unit test project has been created. 31 | /// 32 | /// The of the unit test project that has just been created. 33 | /// The of the source method that is to be unit tested. 34 | protected override void OnUnitTestProjectCreated(Project unitTestProject, CodeFunction2 sourceMethod) 35 | { 36 | if (unitTestProject == null) 37 | throw new ArgumentNullException(nameof(unitTestProject)); 38 | if (sourceMethod == null) 39 | throw new ArgumentNullException(nameof(sourceMethod)); 40 | 41 | TraceLogger.LogInfo("xUnitSolutionManager.OnUnitTestProjectCreated: Adding reference to NUnit assemblies through nuget."); 42 | 43 | base.OnUnitTestProjectCreated(unitTestProject, sourceMethod); 44 | 45 | this.EnsureNuGetReference(unitTestProject, "xunit", "2.9.3"); 46 | this.EnsureNuGetReference(unitTestProject, "xunit.runner.visualstudio", "3.0.2"); 47 | 48 | 49 | var vsp = unitTestProject.Object as VSProject2; 50 | var reference = vsp?.References.Find(GlobalConstants.MSTestAssemblyName); 51 | if (reference != null) 52 | { 53 | TraceLogger.LogInfo("xUnitSolutionManager.OnUnitTestProjectCreated: Removing reference to {0}", reference.Name); 54 | reference.Remove(); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/xUnitUnitTestClassManager.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Copyright (c) 2017 Yowko Tsai 3 | // *********************************************************************** 4 | 5 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Data; 6 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; 7 | 8 | namespace xUnit.net.TestGenerator 9 | { 10 | /// 11 | /// A unit test class for xUnit unit tests. 12 | /// 13 | public class xUnitUnitTestClassManager : UnitTestClassManagerBase 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The configuration settings object to be used to determine how the test method is generated. 19 | /// The object to be used to give names to test projects. 20 | public xUnitUnitTestClassManager(IConfigurationSettings configurationSettings, INaming naming) 21 | : base(configurationSettings, naming) 22 | { 23 | 24 | } 25 | 26 | /// 27 | /// The attribute name for marking a class as a test class. 28 | /// 29 | public override string TestClassAttribute => string.Empty; 30 | 31 | /// 32 | /// The attribute name for marking a method as a test. 33 | /// 34 | public override string TestMethodAttribute => "Fact"; 35 | 36 | /// 37 | /// The code to force a test failure. 38 | /// 39 | public override string AssertionFailure => "Assert.True(false, \"This test needs an implementation\")"; 40 | } 41 | } -------------------------------------------------------------------------------- /CreateUnitTests.xUnit/xUnitUnitTestProjectManager.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Copyright (c) 2017 Yowko Tsai 3 | // *********************************************************************** 4 | 5 | using System; 6 | using Microsoft.VisualStudio.TestPlatform.TestGeneration.Model; 7 | using EnvDTE; 8 | 9 | namespace xUnit.net.TestGenerator 10 | { 11 | /// 12 | /// A unit test project for xUnit unit tests. 13 | /// 14 | public class xUnitUnitTestProjectManager : UnitTestProjectManagerBase 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The service provider to use to get the interfaces required. 20 | /// The naming object used to decide how projects, classes and methods are named and created. 21 | public xUnitUnitTestProjectManager(IServiceProvider serviceProvider, INaming naming) 22 | : base(serviceProvider, naming) 23 | { 24 | } 25 | /// 26 | /// Returns the full namespace that contains the test framework code elements for a given source project. 27 | /// 28 | /// The source project. 29 | /// The full namespace that contains the test framework code elements. 30 | public override string FrameworkNamespace(Project sourceProject) 31 | { 32 | return "Xunit"; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xUnit.net.TestGenerator 2 | xUnit.net 2.0 Test Generator For Visual Studio 2017 This is an extension for Visual Studio 2017 that extends the test functionality to allow you to create unit tests . 3 | It works for Visual Studio 2017. The extension extends the built-in test generator functionality allowing developers to generate tests using xUnit.net 2.0. 4 | You can create xUnit.net 2.0 test project from Create Unit Tests menu option. 5 | 6 | ## Please note that it doesn't support IntelliTest yet. ## 7 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.6 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xUnit.net.TestGenerator", "xUnit.net.TestGenerator\xUnit.net.TestGenerator.csproj", "{9AFBC2C0-5FAE-4349-88CA-7947564E8AAA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateUnitTests.xUnit", "CreateUnitTests.xUnit\CreateUnitTests.xUnit.csproj", "{2C19E5DE-4D51-44B2-A885-49CAB0E73C9A}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {9AFBC2C0-5FAE-4349-88CA-7947564E8AAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {9AFBC2C0-5FAE-4349-88CA-7947564E8AAA}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {9AFBC2C0-5FAE-4349-88CA-7947564E8AAA}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {9AFBC2C0-5FAE-4349-88CA-7947564E8AAA}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("xUnit.net.TestGenerator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("xUnit.net.TestGenerator")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/license.txt: -------------------------------------------------------------------------------- 1 | Attribution 3.0 Unported (CC BY 3.0) 2 | 3 | Copyright (c) <2017> 4 | 5 | You are free to: 6 | Share — copy and redistribute the material in any medium or format 7 | Adapt — remix, transform, and build upon the material for any purpose, even commercially. 8 | The licensor cannot revoke these freedoms as long as you follow the license terms. 9 | 10 | 11 | Under the following terms: 12 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 13 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yowko/xUnit.net.TestGenerator/b5910bcb0d5c8e8d123768274a71899e6d8bd8f3/xUnit.net.TestGenerator/preview.png -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | xUnit.net.TestGenerator 6 | xUnit.net Test Generator extensions for Visual Studio 2017 and Visual Studio 2019. 7 | Creates Unit tests with xUnit.net 2.0 framework. 8 | Works on Visual Studio 2017 and Visual Studio 2019. 9 | https://github.com/yowko/xUnit.net.TestGenerator 10 | license.txt 11 | xUnit.png 12 | preview.png 13 | unit testing, xUnit,xUnit.net 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/xUnit.net.TestGenerator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 15.0 6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Debug 16 | AnyCPU 17 | 2.0 18 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 19 | {9AFBC2C0-5FAE-4349-88CA-7947564E8AAA} 20 | Library 21 | Properties 22 | xUnit.net.TestGenerator 23 | xUnit.net.TestGenerator 24 | v4.7.2 25 | false 26 | false 27 | false 28 | false 29 | false 30 | false 31 | 32 | 33 | true 34 | full 35 | false 36 | bin\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | 41 | 42 | pdbonly 43 | true 44 | bin\Release\ 45 | TRACE 46 | prompt 47 | 4 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Designer 56 | 57 | 58 | 59 | 60 | Always 61 | true 62 | 63 | 64 | Always 65 | true 66 | 67 | 68 | Always 69 | true 70 | 71 | 72 | 73 | 74 | {2C19E5DE-4D51-44B2-A885-49CAB0E73C9A} 75 | CreateUnitTests.xUnit 76 | BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b 77 | 78 | 79 | 80 | 81 | 82 | 83 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 84 | 85 | 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /xUnit.net.TestGenerator/xUnit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yowko/xUnit.net.TestGenerator/b5910bcb0d5c8e8d123768274a71899e6d8bd8f3/xUnit.net.TestGenerator/xUnit.png --------------------------------------------------------------------------------