I’m looking into JustMock the mocking framework from Telerik. It seems pretty good and all. There is one particular feature that is really interesting for us is what they call Future Mocking. Where basically you can mock an instance that was created inside the method you want to test (bad code I know).
For example :
public void foo()
{
var service = new MyService();
service.DoSomething();
}
So this feature will allow to mock the MyService instance used inside that foo() method.
I think TypeMock has similar feature.
I was wondering if there are other framework that allows this? Moq? NMock? FakeItEasy? Do they have this feature? Any other frameworks???
Traditional frameworks like you mention (Moq, NMock, FakeItEasy) work based on production code being loosely coupled. Creating the dependency inside a method (as opposed to passing it in via a parameter or class constructor) makes it such that the seams for injecting fakes (stubs or mocks) would not be possible.
JustMock and TypeMock get around this using profiler APIs (IIRC) to intercept and detour code. Another framework that does this is Miscosoft Moles, soon to be named Fakes in Visual Studio 11.