<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think even the problem of too many layers can itself be solved by yet another indirection later whose implementation is to bypass all the other layers )))<br><div><div>On Apr 12, 2011, at 8:59 AM 4/12/11, Lee Meador wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">You can solve most such problems by adding a layer of indirection, except the problem where you have too many layers of indirection<br><br>-- Lee<br><br><div class="gmail_quote">On Tue, Apr 12, 2011 at 1:05 AM, Brett L. Schuchert <span dir="ltr"><<a href="mailto:schuchert@yahoo.com">schuchert@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">By the way, using a mocking library or not would not fundamentally change how I test either:<div>
<span style="white-space: pre-wrap;"> </span>the persistent layer</div><div><span style="white-space: pre-wrap;"> </span>clients of the persistent layer</div><div><br></div><div>So follow-up to last email. Not only "what are you wanting to test, the later itself or clients of the layer". Additionally,</div>
<blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div>what problem(s) are you trying to solve that requires needing to know "how to test persistent layer effectively" - this is a solution to a perceived problem and not a problem itself, so what problem are you trying to solve.</div>
<div><br></div><div>If you are meaning to test the persistent layer, does your underlying persistent store's schema make heave use of stored procedures, or are you primarily using an ORM tool (if so, top-down, bottom-up or meet in the middle mapping).</div>
<div><br></div><div>If you instead planning on testing clients that use the persistent layer, how does client code get access to an object representing access to that layer (a dao). Does it</div><div>- use new directly</div>
<div>- get it passed in (in a ctor, method, setter)</div><div>- use some kind of IoC container, e.g. Spring</div></blockquote><div><br></div>I don't think there's enough time to get more than a superficial hand waving at your question. However, it turns out that the solution to this problem is general. Introduce a level of indirection!-)<div>
<br></div><div><font color="#888888">Brett</font><div><div></div><div class="h5"><br><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div> </div></blockquote><div><div><div>On Apr 11, 2011, at 8:36 PM 4/11/11, Rupesh Bhochhibhoya wrote:</div>
<br><blockquote type="cite"><div style="word-wrap: break-word;">
<pre style="word-wrap: break-word; font-size: 10pt; font-family: Tahoma; color: black;">I have always used nice mocks. And didn't really know why other mocks didn't work well for me. So, thanks for info.
Also it would be nice if you could share how to test persistent layer effectively using Jmockit.
"Brett L. Schuchert" <<a href="mailto:schuchert@yahoo.com" target="_blank">schuchert@yahoo.com</a>> wrote:
</pre>
<div>Might as well start the talk now...
<div><br>
</div>
<div>When using mock libraries, by default use "nice" or "not strict" mocks. Most of them default to strict mocks. The problem with this is that doing so makes the tests more fragile and dependent on incidental complexity rather than essential responsibility.</div>
<div><br>
</div>
<div>So in the case of easy mocks, don't use "createMock" by default, instead prefer "createNiceMock". Only use createMock when you really want to verify all messages sent. This is actually a fringe case when doing<i><b> focused</b></i> unit tests. This is
typically counter-intuitive. It only becomes clear as individuals move from tests with lots of checks to focused, single-check or single-logical-check based tests.</div>
<div><br>
</div>
<div>OK, discuss...</div>
<div><br>
</div>
<div>Brett</div>
<div>
<div>
<div>
<div>On Apr 11, 2011, at 11:05 AM 4/11/11, Rupesh Bhochhibhoya wrote:</div>
<br>
<blockquote type="cite"><span style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium;">
<div link="blue" vlink="purple" style="word-wrap: break-word;" lang="EN-US">
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<span style="font-size: 11pt; font-family: Calibri,sans-serif; color: rgb(31, 73, 125);">I appreciate if you can demonstrate examples with TDD/BDD. And also if you could show its advantages over EasyMock, that will be helpful too.</span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<span style="font-size: 11pt; font-family: Calibri,sans-serif; color: rgb(31, 73, 125);"> </span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<span style="font-size: 11pt; font-family: Calibri,sans-serif; color: rgb(31, 73, 125);"> </span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<span style="font-size: 11pt; font-family: Calibri,sans-serif; color: rgb(31, 73, 125);">Rupesh</span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<span style="font-size: 11pt; font-family: Calibri,sans-serif; color: rgb(31, 73, 125);"> </span></div>
<div>
<div style="border-style: solid none none; border-top: 1pt solid rgb(181, 196, 223); padding: 3pt 0in 0in;">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<b><span style="font-size: 10pt; font-family: Tahoma,sans-serif;">From:</span></b><span style="font-size: 10pt; font-family: Tahoma,sans-serif;"><span> </span><a href="mailto:jug-bounces@lists.okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">jug-bounces@lists.okcjug.org</a><span> </span>[mailto:<a href="mailto:jug-bounces@lists.okcjug.org" target="_blank">jug-bounces@lists.okcjug.org</a>]<span> </span><b>On
Behalf Of<span> </span></b>Brett L. Schuchert<br>
<b>Sent:</b><span> </span>Monday, April 11, 2011 10:52 AM<br>
<b>To:</b><span> </span><a href="mailto:jug@lists.okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">jug@lists.okcjug.org</a><br>
<b>Subject:</b><span> </span>Re: [OKC JUG] Reminder - meeting Tuesday, April 12th</span></div>
</div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
Oh yeah, I suppose I should prep (mostly kidding).</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
I already have a "story" for this presentation but I'm open to adjusting if anybody has anything in particular they'd like to me to cover. Just reply to this chain with request.</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
One thing I will be demonstrating is overriding static methods with the tool - which is cool, too cool, but cool.</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
Brett</div>
<div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
On Apr 11, 2011, at 10:35 AM 4/11/11, Brian Sheldon wrote:</div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<br>
<br>
</div>
<div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
We have a meeting tomorrow. We will be providing food and drinks this month thanks to MBO sponsoring again this year.</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
Please go register<span> </span><a href="http://okcjug.org/registration" style="color: blue; text-decoration: underline;" target="_blank">http://okcjug.org/registration</a> so we know how much food to get and who to pick from
for the door prize.</div>
</div>
<div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);">Sponsor: <a href="http://www.mbopartners.com/" style="color: blue; text-decoration: underline;" target="_blank"><span style="color: rgb(41, 112, 166); text-decoration: none;">MBO
Partners</span></a></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);">Speaker: <a href="http://okcjug.org/bios/brett-schuchert" style="color: blue; text-decoration: underline;" target="_blank"><span style="color: rgb(41, 112, 166); text-decoration: none;">Brett
Schuchert</span></a></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);"><a href="http://code.google.com/p/jmockit/" style="color: blue; text-decoration: underline;" target="_blank"><span style="color: rgb(41, 112, 166); text-decoration: none;">JMockit</span></a> -
Things you shouldn’t do when testing…</span></div>
<h3 style="margin: 0in 0in 0.0001pt; font-size: 13.5pt; font-family: 'Times New Roman',serif;">
<span style="font-family: Arial,sans-serif; color: rgb(85, 85, 85); letter-spacing: -0.6pt;">Agenda</span></h3>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);">11:30
am – Welcome Announcements</span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);">11:40
am – Lightning Talks begin</span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Symbol; color: rgb(85, 85, 85);"><span>·<span> <span> </span></span></span></span><span style="font-size: 9pt; font-family: Verdana,sans-serif; color: rgb(85, 85, 85);">12:40
pm – Wrap Up</span></div>
<h3 style="margin: 0in 0in 0.0001pt; font-size: 13.5pt; font-family: 'Times New Roman',serif;">
<span style="font-family: Arial,sans-serif; color: rgb(85, 85, 85); letter-spacing: -0.6pt;">Presentation Information</span></h3>
<h3 style="margin: 0in 0in 0.0001pt; font-size: 13.5pt; font-family: 'Times New Roman',serif; line-height: 12.75pt;">
<span style="font-size: 10pt; font-family: Arial,sans-serif; color: rgb(85, 85, 85); letter-spacing: -0.6pt; font-weight: normal;">JMockIt is a powerful and easy (perhaps too easy) to use mocking tool that allows you to do things that defy logic. Examples
include stubbing static methods, changing final classes and pretty much anything that byte code injection on the fly (per test) allows. We’ll look at some of those things along with more traditional test double creation and then discuss why on the one hand
it is nice to have this power, on the other hand you should almost never use it.</span><span style="font-family: Arial,sans-serif; color: rgb(85, 85, 85); letter-spacing: -0.6pt;"></span></h3>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
<br>
<span style="color: rgb(136, 136, 136);">--<span> </span><br>
Brian</span></div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
_______________________________________________<br>
Jug mailing list<br>
<a href="mailto:Jug@lists.okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">Jug@lists.okcjug.org</a><br>
<a href="http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org</a></div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman',serif;">
</div>
</div>
</div>
_______________________________________________<br>
Jug mailing list<br>
<a href="mailto:Jug@lists.okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">Jug@lists.okcjug.org</a><br>
<a href="http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org" style="color: blue; text-decoration: underline;" target="_blank">http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org</a><br>
</div>
</span></blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
_______________________________________________<br>Jug mailing list<br><a href="mailto:Jug@lists.okcjug.org" target="_blank">Jug@lists.okcjug.org</a><br><a href="http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org" target="_blank">http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org</a><br>
</blockquote></div><br></div></div></div></div></div><br>_______________________________________________<br>
Jug mailing list<br>
<a href="mailto:Jug@lists.okcjug.org">Jug@lists.okcjug.org</a><br>
<a href="http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org" target="_blank">http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>-- Lee Meador<br>Sent from gmail. My real email address is lee AT <a href="http://leemeador.com/">leemeador.com</a><br>
_______________________________________________<br>Jug mailing list<br><a href="mailto:Jug@lists.okcjug.org">Jug@lists.okcjug.org</a><br>http://lists.okcjug.org/listinfo.cgi/jug-okcjug.org<br></blockquote></div><br></body></html>