Author Login
Post Reply
Thanks for your quick reply Steve.
The above code snippet was just a simple example. The code that I am working
on contains complex logic in the static function.
Steve Freeman-2 wrote:
>
> We don't support mocking of static methods since there is almost
> always a better way. That might mean testing it directly in an
> integration test or writing a thin layer above the static method and
> testing against /that/.
>
> If your method is as simple as getName() it might be better to just
> call the method.
> S.
>
> On 1 Dec 2009, at 03:37, Siddhi B <borkar.siddhi@(protected):
>> 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
>> --
>> View this message in context:
>> http://old.nabble.com/Mocking-Static-Methods-using-JMock-tp26585954p26585954.html
>> Sent from the jMock - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
--
Sent from the jMock - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email