lundi 29 août 2016

How do you unit test ASP.NET Core Web Application (.Net Framework)?

I'm building an ASP.NET Core Web Application (.Net Framework) and am having a hard time figuring out how to hook unit tests up to it. I am targeting the .net framework version 4.6.1

If I create a regular "Class Library" project targeting 4.6.1, as I would for previous version of MVC, it lets me add references to my MVC project (which is part of the same solution) but any namespaces I add through a using statement report an error that I might be missing a reference or using statement. If I double click on the reference under the "References" section in the solution explorer it tells me that the project can't be found or hasn't been build yet.

I tried creating a "Class Library (.NET Core)" but that complains since I'm targeting .Net Framework and not .NET Core. I edited the class libaries Project.json to have it target the .net framework and that lets me add my references and doesn't complain when I the namespaces in a using statement but none of my tests are discovered by the test runner. I've tried both XUnit and NUnit and they both behave the same.

Is it possible to unit test an ASP.Net Core Web Application targeting the .Net Framework 4.6.1 or do I need to commit to the .NET Core?

Aucun commentaire:

Enregistrer un commentaire