Is there any framework, whick allows to mock concrete classes, not only interfaces in java 1.4? I have third party code with a singleton class, where I wanna change one function, without touching orignal code. Is it possible?
+1
A:
I recommend Mockito. A port to Java 1.4 is available here.
Robert Petermeier
2010-05-31 13:38:58
Can I use JMock without unit tests? As I see I need to extend class MockObjectTestCase? In my situation it would be very unhandy to use unit tests...
Filip
2010-05-31 14:00:46
You don't need to use a unit test, but certain methods will need to be run. I haven't tried it, but you can check the source code of MockObjectTestCase and see if it does anything special that has to be called separately.
Yishai
2010-05-31 14:09:57
Is it possible to mock some class so _all_ instantiation of some class created after some moment are mocked? I know it is possible in jmockit, but it's only available for newer java.
Filip
2010-06-01 08:48:34
@Filip, I don't think JMock naitively supports such a concept. Of course you could fake it by having a factory produce the object with that logic in it. AFAIK such a feature requires classloader intervention, which would make it tricky to run in a production system.
Yishai
2010-06-01 13:06:51