asp.net 网络 api 应用程序中的正确或优化测试方法

Proper or optimized test way within asp.net web api application

我们有一个 asp.net 网络 api 应用程序,我们在其中使用了这种架构:

  1. 表示层

  2. BLL层

  3. 木豆层

我和我的大学讨论了 TDD 以及我们如何在我们的项目中使用它:

我的方法

I see that we have to test the BLL layer by adding full unit tests list, Then we test the presentation layer

其他意见

We have only to test the services(presentation layer). If a test failed then, we test only the methods(in bll) which have relation with this service

所以讨论是关于

正确与优化方式

所以我需要知道

  1. 他们之间最好的方法是什么?
  2. 项目的大小和类型是否会影响此比较?

谢谢,

在你的 BL 中,你的 DAL 应该作为依赖注入,你应该使用像 Unity 这样的依赖注入容器。原因是,您的单元测试不依赖于数据库。当您的 BL 测试与数据库隔离时,您的测试也可以 运行 快速