From: Olaf K. <ok...@ab...> - 2003-03-10 15:53:05
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 her...@so... wrote: | Hi all, | | Here is my question : the object i want to mock has static methods (which | connect to back-end through a stack of numerous layer ...), and i want to | isolate my test from this back-end dependency. But the problem is that | static method cannot be overriden...so how could i achieve this ??? | | Any help will be appreciated Simple: Don't use the class that contains static methods from everywhere in your code. Create a *very* thin layer that has the same methods nonstatic and only delegates to the static version. This is the *only* user of the static methods. Then extract an interface from your layer. This is the basis for your mock implementation. Olaf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE+bLS87/xtFKqdCzURAi1vAKCGksABlPnz+0pCRE+X7Ygw0FarOgCfVGoy Kr6Gxlq5yXmN1NVsuXlGsxc= =IswN -----END PGP SIGNATURE----- |