[英]What is the proper way to unit test .NET Core Web Application?
I'm new at web development (used to develop desktop apps). 我是Web开发的新手(用于开发桌面应用程序)。 I didn't manage to find a proper way to unit test internals of my web application. 我没有找到找到对Web应用程序内部进行单元测试的正确方法。
Let's say I do have a Foo class which do have a strictly defined behaviour (completely independed from DB and/or UI). 假设我确实有一个Foo类,它确实具有严格定义的行为(完全独立于DB和/或UI)。 I need to make sure that my implementation is corrent. 我需要确保我的实现是正确的。 In the desktop app I just add another test dll with unit tests (if the class is public) or just internal class with tests. 在桌面应用程序中,我只添加另一个带有单元测试的测试dll(如果该类是公共的)或仅带有测试的内部类。 And start it with nunit to make sure that it works. 并以nunit开头以确保其正常工作。 But how is should be done in the web application? 但是应该如何在Web应用程序中完成呢?
The only way I can think of is to add some debug-only pages on which I will run my test and ignore them during the deploy. 我唯一想到的方法是添加一些仅调试页面,我将在这些页面上运行测试,并在部署期间忽略它们。 But I think there should be some unit test framework for that and I just didn't manage to find it. 但是我认为应该为此提供一些单元测试框架,而我只是没有找到它。
Do the .net core web developers have any standard way to do it (something like nunit)? .net核心Web开发人员是否有任何标准方法(类似于nunit)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.