Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create unit tests for .net 6.0

I created a .Net 6 class library and now I am trying to create a test project.
a .net 6 test project is not available. Online I found the information to use .Net Framework or .Net core in order to test.

I created a .Net Framework 4.8 test project an referenced my class library.

I receive the Compiler error:

Project '..\CircularList\CircularList.csproj' targets 'net6.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.8'. UnitTests

How do I do Unit tests then? Is there any way to target .Net 6.0 from .Net Framework 4.8?

like image 863
julian bechtold Avatar asked Dec 17 '25 04:12

julian bechtold


1 Answers

None of the previous answers worked for me. I was trying to add a Test project for my Windows Forms (.NET 6.0) project. Tried all of the available project templates, and none worked.

Just needed to modify the test project .csproj (by double clicking the Test Project), and change TargetFramework from net6.0 to net6.0-windows.

like image 165
chessplayerjames Avatar answered Dec 19 '25 20:12

chessplayerjames