aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Need help in understanding JMockit Usage" Watch "Need help in understanding JMockit Usage" New topic
Author

Need help in understanding JMockit Usage

Raghavan saraghav
Greenhorn

Joined: Dec 16, 2012
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in understanding JMockit Usage