<div dir="ltr">Did the check -&gt;   <div>







<p class=""><b>Executed 157 tests, with 0 failures (0 unexpected) in 14.247 (14.286) seconds</b></p><p class="">that is _ok_, so .... perhaps it&#39;s not that smart, to use proposal #2 ? <br></p></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Jun 11, 2013 at 8:56 AM, Matthias Wessendorf <span dir="ltr">&lt;<a href="mailto:matzew@apache.org" target="_blank">matzew@apache.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Looking at the branch:<div><br></div><div>One thing that I noticed is the extreme larger amount of, for passing the tests.</div><div><br></div><div>Branch_of_PR:</div><div>Executed 156 tests, with 0 failures (0 unexpected) in 52.261 (52.285) seconds<br>

</div><div><br></div><div>Master_branch (aerogear/aerogear-ios):</div><div><div>Executed 157 tests, with 0 failures (0 unexpected) in 12.194 (12.217) seconds</div><div><br></div></div><div><br></div>
<div><br></div><div><br></div><div><br></div><div>Now I am wondering, that that OHHTTPStub is really _that_ slow...</div><div>Do you have an numbers from the proposal #1 ?</div><span class="HOEnZb"><font color="#888888"><div>
<br>
</div><div>-Matthias</div><div><br></div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 11, 2013 at 8:50 AM, Christos Vasilakis <span dir="ltr">&lt;<a href="mailto:cvasilak@gmail.com" target="_blank">cvasilak@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi<div><br></div><div>looks like #2 approach wins so I merged it.</div><div><br></div>

<div>Thanks!</div><div><div><div><br><div><div>On Jun 10, 2013, at 12:29 PM, Corinne Krych &lt;<a href="mailto:corinnekrych@gmail.com" target="_blank">corinnekrych@gmail.com</a>&gt; wrote:</div><br><blockquote type="cite">

<div dir="ltr">+1 for #2. Indeed second approach2 is more objective-c in the syntax.<div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 10 June 2013 10:15, Matthias Wessendorf <span dir="ltr">&lt;<a href="mailto:matzew@apache.org" target="_blank">matzew@apache.org</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I think I do prefer the approach #2 (the &quot;mock helper&quot; class)</div><div>


<br></div><div>-M</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>
On Fri, Jun 7, 2013 at 10:32 AM, Christos Vasilakis <span dir="ltr">&lt;<a href="mailto:cvasilak@gmail.com" target="_blank">cvasilak@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>
<div style="word-wrap:break-word">Hi team,<div><br></div><div>for further improvements of our unit tests we have switched the http mocking mechanism we use (our own NSURLProtocol impl)  to the popular OHHTTPStubs[1] project,  a library currently recommended by the AFNetworking networking lib we use.</div>



<div><br></div><div>The basic mechanism is straightforward to use and encapsulated in one method:</div><div><br></div><div><span style="line-height:16px;font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace">return [</span><span style="line-height:16px;color:rgb(51,51,51);font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace">OHHTTPStubsResponse</span><span style="line-height:16px;font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace"> </span><span style="line-height:16px;color:rgb(51,51,51);font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace">responseWithData</span><span style="line-height:16px;font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-weight:bold">:</span><span style="line-height:16px;color:rgb(51,51,51);font-size:12px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace">data</span></div>



<div><pre style="line-height:16px;width:744px;font-size:12px;margin-bottom:0px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin-top:0px;word-wrap:break-word;padding:0px"><div>                                  <span>statusCode:</span><span style="color:rgb(51,51,51)">status</span></div>



<div>                                <span>responseTime:</span><span style="color:rgb(51,51,51)">responseTime</span></div><div>                                     <span>headers:</span><span style="color:rgb(51,51,51)">headers</span><span>];</span></div>



