• 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

EasyMock : AssertionError expected:1, actual:0 error

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am trying to test method retrieve() in Class A (I have created dummy code to represent the problem that I am facing). Please see the comments in bold below for my question.


[ May 21, 2008: Message edited by: Santosh Ramachandrula ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Santosh Ramachandrula:


You don't mock an object that is being created within a method. The only way to do that would be to modify the actual byte code with a library such as BCEL or ASM, replacing the byte code instructions for "B b = new B()" with something else.

A much more viable option is to expose "B" so that you can indeed swap in a test double. For example, you could do something like this:

 
reply
    Bookmark Topic Watch Topic
  • New Topic