• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

newbie question on easyMocking the DataSource

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm trying to unit test a function with jdbc access



But I'm getting a null on dataSource.getConnection(). What am I missing? Appreciate any help.
[ June 23, 2008: Message edited by: Aris Tan ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before you pass the mock object to the code under test, you need to move it from "record" to "replay" mode with EasyMock#replay(Object... mocks).
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You that have posted these messages seem to understand how to use mock object frameworks like EasyMock, and there are a number of other frameworks listed at http://www.mockobjects.com/ ... I have some very basic questions. I understand the idea behind use of mock objects despite I lack experiences from it, and I understand use of unit testing and I like test-driven, test-first, development more and more as more I have tried it. But I don�t understand how I should use the mock object frameworks, and not what of them I should look at. Is it possible to say which of them that have got best reputation?

I have looked a little (very little) at EasyMock 2.4 (they do also have a EasyMock 2.3 Class Extension, I am not sure about the difference between them) and on Mock Objects 0.9. It also seems that the maintenance of these frameworks has come to nothing now.

Well, I guess my question could be simplified as should I use mock objects, which one should I then use, adnd how do I learn the basics?

I am currently exercising unit testing on 1.4 servlets as mean to learn more about how to use mock objects in unit testng.
 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After some more googling did I find this little good introduction to EasyMock http://www.michaelminella.com/testing/unit-testing-with-junit-and-easymock-2.html which gives a good idea on how EasyMock can be used. It is easy enough to to get a quick start but more tutorial that builds in this start would have been great. This tutorial is any way a good start for them like me not have learnt how to "think" to fully understand mocking yet
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic