Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] Mocking Static Methods using JMock

Siddhi B

2009-11-30

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi,

I need a way of mocking a static class using JMock. Consider the following
code snippet.

public class A {
 void functionX() {
    String name = ClassB.getName(); // Static function
 }
}

public class ClassB {
  static String getName() {
    return 'ABC'
  }
}

I need a way of mocking the static function 'getName'.Please note that I do
not have rights to modify the legacy code.

Any help would be highly appreciated.

Thanks,
Siddhi
--
Sent from the jMock - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.