tag:blogger.com,1999:blog-7855757415977257409.post6957183326992930830..comments2023-11-27T08:29:47.799-08:00Comments on carlo scarioni: Ruby unit testing is weak as a safety netAnonymoushttp://www.blogger.com/profile/05231758018563704360noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-7855757415977257409.post-91441621390416484762014-09-18T12:49:59.012-07:002014-09-18T12:49:59.012-07:00Hey Akita, I have question regarding this:
"...Hey Akita, I have question regarding this:<br /><br />"Unit tests are never about testing interfaces (unless, of course, you're making a lint test for some web service API, and even then)."<br /><br />So, how do you take care of NoMethodError exceptions (given that you changed class api)? By doing integration tests or what? Could you point to some resources?<br /><br />Cheers and Anonymoushttps://www.blogger.com/profile/17560111051872402038noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-13575473541114938012014-09-18T11:56:24.162-07:002014-09-18T11:56:24.162-07:00Hey Akita, didn't mean to make the title provo...Hey Akita, didn't mean to make the title provocative at all. I get nothing for page clicks. Just to show an actual issue I encounter in bigger Ruby projects. So apologies if it seems intentionally provocative.<br /><br />The example is deliberately simple, but for a real life problem. But you obviously don't want to discuss it which is fine of course. Thanks for your input anyway.<br /Anonymoushttps://www.blogger.com/profile/05231758018563704360noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-20407225626198623452014-09-18T10:52:08.569-07:002014-09-18T10:52:08.569-07:00Wow, seriously? This title and this kind of conten...Wow, seriously? This title and this kind of content is what's defined as 'link bait'.<br /><br />If this is not the case, this example is checking a type's interface. This shouldn't be tested to begin with. And of course, Java being statically typed, it's utterly redundant as the compiler tests that already.<br /><br />Unit tests are never about testing interfaces (unless,AkitaOnRailshttps://www.blogger.com/profile/05539202931163964720noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-79038947046395977412014-09-18T03:50:14.073-07:002014-09-18T03:50:14.073-07:00Hey, Sale is nickname for Sasa in Serbia :)
Yes, ...Hey, Sale is nickname for Sasa in Serbia :)<br /><br />Yes, I agree that this is kinda "hacky" in dynamic languages, especially when you come from static background :)<br /><br />Cheers,<br />SaleAnonymoushttps://www.blogger.com/profile/17560111051872402038noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-85984337748390831292014-09-18T03:37:27.815-07:002014-09-18T03:37:27.815-07:00Hey Sale, Sasa?. you sign differently in your both...Hey Sale, Sasa?. you sign differently in your both comments :)<br /><br />Yeah, that is the point. it is definitely more difficult to be confident and make sure that the tests will simply "catch these bugs while refactoring" the way they do in statically typed. And is not about the IDE, it is about not letting you deploy it broken. The application will fail to compile and you won't Anonymoushttps://www.blogger.com/profile/05231758018563704360noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-32030921853444656172014-09-18T03:00:18.351-07:002014-09-18T03:00:18.351-07:00Hey Carlo,
sure, you can go and change failing ex...Hey Carlo,<br /><br />sure, you can go and change failing example, but for me failing of this example means: class api is changed, find all usages of old method and change them. In my head this is equal to IntelliJ/Eclipse red underline notifications that method/field in object/class is missing. Sure, it is more convenient when IDE is doing this for you, but as I said, this is the way to "Anonymoushttps://www.blogger.com/profile/17560111051872402038noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-1626387119780190092014-09-18T02:26:33.925-07:002014-09-18T02:26:33.925-07:00Hi Sasa, thanks for writing.
I don't think th...Hi Sasa, thanks for writing.<br /><br />I don't think that in general Java is stronger, but I do think it definitely have stronger points (in this particular case static typing vs dynamic). As Ruby also has stronger points.<br /><br />Even in your example, that is the only test that would fail. The original test that used the collaborator as a client would still be passing. Meaning, you go Anonymoushttps://www.blogger.com/profile/05231758018563704360noreply@blogger.comtag:blogger.com,1999:blog-7855757415977257409.post-15861874164733642242014-09-18T02:04:55.470-07:002014-09-18T02:04:55.470-07:00describe Collaborator do
subject { Collaborator....describe Collaborator do<br /> subject { Collaborator.new }<br /><br /> it {should respond_to(:do_stuff)}<br />end<br /><br />As Ruby is dynamic language, this is way to test for object API (fields/methods). Yeah, this is thing that you do not need to do in languages with static typing, but every language type has it's pros and cons.<br /><br />Saying that Java is superior than Ruby is Anonymoushttps://www.blogger.com/profile/17560111051872402038noreply@blogger.com