Build/Test Issues

Problem with MFakes when Fakes compiled outside test project

Started by dmitrijz on 4,114 views

Hello,
I have issues with NCrunch, latest version, when I generate Fakes inside test project, everything works and tests pass.
But for very large projects, we using special project to generate system fake assemblies and put them to dependencies folder, so in each test project we using static reference from dependencies folder and do not have any Fakes folder with xml configuration. Ncrunc always fails at using (ShimsContext.Create()) line.

Please tell whether it is possible to configure NCrunch to work with pre-compiled fake dlls. We are large company and currently I am trying to find solution for this problem, so I bought single license to test your tool on our project but now this issue is a blocker for us.

Thanks,
Dmitry
Hi Dmitry,

Unfortunately it's difficult for me to promise that I can find a way to make NCrunch work with such a scenario. MS Fakes itself is a Microsoft product and NCrunch's integration with this product was particularly challenging as there is no 'official' way in which Microsoft supports Fakes being loaded into the test environment by a third party tool. The goal of integrating with MS Fakes was to try and make this product work in its standard use case, which is where the fakes assemblies are generated at build time through the standard MSBuild tasks.

With that said, have you tried creating a single reference to a fakes assembly (perhaps a small one) from your test project that hasn't been pre-built using your custom method? NCrunch detects the requirement for MSFakes by looking for the <Fakes> project item inside the test project. If the <Fakes> configuration files are declared in the project, NCrunch will then initialise the intellitrace profiler to allow fakes to operate at run time. What I'm not certain of is how the intellitrace profiler will behave if the Fakes assemblies themselves are pre-generated and do not have any configuration - unfortunately this is outside of my knowledge of how this product works. I recommend trying this approach to see if it works for you.

Post a reply

Log in to reply.