Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create .NET framework 4.6 version of XUnit project in Visual Studio 2019?

Tags:

I notice when I start up Visual Studio 2019, I am unable to create a .NET Framework version of XUnit or NUnit (only MSTests). We have been mandated to use XUnit tests, but our solution is all .NET Framework. Some of the nuget packages are dependent on being .NET Framework (for Sitecore 8.2) and thus I can't add them to a .NET Core project. I cannot upgrade any of the legacy project to .NET Core or to Sitecore 9+ at this time.

How do I add in a .NET Framework XUnit project? Is there something wrong with my Visual Studio setup? Is it not supported? I have been unable to find documentation from Microsoft about this. Thanks.

like image 582
Ross Gustafson Avatar asked Jul 16 '19 18:07

Ross Gustafson


People also ask

Is xUnit compatible with .NET framework?

It's an open source unit testing tool for . Net framework that's compatible with ReSharper, CodeRush, TestDriven.Net, and Xamarin. You can take advantage of xUnit.Net to assert an exception type easily.

Does xUnit work with .net 5?

Sometimes, you want to write tests and ensure they run against several target application platforms. The xUnit.net test runner that we've been using supports . NET Core 1.0 or later, . NET 5.0 or later, and .


1 Answers

  • First use the xUnit Test Project (.NET Core) project template.

  • Then go edit the .csproj file and change <TargetFramework>netcoreapp2.2</TargetFramework> to <TargetFramework>net462</TargetFramework>.

  • That's it. :)

like image 85
Matt Johnson-Pint Avatar answered Sep 21 '22 00:09

Matt Johnson-Pint