自动化测试

测试的编写在构建任何程序时都很重要。测试代码有助于发现及避免 bug,并使你后续重构代码的工作轻松些,以免破坏现有功能或引入新的问题。

在本章里,你将学习如何编写 单元测试集成测试 以检验你的 ASP.NET Core 程序。单元测试较小,用来确保单个方法或者逻辑块工作良好。集成测试(有时候也叫 功能性 测试)较大,模拟实际的应用场景,并检验你程序里的多个层次或组件。


Automated testing

Writing tests is an important part of building any application. Testing your code helps you find and avoid bugs, and makes it easier to refactor your code later without breaking functionality or introducing new problems.

In this chapter you’ll learn how to write both unit tests and integration tests that exercise your ASP.NET Core application. Unit tests are small tests that make sure a single method or chunk of logic works properly. Integration tests (sometimes called functional tests) are larger tests that simulate real-world scenarios and test multiple layers or parts of your application.