|
I have what's probably a really dumb question about unit testing and mocking. Is it possible to mock an object inside a class that doesn't have getters and setters? Right now I'm trying to write a unit test for a class that submits an XML feed to Amazon.com's marketplace web service. The problem is the class was designed to be totally self-contained. Normally all of our services are written with web service objects configured through Spring, so it's easy to pass a mock object in the unit test instead of directing it to the normal Spring configuration. In this case, the web service object is set up within the class I'm trying to test itself. We don't want to hit the actual service--just test that the code is working properly and is submitting the correct XML at the end of its process. Ideally, I could use a mock web service to "receive" the XML. What can I do here, aside from modifying the production code so that the web service object can be passed in? I hope this makes sense.
|
# ¿ Jul 22, 2010 19:25 |
|
|
# ¿ May 20, 2024 12:59 |
|
Thanks! That's great to know in case I'm trying to test with these restrictions again. For now though, I got permission to modify the production code. This definitely seems like it will be useful, however. I can already think of a few test cases that this will make possible.
|
# ¿ Jul 22, 2010 23:59 |