Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we unit test web service?

Should we unit test web service or really be looking to unit test the code that the web service is invoking for us and leave the web service alone or at least until integration testing, etc.... ?

EDIT: Further clarification / thought

My thought is that testing the web service is really integration testing not unit testing?? I ask because our web service at this point (under development) is coded in such a way there is no way to unit test the code it is invoking. So I am wondering if it is worth while / smart to refactor it now in order to be able to unit test the code free of the web service? I would like to know the general consensus on if it's that important to separate the two or if it's really OK to unit test the web service and call it good/wise.

If I separate them I would look to test both but I am just not sure if separation is worth it. My hunch is that I should.

like image 735
Kevin LaBranche Avatar asked Aug 20 '09 20:08

Kevin LaBranche


1 Answers

Unit testing the code that the web service is invoking is definitely a good idea since it ensures the "inside" of your code is stable (and well designed). However, it's also a good idea to test the web service calls, especially if a few of them are called in succession to accomplish a certain task. This will ensure that the web services that you've provided are usable, as well as, work properly when called along with other web service calls. (Not sure if you're writing these tests before or after writing your code, but you should really consider writing your web service tests before implementing the actual calls so that you ensure that they are usable in advance of writing the code behind them.)

like image 112
Joe L. Avatar answered Sep 18 '22 05:09

Joe L.