Re: simple mock web service
- From: Andrew McDonagh <news@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Nov 2005 18:40:34 +0000
paul wrote:
Thanks for all your help guys.
Gordon - you certainly got me going in the right direction, but I was not able to find the end of the request - and I don't have any control over what the request might be.
Andrew - I definitely do need to have a mock web service for what I'm doing. What it is is that there are many client components, each wrapped in a JUnit test; but the real web services are live, and contain data which anyone can alter. The tests were failing simply because someone somewhere had tweaked with the values, so what I wanted to do was build an interceptor which forwards the request to the real web service the first time, but whenever the same call was received again, then it will return a cached response. The urls to the web services are soft, and so as the tests run during the build, the clients are pointed at the mock web services.
If you are writing a Unit test - then your class under test needs to be simulated 'as if' a web service framework would use it or provide a mock webserver framework for your class to call into. E.g. TDDing your own servlet class.
When unit testing, we are not acceptance testing, so we would not write a test that creates a client to connect to a remote webservice. We only write tests to exercise our classes that make up our application.
We would certainly not have any multi user client invocating upon the same mock.
Acceptance Tests (which are rarely written in xUnit - more likely in FitNesse, Watir, Selenium, etc) test the collaboration of our classes to see if we the feature is working.
Put another way...
Acceptance test concerns Building the Right Code Unit Tests concerns Building the Code Right
To be a unit test - no file access, db access, network access should happen.
Chris - I hear what you are saying about how the String handles the duff characters, but it is only a mock web service, the worst that can happen is that a test will fail when it shouldn't have. Good to know though, all the same. Your ByteArrayOutputStream works a treat - thanks very much for that.
Paul
.
- References:
- simple mock web service
- From: paul
- Re: simple mock web service
- From: Chris Smith
- Re: simple mock web service
- From: paul
- simple mock web service
- Prev by Date: Re: question about coverage for java file
- Next by Date: Query regarding the Java SDKs, SE and EE
- Previous by thread: Re: simple mock web service
- Next by thread: question about coverage for java file
- Index(es):
Relevant Pages
|