简体   繁体   中英

Testing Asp.Net Core on full .NET framework

I want to unit test an asp.net core project that targets the full .net framework. I tried using the "normal" unit test project template and a .net core project as outlined in this blog post , but both attempts fail because the assembly of my web-project cannot be referenced in either of the test projects.

Is there a way to unit test asp.net core apps on the full framework?

Found the solution in the comments section of the same blog post. As I cannot link directly, it is quoted below:

BillyboyD

In case anyone needs to do something similar, I have managed to set this up so I can test my controllers in an ASP.NET Core project that targets the .NET Framework 4.6.1 and also references class libraries that are standard .NET, not .NET core (we will have this hybrid situation for some time!). I am using VS2015 update 3 and .NET Core 1.0. My project.json is:

 { "version": "1.0.0-*", "testRunner": "mstest", "dependencies": { "dotnet-test-mstest": "1.0.1-preview", "MSTest.TestFramework": "1.0.0-preview", "MyASP.NetCoreProject": "1.0.0-*" }, "frameworks": { "net461": { "dependencies": { "MyClassLibrary": { "target": "project" } } } } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM