<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The latter do work, though, IFF all concerned tests are just expecting the same thing from the called function... but most likely you have some tests that would check different scenarios. One test might check that the System Under Test behaves well if twitter does a positive response while another might check that the SUT  does  not fail in a catastrophic way if the twitter call gives garbage as response.<br></blockquote><div><br></div><div>Yes. One solution to this problem is to parameterize the different responses under the same system. For example, the username request for "josevalim" would work but fail for "josevalim-fail". It is a very simple solution but it can get unwieldy for complex systems where you need to test many scenarios. In any case, I wouldn't discard this approach quickly, as it fits simple problems quite well.</div><div><br></div><div>A more complex solution is to have an ownership pool where you could say: "if this pid asks for this data, return this value". The benefit of such system is that, if a pid has a given key reassigned without first "deallocating" it, you certainly have a concurrency issue in your tests where two tests need the same resource. We are building such system to allow us to run tests concurrently even if they depend on a common external resource like a database. We replace the regular database pool by the ownership pool and run tests concurrently by wrapping each connection in a transaction (works for SQL ones) or by running different database instances.</div><div><br></div><div><div><div class="gmail_signature"><div dir="ltr"><div><br></div><div><span style="font-size:13px"><div><span style="border-collapse:collapse"><b>José Valim</b></span></div><div><span style="border-collapse:collapse"><div><span style="font-family:verdana,sans-serif;font-size:x-small"><a href="http://www.plataformatec.com.br/" target="_blank" style="color:rgb(42,93,176)">www.plataformatec.com.br</a></span></div><div><span style="font-family:verdana,sans-serif;font-size:x-small">Skype: jv.ptec</span></div><div><span style="font-family:verdana,sans-serif;font-size:x-small">Founder and Director of R&D</span></div></span></div></span></div></div></div></div></div><div><br></div></div></div></div>