yes typemock uses the CLR profiling API and is a paid product. I don’t
if typemock runs on Mono either, couldn’t find it on their website.
For me running on mono is one of the base requirements of my mocker,
I’m too often on my mac or linux machines to neglect that.
That being said 99% of your tests will not need to mock a static method,
if you know about the limitation you can work around it if you’re in
of the code.
I’ve looked into this now and I can’t find the ICorProfilerCallback2
interface in Mono on my mac. Mono allows you to write a profiler too
but AFAICT that has to be written in C, which I don’t know, and it would
also require to start mono with a different set of parameters.
So I guess the way forward is mono.cecil, but I don’t like the approach
need to take at all:
Backup the assemblies in the bin
before running the tests instrument every assembly in the bin folder
all the static method calls wrapped inside a before and after hook.
hooks call out to caricature and provide the mocking behavior.
Save the modified assembly in the bin
run the test.
if there is an error or an interrupt or exit, restore assemblies from
and this can go wrong easily.
It also means I have to make it a requirement to require caricature
requiring any of your application code in the test_helper or spec_helper
If somebody has a better solution by all means share, or better yet put
in and send me a pull request
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Author of IronRuby in Action (http://manning.com/carrero)