<p>I have an application that sends messages to an external web service. I build and deploy this application using <a href="http://msdn.microsoft.com/en-us/library/wea2sca5(VS.80).aspx" rel="nofollow noreferrer">MSBuild</a> and <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" rel="nofollow noreferrer">Cruisecontrol.NET</a>. As CCNET build and deploys the app it also runs a set of test using <a href="http://www.nunit.org/index.php" rel="nofollow noreferrer">NUnit</a>. I'd now like to test the web service communication as well. </p>

<p>My idea is that as part of the build process a web service should be generated (based on the external web services WSDL) and deployed to the build servers local web server. All the web service should do is to receive the message and place it on the file system so I then can check it using ordinary NUnit for example. This would also make development easier as new developers would only have to run the build script and be up and running (not have to spend time to set up a connection to the third party service).  </p>

<p>Are there any <strong>existing utilities out there</strong> that easily mock a web service based on a WSDL? Anyone <strong>done something similar using MSBuild?</strong> </p>

<p>Are there <strong>other ways of testing this scenario?</strong> </p>

[{'answer_id': 34693, 'author': 'Joshua Turner', 'author_id': 820, 'author_profile': 'https://Stackoverflow.com/users/820', 'pm_score': 3, 'selected': True, 'text': '<p>I just started looking into <a href="http://www.soapui.org/" rel="nofollow noreferrer">http://www.soapui.org/</a> and it seems like it will work nicely for testing web services.</p>\n\n<p>Also, maybe look at adding an abstraction layer in your web service, each service call would directly call a testable method (outside of the web scope)?  I just did this with a bigger project I\'m working on, and it\'s testability is working nicely.</p>\n'}, {'answer_id': 176560, 'author': 'Josh Kodroff', 'author_id': 549, 'author_profile': 'https://Stackoverflow.com/users/549', 'pm_score': 1, 'selected': False, 'text': '<p>In general, a very good way to test things like this is to use <a href="http://en.wikipedia.org/wiki/Mock_object" rel="nofollow noreferrer">mock objects</a>.  </p>\n\n<p>At work, we use the product <a href="http://www.typemock.com/" rel="nofollow noreferrer">TypeMock</a> to test things like Web Service communication and other outside dependencies.  It costs money, so for that reason it may not be suitable for your needs, but I think it\'s a fantastic product. I can tell you from personal experience that it integrates very well with NUnit and CCNet.</p>\n\n<p>It\'s got a really simple syntax where you basically say "when this method/property is called, I want you to return this value instead."  It\'s great for testing things like network failures, files not being present, and of course, web services.</p>\n'}, {'answer_id': 177926, 'author': 'David Schmitt', 'author_id': 4918, 'author_profile': 'https://Stackoverflow.com/users/4918', 'pm_score': 1, 'selected': False, 'text': '<p>Take a look at <a href="http://nmock2.wiki.sourceforge.net/" rel="nofollow noreferrer">NMock2</a>. It\'s a open-source mocking product and allows you to create "virtual" implementations for interfaces that support rich and deep interaction.</p>\n\n<p>For example, if your WS interface is called <code>IService</code> and has a <code>Data GetData()</code> method, you can create a mock that requires the method to be called once and returns a new <code>Data</code> object:</p>\n\n<pre><code>var testService = mockery.NewMock&lt;IService&gt;();\nExpect\n    .Once\n    .On(testService)\n    .Method("GetService")\n    .WithNoArguments()\n    .Will(\n        Return.Value(new Data());\n</code></pre>\n\n<p>At the end of the test, call <code>mockery.VerifyAllExpectationsHaveBeenMet()</code> to assure that the <code>GetData</code> method was actually called.</p>\n\n<p>P.S.:  don\'t confuse the "NMock2" project with the "NMock RC2", which is also called "nmock2" on sourceforge. NMock2-the-project seems to have superseded NMock.</p>\n'}, {'answer_id': 540277, 'author': 'Riri', 'author_id': 298, 'author_profile': 'https://Stackoverflow.com/users/298', 'pm_score': 1, 'selected': False, 'text': '<p>This might also be something - <a href="http://www.codeplex.com/mockingbird" rel="nofollow noreferrer">MockingBird</a>. Look useful.</p>\n'}, {'answer_id': 737474, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>At my work place we are using <a href="http://www.typemock.com/index.php" rel="nofollow noreferrer">Typemock</a> and <a href="http://www.nunit.org/" rel="nofollow noreferrer">nUnit</a> for our unit testing.</p>\n'}]
['https://Stackoverflow.com/questions/34661', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/298/']