This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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