File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Need help in understanding JMockit Usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Need help in understanding JMockit Usage" Watch "Need help in understanding JMockit Usage" New topic

Need help in understanding JMockit Usage

Raghavan saraghav

Joined: Dec 16, 2012
Posts: 1
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
I agree. Here's the link:
subject: Need help in understanding JMockit Usage
It's not a secret anymore!