• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

junit & mock objects

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,

Hi I am trying to implement junit to my application. But when I wasa trying to do some research on that, I see junit and Mock objects for testing. But I really could not figure out whether they are both used same way or used together.

Thanks
Spephanie
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stephanie,
They are used together.

JUnit is a testing framework. When you don't need to mock anything out, it can be used by itself.

Mock objects create a dummy object for an interface. They are used with JUnit when you want to prevent the real interface's implementation from being called. While mock objects can be used without JUnit, this is extremely rare.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steph,

You might be interested to read Martin Fowler's articles/blog entries on mock objects and test-doubles:

Mocks Aren't Stubs
Test Double
 
reply
    Bookmark Topic Watch Topic
  • New Topic