如何对 WCF 服务进行单元测试? [英] How do I unit test a WCF service?

查看:38
本文介绍了如何对 WCF 服务进行单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一大堆 DLL,可让我们访问我们的数据库以及其他应用程序和服务.

We have a whole bunch of DLLs that give us access to our database and other applications and services.

我们用一个薄的 WCF 服务层包装了这些 DLL,然后我们的客户端会使用这些服务层.

We've wrapped these DLLs with a thin WCF service layer which our clients then consume.

我有点不确定如何编写仅测试 WCF 服务层的单元测试.我应该为 DLL 编写单元测试,为 WCF 服务编写集成测试吗?我很感激任何智慧......我知道如果我的单元测试实际上进入数据库,它们实际上不会是真正的单元测试.我也明白我真的不需要在单元测试中测试 WCF 服务主机.

I'm a little unsure on how to write unit tests that only test the WCF service layer. Should I just write unit tests for the DLLs, and integration tests for the WCF services? I'd appreciate any wisdom... I know that if my unit tests actually go to the database they won't actually be true unit tests. I also understand that I don't really need to test the WCF service host in a unit test.

所以,我对测试什么以及如何测试感到困惑.

So, I'm confused about exactly what to test and how.

推荐答案

服务的使用者并不关心服务的底层内容.要真正测试您的服务层,我认为您的层需要深入到 DLL 和数据库并至少编写 CRUD 测试.

The consumer of your service doesn't care what's underneath your service. To really test your service layer, I think your layer needs to go down to DLLs and the database and write at least CRUD test.

这篇关于如何对 WCF 服务进行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