Can EasyMock support several overloaded methods added to createMockBuilder?

I work with existing test cases that are used EasyMockto mock a class. I overloaded the method with no parameters, so now there is a method to take a string. For instance:

public class HelloClass {
   // This method always existed.
   public String methodHello() {
       ...
   }
   // This method is new; it overloads the methodHello() method.
   public String methodHello(String msg) {
       ...
   }
}

In the test class, HelloClass is ridiculed. As a result, I added an overloaded method so that we had an declaration:

public static HelloClass mockHelloClass = createMockBuilder(HelloClass.class)
   .addMockedMethod("methodHello")
   .addMockedMethod("methodHello", String.class)
   .createMock();

However, when I run them, test cases fail. When I make the method methodHello(String)private, then the test cases pass again.

Is it EasyMockcapable of handling multiple overloaded methods added to createMockBuilder?

+4
1

, :

java.lang.RuntimeException: : named methodHello

:

public static HelloClass mockHelloClass = createMockBuilder(HelloClass.class)
   .addMockedMethod("methodHello", new Class[]{}) // you got this one wrong
   .addMockedMethod("methodHello", String.class)
   .createMock();

, - ,

addMockedMethod("methodHello")

, , . :

addMockedMethod("methodHello", new Class[]{})

+5

All Articles