EasyMock 2.1이 19일에 release됐다. 아직 사이트에는 안내가 뜨지 않았지만 sourceforge에서 다운받을 수 있다.

Mock object는 isolated test기반의 unit test에서 빼놓을 수 없는 필수요소이다. Stub과 달리 Mock은 test object와 collaborator사이의 관계를 검증하는데 매우 유용하기 때문에 좀 더 효과적이고 세밀한 test코드를 작성할 수 있게 해준다. EasyMock은 그런 mock object를 쉽게 만들게 해주는데 특히 2.x에서는 JDk5의 generic을 이용해서 MockControl을 쓰지 않아도 쉽게 mock을  생성하고 사용할 수 있기 때문에 매우 편리하다. EasyMock은 비슷한 툴로 많이 쓰이는 jMock과 종종 비교되는데 jMock이 사용하는 코드는 좀 더 간결하지만 문자파라메터를 이용한 recoding방식이 EasyMock과 달리 refactoring시 일일히 수정해줘야 하는 등의 불편함을 가지고 있다.
EasyMock을 써서 collaborator를 호출하는 방식과 파라메터등을 체크할 수 있는데 파라메터값이equals나 ==로 직접비교가 가능한 경우가 아니라면 parameter matcher를 만들어줘야한다. 이부분이 사실 좀 번거로웠는데 2.x에는 간단한 interface를 구현해서 matcher를 쉽게 만들어 줄 수 있게 되었다. 단지 파라메터 체크 뿐 아니라 method call이 일어났을 때 가상의 처리가 필요하다면 callback method를 사용할 수 있다.

EasyMock 2.1에서는 callback method안에서 getCurrentArguments()를 이용해서 파라메터 값을 가져올 수 있게 했는데 이를 이용하면 좀 더 간편한 adhoc matcher를 만들거나 다른 작업에 사용할 수 있게 되었다. 다만 이번 버전에 담겨있는 document의 callback 샘플코드는 잘못되어있다. 리턴값이 있는 method에 대해서 callback을 적용하려면 먼저 리턴값을 세팅해줘야 한다.

expect(mock.a()).callback(runnable).andReturn(false);   // 이부분은 틀렸다.

expect(mock.a()).andReturn(false).callback(runnable);    // 이렇게 수정해줘야 한다.

callback 내에서 void형이 아닌경우 return 값이 세팅되었는지를 먼저 확인하기 때문이다.

Related posts:

  1. Spring 3.0 (29) M2 Released
  2. Spring Framework 2.5 Released
  3. Hibernate 3.0 released!
  4. Spring Framework 1.1.2 released
  5. Spring Framework 1.1.3 released
  6. Spring기반의 Hibernate DAO Unit Test 만들기
  7. Spring Expressions(SpEL)를 이용한 Mockito Argument Matcher 만들기
  8. 유쾌한 이슈처리 재촉 메일
  9. 테스트 코드에서 static import를 편하게 넣는 방법
  10. Mock Object의 위험성?

Facebook comments:

