• 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

Need help in understanding JMockit Usage

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Am a newbie to the Junit and JMockit. I havent used any other mock tools before and thought of deciding to give a try with JMockit. Am trying a simple example and am not able to solve the problem. I have 3 classes namely Logger, Base Class and a Derived Class and all of three resides in 3 different packages

1. The Logger class which is final and has a private constructor and has a method call log(String message)
2. The Base Class has a getter/setter for the Logger which currently am not aware of who is setting it
3. The derived class is my class under testing which uses the logger set by the base class. [example. logger.log("some message")] and say performOperation is my method which i want to test.

Hope the above points clarify the scenario.

My intention is to test the performOperation alone in the derived class. Should i mock the setter of base class and also the Logger class itself as i cannot instantiate it from outside. Suggest me what approach should i take to test my method alone
 
Hold that thought. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic