Unit test Helper class method call
Unit test Helper class method call
(OP)
Hi,
Can someone guide me on this please. I am trying to write a unit test for the following:
methodA() {
myservice.callMe();
Date d = MyHelper.createDate();
}
Here is the helper class:
public class MyHelper {
protected MyHelper() {
}
...
...
public static Date createDate() {
...
}
}
I have a private constructor to prevent anyone from instatiating the helper class. Now here is my test:
testMethodA() {
// Mocked the call to myservice
// These are my questions:
?? I would like to mock the method call on the helper class as the helper method functionality has been tested in isolation, in the test for the helper class.
?? How will I define the helper class method call?
?? I tried using MockClassControl (easymock) but since the constructor is protected, I get an error saying that the constructor is not visible.
}
I need some guidance guys. Thanks in advance.
Sam.
Can someone guide me on this please. I am trying to write a unit test for the following:
methodA() {
myservice.callMe();
Date d = MyHelper.createDate();
}
Here is the helper class:
public class MyHelper {
protected MyHelper() {
}
...
...
public static Date createDate() {
...
}
}
I have a private constructor to prevent anyone from instatiating the helper class. Now here is my test:
testMethodA() {
// Mocked the call to myservice
// These are my questions:
?? I would like to mock the method call on the helper class as the helper method functionality has been tested in isolation, in the test for the helper class.
?? How will I define the helper class method call?
?? I tried using MockClassControl (easymock) but since the constructor is protected, I get an error saying that the constructor is not visible.
}
I need some guidance guys. Thanks in advance.
Sam.