I want to make an application for iPhone, as an introduction to programming in ObjC and Cocoa. I’m .net developer, so programming on Mac is a whole new world to discover for me 🙂
My application will be talking with web service. I want to use iCuke as a testing framework, and I don’t want to connect to that webservice every time I ran test suite. So how can I mock a webservice response for testing? One solution could be use of SoapUI, but maybe there is some solution that do not use external tools.
I would write a wrapper around the calls to the webservice in the application.
Example in Pseudo Code
Then you just mock of that function just you would like any other function
This way you can mock of the webservice without bothering about it being a webservice or a database connection or whatever. And you can have it return true or whatever.
Good luck
UPDATE
To take this idea one step further and make your tests even more powerful you could use some kind of test parameters or environment parameters to control what happens in the mocked off webservice method. Then you can successfully test how your codes handels different responses from the web services.
Again in pseudo-code:
And tests to match:
And so on, you get the point.
Please note that all my examples are Negative test cases but this could of course be used to test Positive test cases also.