473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Unit testing Web service

I am implementing class that uses Web service written by another and it is
not implemented yet. How can I test my class using NUnit framework without
make changes in future when web service will be implemented?
Nov 23 '05 #1
4 7026
"Vlad" <Vl**@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
I am implementing class that uses Web service written by another and it is
not implemented yet. How can I test my class using NUnit framework without
make changes in future when web service will be implemented?


One way to test the Web Service consumer application is to use the mock
object pattern with the Web Service proxy.

All you need is the WSDL of the Web Service. Use the WSDL to generate a Web
Service proxy for the client object, and then modify the proxy to return
hard-coded responses to the client application.

As a side-note, this would be easier if the proxy generator generated
virtual methods so one could subclass the proxy and override the methods. As
it stands now, you will have to modify the generated proxy code and the
downside is that you'll lose the modifications every time the proxy is
regenerated.

Regards,
Sami
Nov 23 '05 #2
Vlad,
One way to test the Web Service consumer application is to use the
mock object pattern with the Web Service proxy.
Ideal way to proceed!

All you need is the WSDL of the Web Service. Use the WSDL to generate
a Web Service proxy for the client object, and then modify the proxy
to return hard-coded responses to the client application.

As a side-note, this would be easier if the proxy generator generated
virtual methods so one could subclass the proxy and override the
methods. As it stands now, you will have to modify the generated proxy
code and the downside is that you'll lose the modifications every time
the proxy is regenerated.


Not necessarily. You could just generate a server stub and implement the
web methods and and make the server return the dummy responses. The only
place that will be affected would be in the client side Url that the proxy
hits :)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Nov 23 '05 #3
Thanks guys!
I understand but the class that uses web service is a singleton and clients
of this class donot have ability to setup it with implementation of web
service (mock or real proxy)? What to do in this case?
"Dilip Krishnan" wrote:
Vlad,
One way to test the Web Service consumer application is to use the
mock object pattern with the Web Service proxy.


Ideal way to proceed!

All you need is the WSDL of the Web Service. Use the WSDL to generate
a Web Service proxy for the client object, and then modify the proxy
to return hard-coded responses to the client application.

As a side-note, this would be easier if the proxy generator generated
virtual methods so one could subclass the proxy and override the
methods. As it stands now, you will have to modify the generated proxy
code and the downside is that you'll lose the modifications every time
the proxy is regenerated.


Not necessarily. You could just generate a server stub and implement the
web methods and and make the server return the dummy responses. The only
place that will be affected would be in the client side Url that the proxy
hits :)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

Nov 23 '05 #4
Hello Vlad,
Just a wild swag at what you could do.... :) You could consider redesigning
your singleton class to control those parameters. Try this pattern [0] to
give you some insights into whats possible.
[0] - http://www.martinfowler.com/articles/injection.html
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Thanks guys!
I understand but the class that uses web service is a singleton and
clients
of this class donot have ability to setup it with implementation of
web
service (mock or real proxy)? What to do in this case?
"Dilip Krishnan" wrote:
Vlad,
One way to test the Web Service consumer application is to use the
mock object pattern with the Web Service proxy.

Ideal way to proceed!
All you need is the WSDL of the Web Service. Use the WSDL to
generate a Web Service proxy for the client object, and then modify
the proxy to return hard-coded responses to the client application.

As a side-note, this would be easier if the proxy generator
generated virtual methods so one could subclass the proxy and
override the methods. As it stands now, you will have to modify the
generated proxy code and the downside is that you'll lose the
modifications every time the proxy is regenerated.

Not necessarily. You could just generate a server stub and implement
the web methods and and make the server return the dummy responses.
The only place that will be affected would be in the client side Url
that the proxy hits :)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hugh Cowan | last post by:
Hello, I don't program full-time (anymore), but I do try and stay on-top of the latest technologies and like most are always trying to upgrade my skills and remain current (as much as is...
14
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
4
by: Peter Rilling | last post by:
Does VS.NET 2005 Professional support integrated unit testing, or is that only with the team system?
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
1
by: Cam | last post by:
Hi have a question about unit testing web services. I have created a web service that has public and private methods.I would like to generate unit tests but when I generate the unit tests I get a...
4
by: Dat AU DUONG | last post by:
Hi, I am new to Unit testing, could you tell me where I could find information (hopefully step by step) and what is the benefit of unit testing. I am a sole developer in a company, therefore I...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
48
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but...
6
by: Vyacheslav Maslov | last post by:
Hi all! I have many many many python unit test, which are used for testing some remote web service. The most important issue here is logging of test execution process and result. I strongly...
5
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.