</pre><div><br></div></div><div>in which a stubbed response is returned to the client.</div><div><br></div><div>Now, based on this mechanism,  we have abstracted a bit and created methods such as:</div><div><br></div><pre style="line-height:16px;font-size:12px;width:744px;margin-bottom:0px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;margin-top:0px;word-wrap:break-word;padding:0px">
<div><span style="font-weight:bold"> +</span> <span>(</span><span style="color:rgb(68,85,136);font-weight:bold">void</span><span>)</span><span style="color:rgb(51,51,51)">mockResponse</span><span style="font-weight:bold">:</span><span>(</span><span style="color:rgb(51,51,51)">NSData</span><span style="font-weight:bold">*</span><span>)</span><span style="color:rgb(51,51,51)">data</span><span>;</span></div>



<div><span> <span style="font-weight:bold">+</span> <span>(</span><span style="color:rgb(68,85,136);font-weight:bold">void</span><span>)</span><span style="color:rgb(51,51,51)">mockResponseStatus</span><span style="font-weight:bold">:</span><span>(</span><span style="color:rgb(68,85,136);font-weight:bold">int</span><span>)</span><span style="color:rgb(51,51,51)">status</span><span>;</span></span></div>



<div> <span style="font-weight:bold">+</span> <span>(</span><span style="color:rgb(68,85,136);font-weight:bold">void</span><span>)</span><span style="color:rgb(51,51,51)">mockResponseTimeout</span><span style="font-weight:bold">:</span><span>(</span><span style="color:rgb(51,51,51)">NSData</span><span style="font-weight:bold">*</span><span>)</span><span style="color:rgb(51,51,51)">data</span> <span style="color:rgb(51,51,51)">status</span><span style="font-weight:bold">:</span><span>(</span><span style="color:rgb(68,85,136);font-weight:bold">int</span><span>)</span><span style="color:rgb(51,51,51)">status</span> <span style="color:rgb(51,51,51)">responseTime</span><span style="font-weight:bold">:</span><span>(</span><span style="color:rgb(51,51,51)">NSTimeInterval</span><span>)</span><span style="color:rgb(51,51,51)">responseTime</span><span>;</span></div>



<div><br></div></pre><div>This gives the advantages that a) clearly indicate what http scenario we are testing  and b) remove params that don&#39;t make sense for the particular scenario under testing e.g. that is we simulate a status of  (404) but we need to pass all params eg. data, interval, timeout, etc.  But this doesn&#39;t limit us, we can do that if we want and use the full blown method with all the params attached.</div>



<div><br></div><div>I have created two branches in my fork, one that uses a blocks approach inside the testing class [2] and one that the functionality is extracted in a helper class that the testing classes can use [3].  The second approach was created because there was common code and didn&#39;t want to duplicate it over the testing classes.  </div>



<div><br></div><div>I would be interesting to know what is your comments on it?</div><div><br></div><div>Thanks,</div><div>Christos</div><div><br></div><div><br></div><div>[1] <a href="https://github.com/AliSoftware/OHHTTPStubs" target="_blank">https://github.com/AliSoftware/OHHTTPStubs</a></div>



<div>[2] <a href="https://github.com/cvasilak/aerogear-ios/blob/ohhttpstubs/AeroGear-iOS/AeroGear-iOSTests/AGRestAdapterTests.m#L33-L51" target="_blank">https://github.com/cvasilak/aerogear-ios/blob/ohhttpstubs/AeroGear-iOS/AeroGear-iOSTests/AGRestAdapterTests.m#L33-L51</a></div>



<div>[3] <a href="https://github.com/cvasilak/aerogear-ios/blob/ohhttpstubs.helper/AeroGear-iOS/AeroGear-iOSTests/utils/AGHTTPMockHelper.m" target="_blank">https://github.com/cvasilak/aerogear-ios/blob/ohhttpstubs.helper/AeroGear-iOS/AeroGear-iOSTests/utils/AGHTTPMockHelper.m</a></div>



<div>[4] </div><div> </div><div><br></div></div><br></div></div>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><span><font color="#888888"><br></font></span></blockquote></div><span><font color="#888888"><br>


<br clear="all"><div><br></div>-- <br>Matthias Wessendorf <br>
<br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>



twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</font></span></div>
<br>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br></blockquote></div><br></div>
_______________________________________________<br>aerogear-dev mailing list<br><a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></blockquote>

</div><br></div></div></div></div><br>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Matthias Wessendorf <br>

<br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>

twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>
sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div>