This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Testing and the fly likes Effective Unit Testing: Does your book delve into Mock objects ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Effective Unit Testing: Does your book delve into Mock objects ?" Watch "Effective Unit Testing: Does your book delve into Mock objects ?" New topic
Author

Effective Unit Testing: Does your book delve into Mock objects ?

ludoviko azuaje
Ranch Hand

Joined: Jun 07, 2005
Posts: 47
Dear Lasse Koskela,

Effective unit testing requires testing on objects, but sometimes these are not at hand, we instead use mock objects to mimic those, as they easier to create.

Does your book delve into Mock objects ? I mean do you speak about its usefulness, mock libraries, etc ?


SCJP 1.4, SCJP 5.0, SCWCD 1.4, Oracle SQL Expert Exam 1Z0-047
IBM Test 255, IBM Test 730, IBM Test 142, ScrumManager® Certified.
David Sachdev
Ranch Hand

Joined: Oct 18, 2011
Posts: 32
On this topic, I'm curious to know what Mock frameworks people use: JMock, EasyMock, Mockito, etc.

Also, are there new mocking frameworks out there that I may not be aware of? In general, I have been so happy with Mockito, that it is my default Mocking framework at this point in time, and I worry that maybe I'm missing the next great thing.

Thanks
David
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Chapter 3 is dedicated to the different types of "test doubles", including mock objects but also lower fidelity utilities like plain stubs. What I've tried to do with Chapter 3 is to focus on highlighting the benefits and motivation for using test doubles and helping the reader identify what type of a test double they might need. It's not always a mock object that fits the bill best, although mock object libraries such as Mockito can be used in different styles. For example, a lot of people use a mock object library to create stubs.

As for specific libraries, we've used JMock and Mockito for the example code listings but we don't really teach either. Again, the goal for Chapter 3 wasn't to teach any specific library but to teach the fundamental concepts that may (or may not) justify using such a library.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
 
subject: Effective Unit Testing: Does your book delve into Mock objects ?