[英]Unit testing WCF calls, is it possible and how?
I'm working on a tool that checks some large application functionality. 我正在使用一种检查某些大型应用程序功能的工具。 All of my calls to large application are made using WCF, application is too big to create Mock out of it. 我对大型应用程序的所有调用都是使用WCF进行的,应用程序太大而无法从中创建Mock。 I want to create Unit Tests for my tool so i won't break functionality while re-factoring or extending functionality. 我想为我的工具创建单元测试,这样我就不会在重构或扩展功能时破坏功能。
Is it possible and how ? 有可能吗?
You can, but they won't be unit tests in the normal sense of the word, they will be more like automated regression tests. 您可以,但是从一般意义上讲,它们将不是单元测试,它们更像是自动回归测试。 A typical test method might contain the following: 典型的测试方法可能包含以下内容:
It takes a lot of care to get this right, but it does work. 需要花费很多心思才能做到这一点,但它确实有效。
The phrase "application is too big to create Mock out of it" raised a warning sign. 短语“应用程序太大而无法创建Mock”提出了警告信号。 I do not mean to sound harsh but if your application logic cannot be broken down into smaller unit-testable parts then there's something wrong with the architecture of the application. 我并不是说听起来很刺耳,但是如果您的应用程序逻辑无法分解成较小的可单元测试的部分,那么应用程序的架构就有问题了。
I've been unit testing WCF powered Silverlight ViewModels for years using Moq with great results. 多年来,我一直在使用Moq对WCF驱动的Silverlight ViewModels进行单元测试,结果非常好。 A concept which can be applied to ASP.Net/MVC as well. 也可以应用于ASP.Net/MVC的概念。
I guess it depends whether you're looking at unit testing the classes behind the service or functionally testing the service itself. 我想这取决于您是要对服务背后的类进行单元测试还是对服务本身进行功能测试。
For functional testing of WCF services I use WCF Storm which could do with a little polish, but works great. 对于WCF服务的功能测试,我使用WCF Storm,可以稍加修改,但效果很好。 You can build and run functional tests as well as performance tests. 您可以构建和运行功能测试以及性能测试。 Very useful little tool. 非常有用的小工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.