none
How to write integration tests for WCF service? RRS feed

Answers

  • I am tellling you Reshaper can host a classlib project that consumes a WCF Web service. It allows one to set a brakepoint in the test method and start single stepping into the WCF service from the client. You can set a brakepoint in the WCF service and run Resharper from the client and hit the brakepoint in the service. You only have so much time to debug while on the WCF service-side before it times out, which is configuable on the WCF client-side config that is the App.config in the FunctionalTest classlib project.

    ConnectionString and WCF config for the cleint the (classlib) project must be in the App.config within the classlibh project when running fuctional tests using Resharper. You may or may not find Reharper documentation on the this, becuase I was shown the power of Reharper by other developersI was working with at the time back in year 2008.

    I also used WCF Restful service too that was using ASP.NET WCF Service in the project that was hosted by Resharper.

    Hey, all I can tell you is insatll Reharper on a machine you have not installed it on before and try it. You can certainly make the calls to a Restful WCF Web service using Reshaper that's hosting a classlib project.

    I go nowhere without installing my personal copy of Resharper on my work machine at the client. :)

    Monday, June 2, 2014 8:27 PM

All replies

  • Why would you try to intergation or unit test  a WCF service? WCF is just a solution that allows communication protoclos TCP, HTTP, Named Pipe and MSMQ communications between client and service application to be used.

    Now if the WCF service project had reference to a classlib project call it Business Logic Layer (BLL) and the WCF service was calling methods on the BLL objects, then interfaction testing or unit testing  logic in the BLL objects would make sense. But to intergration test or unit test the WCF service, which is just doing  communications,  is questionable.

    Monday, June 2, 2014 5:06 PM
  • Yes, there merit to writing tests that directly test the BLL too.

    However, I would like a true integration test. Unlike the tests that bypass the service that you suggested, a true integration test would show

    (1) The firewall is not blocking the service

    (2) All the dependencies (e.g.: DLLs) required by the service are present and properly configured

    (3) The service (and in this case IIS) are running and configured properly.

    Can someone help me write such an integration test that will demonstrate all the above are working properly.

    Thanks

    Siegfried


    siegfried heintze

    Monday, June 2, 2014 5:16 PM
  • Well you should be doing Functuional Testing along the way with a classlib project called FunctionalTest that would test the WCF service in the manner you are talking about, which would be part of the solution as a whole and the whole back-end functional tested before you even went to developing client side code. It would be a classlib project using Nunit and Reharper with Rehaper hosting the classlib project that would have the power (Reshaper) to host WCF client code throug IIS accessing the WCF service.

    If you are doing FW testing that the service can be reached through a FW, then it has nothing to do with WCF. And IIS has nothing to do with WCF testing, which should hav been figured out well before you reached some kind of testing phase if using fuctional tests along the way.

    I haved worked on a number of WCF solitions and devloped them on the back-end too, and I have seen no client try to intergatuion test a WCF service -- no one.

    Monday, June 2, 2014 5:34 PM
  • I agree.

    Can someone show me some sample code to help me create automated function tests? I'm not convinced I want function tests, however. I really think I want a test that does not require a user interface.

    DArnold924: Are you suggesting that I use my custom cell phone client app for functional testing?  I was hoping to have some automated tests that prove that IIS and my service are working properly before my colleagues (or myself) begin work on (our first) IPhone cell phone app.

    I think there is merit to testing IIS and my service with an automated test without having to implement and configure a cell phone app in a cell phone emulator (which is kind of complex for a windows programmer writing a REST service to be used by an Apple IPhone app since these phone apps will be developed on Mac or Linux).  Do you agree? If not, why not?

    Oh -- and I forgot to mention: when my REST service is deployed to Azure (or some other cloud service), I'll be testing those additional dependencies and configurations too (with my automated tests).

    Furthermore, using a user interface of a cell phone app to test azure/IIS/myrestservice is really tedious if the coordinates of your user interface controls are constantly moving around because it is underdevelopment. One would be constantly (re)creating new functional tests by recording the coordinates of mouse clicks and keyboard clicks every time the UI changes. Do you agree?

    I really want to be able to tell the IPhone cell phone app programmers "see! we paid our azure service fee and configured it correctly and the azure/IIS/restservice is running fine. Just run these tests to prove it".

    Thanks

    siegfried


    siegfried heintze



    • Edited by siegfried_ Monday, June 2, 2014 6:35 PM
    Monday, June 2, 2014 6:20 PM
  • DArnold924: Are you suggesting that I use my custom cell phone client app for functional testing?  I was hoping to have some automated tests that prove that IIS and my service are working properly before my colleagues (or myself) begin work on (our first) IPhone cell phone app.

    What? Do you not know how to create a FuctionalTest classlib project in a solution, make the FuctionalTest project consume the WCF service as a client, write test methods in the FunctionalTest class and test WCF through IIS with using Resharper to host the classlib project, right in the VS solution?

    You can tell Resshaper to run all the test methods or go run an indiviual test method, put a breakpoint it the test method code and single step all the way into the WCF service code rigth down into the classlib project the WCF service has reference to.  

    Heck, if you knew how to do that, that's 95% of you trying to come up with some automated intergration testing that I have seen no contract client using WCF ever do.

    I really want to be able to tell the IPhone cell phone app programmers "see -- the azure/IIS/service is running fine. Just run these tests to prove it".

    Have the developers go to the FucntionalTest project in the solution, run all the tests through Reshaper and be done with it. Let them  run the test as many time as they want. If a test fails, they know who to look for. 

    But for you to run some automated tests that going to host WCF,  that's questionalble, becuase I have never seen it done.

    Monday, June 2, 2014 7:01 PM
  • Thanks DArnold924.

    Since I've already used up my resharper free trial, can you point me to the resharper documentation that describes this feature before I plunk my money down?

    I went to the resharper feature page (http://www.jetbrains.com/resharper/features/) and could not find any mention of functional or integration tests or even WCF.

    If anyone else wants to jump in this discussion I would love their input too!

    Thank you DArnold924.

    Siegfried


    siegfried heintze

    Monday, June 2, 2014 7:30 PM
  • I am tellling you Reshaper can host a classlib project that consumes a WCF Web service. It allows one to set a brakepoint in the test method and start single stepping into the WCF service from the client. You can set a brakepoint in the WCF service and run Resharper from the client and hit the brakepoint in the service. You only have so much time to debug while on the WCF service-side before it times out, which is configuable on the WCF client-side config that is the App.config in the FunctionalTest classlib project.

    ConnectionString and WCF config for the cleint the (classlib) project must be in the App.config within the classlibh project when running fuctional tests using Resharper. You may or may not find Reharper documentation on the this, becuase I was shown the power of Reharper by other developersI was working with at the time back in year 2008.

    I also used WCF Restful service too that was using ASP.NET WCF Service in the project that was hosted by Resharper.

    Hey, all I can tell you is insatll Reharper on a machine you have not installed it on before and try it. You can certainly make the calls to a Restful WCF Web service using Reshaper that's hosting a classlib project.

    I go nowhere without installing my personal copy of Resharper on my work machine at the client. :)

    Monday, June 2, 2014 8:27 PM
  • http://www.jetbrains.com/dotcover/

    Another Jetbrain tool I have come to like too, which I use when I am doing unit tests.

    Monday, June 2, 2014 9:27 PM