to “EasyMock 2.1 Released”

  1. Loving this page :) If anyone here is interested in boosting their viewers, can I recommend a really well thought out gig. Look into it here- ser backlink, or just go to https://www.fiverr.com/fastandy/create-100-high-da-average-42-low-obl, it’s great!

  2. Retin A What Strength Does Itcome It http://cialibuy.com – buy cialis online Blood Pressure Medications For Sale Buy Cialis Sans Ordonnance Amoxicillin Sans Prescrire France

  3. Needed to write you one bit of observation so as to thank you once again considering the pretty secrets you have contributed on this page. It has been simply shockingly open-handed of people like you to deliver openly what exactly most of us could possibly have supplied as an e book to help with making some cash for themselves, even more so since you could have done it if you considered necessary. These suggestions as well served to become a great way to fully grasp many people have the same interest just as mine to know whole lot more on the subject of this condition. I think there are several more fun sessions in the future for folks who browse through your blog post.

  4. I intended to draft you this very little remark to help give thanks the moment again relating to the fantastic secrets you have contributed in this case. This is quite tremendously generous with people like you to allow easily precisely what a number of people could possibly have distributed for an e-book to end up making some bucks for themselves, particularly now that you might well have done it if you decided. The tips as well served as a easy way to be aware that most people have the same passion just as my personal own to understand somewhat more regarding this problem. Certainly there are several more pleasant instances ahead for folks who start reading your blog post.

  5. Pretty component to content. I just stumbled upon your web site and in accession capital to assert that I get in fact loved account your blog posts. Any way I’ll be subscribing for your augment and even I fulfillment you access constantly quickly.

  6. Howdy very cool blog!! Man .. Beautiful .. Wonderful .. I will bookmark your blog and take the feeds additionally?KI am glad to find a lot of helpful info here within the post, we’d like develop extra strategies on this regard, thanks for sharing. . . . . .

  7. Propecia Blisters http://abuycialisb.com – Cialis Cymbalta Philippines Cialis Online Kamagra Montpellier

  8. I don’t commonly comment but I gotta admit appreciate it for the post on this amazing one : D.

  9. I truly wanted to compose a quick comment to appreciate you for all of the remarkable suggestions you are posting at this site. My rather long internet search has finally been compensated with good quality ideas to go over with my good friends. I would express that most of us site visitors are truly endowed to dwell in a useful community with so many marvellous individuals with valuable plans. I feel somewhat blessed to have discovered the web page and look forward to so many more amazing minutes reading here. Thanks once more for all the details.

  10. My wife and i were really thrilled that Raymond managed to do his preliminary research via the precious recommendations he came across while using the weblog. It’s not at all simplistic just to possibly be releasing thoughts which often many people have been trying to sell. And now we fully understand we have got the website owner to thank because of that. Most of the illustrations you made, the easy site navigation, the friendships your site make it possible to engender – it’s all extraordinary, and it is letting our son in addition to us feel that that content is thrilling, which is certainly incredibly vital. Thanks for all the pieces!

  11. I simply desired to thank you so much all over again. I’m not certain the things I would have followed without the tips and hints documented by you on that concern. It became an absolute troublesome situation in my view, nevertheless understanding this specialized form you solved the issue made me to weep for delight. I am happier for your work and then expect you know what a powerful job you were accomplishing instructing people today through your blog. I am certain you’ve never encountered any of us.

  12. Propecia .25mg http://cheapcialisir.com – order cialis online Amoxicillin And Abnormal Menstual Cycles Cialis Buy Cheap Synthroid No Prescription

  13. Thanks very interesting blog!

  14. I together with my friends have already been examining the best key points on your web blog and at once developed a terrible feeling I never expressed respect to the web blog owner for those tips. All the guys appeared to be warmed to read through all of them and have now clearly been loving these things. Thank you for genuinely really accommodating and then for selecting variety of fantastic useful guides most people are really needing to be aware of. My personal honest apologies for not saying thanks to you sooner.

  15. Por exemplo, o e-mail marketing pode ser uma grande oportunidade para se manter em contato com seus clientes. Confira este artigo para encontrar maneiras mais poderosas de realmente tornar seus métodos mais sensíveis às necessidades de sua base de clientes.

  16. Thank you, I’ve recently been looking for information approximately this topic for ages and yours is the best I’ve discovered till now. However, what about the bottom line? Are you positive concerning the supply?

  17. I not to mention my buddies happened to be looking through the great advice on the website and so unexpectedly got an awful feeling I had not thanked you for those techniques. All the people came for this reason excited to read them and have now certainly been enjoying these things. We appreciate you simply being simply helpful and then for getting some decent subjects millions of individuals are really desperate to be informed on. Our own sincere apologies for not expressing gratitude to you earlier.

  18. Hi there this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

  19. Where To Buy Colchicine For Plants http://abuycialisb.com – order cialis online Comprare Il Viagra Su Internet generic cialis Buy Viagara With Goft Card

  20. I really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You’ve made my day! Thx again

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2017 Toby's Epril Suffusion theme by Sayontan Sinha