I am using NCrunch version 2.13.0.5
I have a project which uses Microsoft Fakes, when I run my tests with VS test engin every test pass without any problem. But when I do run them in NCrunch I have maybe 20% of them that fail with the ShimNotSupportedException
Basically they all seems to fail on the line where I pass a lambda expression to the Shim to create my return value before calling them.
Here is what the code looks like:
MyObject.Fakes.ShimMyObjectAdapteur.AllInstances.MyFunctionRequest =
Function()
Return New DtoReply
End Function
Do I have to do anything special to make those work with NCrunch?
Thank you!
Remco NCrunch Developer
#7081
17 Mar 2015 22:19 UTC
Hi, thanks for sharing this issue.
Do you receive this exception on all the code that uses shims? Is there any chance you can provide me with the full exception message?
The first thing to establish here is whether the profiler is being correctly loaded by NCrunch.
Cheers,
Remco
Do you receive this exception on all the code that uses shims? Is there any chance you can provide me with the full exception message?
The first thing to establish here is whether the profiler is being correctly loaded by NCrunch.
Cheers,
Remco
Morning Remco!
Yes every test that call the Shims fail, those that do not pass.
Here is the stack trace
Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotSupportedException: DSF.Service.CPS.TerminalId.Contrat.TerminalIdAdapteur
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InvokeEvent[T](T value, Action`1 eh)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.OnAttachedUnsupportedMethod(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.CheckInstrumentation(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InternalAttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.AttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimMethod(Delegate optionalStub, Object optionalReceiver, MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShim(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, ShimBinding flags, Type returnType, Type[] parameterTypes)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimPublicInstance(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, Type returnType, Type[] parameterTypes)
at TerminalId.Contrat.Fakes.ShimTerminalIdAdapteur.AllInstances.set_GenererTerminalIdGenererTerminalIdRequest(Func`3 value)
at Service.Implementation.Test.UtilitairePreparation.FakeTerminalIDContratAdapteur(Boolean codeRetourOk) in C:\Service.Implementation.Test\UtilitairePreparation.vb:line 233
at Service.Implementation.Test.PropagerSynchro.FakePropageSynchro() in C:\Service.Implementation.Test\PropagerSynchro.vb:line 13
at Service.Implementation.Test.PropagerSynchro.PropagerSynchro_Test001() in C:\Service.Implementation.Test\PropagerSynchro.vb:line 28
Thanks!
Yes every test that call the Shims fail, those that do not pass.
Here is the stack trace
Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotSupportedException: DSF.Service.CPS.TerminalId.Contrat.TerminalIdAdapteur
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InvokeEvent[T](T value, Action`1 eh)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.OnAttachedUnsupportedMethod(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.CheckInstrumentation(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InternalAttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.AttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimMethod(Delegate optionalStub, Object optionalReceiver, MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShim(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, ShimBinding flags, Type returnType, Type[] parameterTypes)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimPublicInstance(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, Type returnType, Type[] parameterTypes)
at TerminalId.Contrat.Fakes.ShimTerminalIdAdapteur.AllInstances.set_GenererTerminalIdGenererTerminalIdRequest(Func`3 value)
at Service.Implementation.Test.UtilitairePreparation.FakeTerminalIDContratAdapteur(Boolean codeRetourOk) in C:\Service.Implementation.Test\UtilitairePreparation.vb:line 233
at Service.Implementation.Test.PropagerSynchro.FakePropageSynchro() in C:\Service.Implementation.Test\PropagerSynchro.vb:line 13
at Service.Implementation.Test.PropagerSynchro.PropagerSynchro_Test001() in C:\Service.Implementation.Test\PropagerSynchro.vb:line 28
Thanks!
Remco NCrunch Developer
#7085
18 Mar 2015 22:45 UTC
Ok - I'm wondering if you could check something for me. We need to know whether NCrunch is attempting to load the profiler by setting the COR_PROFILER environment variable.
Can you open up a debug session into one of the failing tests? Once you're stopped on a line of code, open up the immediate window and type the following:
System.Environment.GetEnvironmentVariables();
Do you see the COR_PROFILER environment variable defined?
... Also .. if you get a chance, would you be able to submit an NCrunch bug report after you've had the tests fail?
Can you open up a debug session into one of the failing tests? Once you're stopped on a line of code, open up the immediate window and type the following:
System.Environment.GetEnvironmentVariables();
Do you see the COR_PROFILER environment variable defined?
... Also .. if you get a chance, would you be able to submit an NCrunch bug report after you've had the tests fail?
Edited 18 Mar 2015 22:46 UTC
Morning Remco!
Yes I see the variable in the immediate window, here is what I see
["COR_PROFILER"]: "{44250666-1751-4368-A29C-31CAF4CCF3F5}"
I'll open a bug with this info.
Thanks!
Yes I see the variable in the immediate window, here is what I see
["COR_PROFILER"]: "{44250666-1751-4368-A29C-31CAF4CCF3F5}"
I'll open a bug with this info.
Thanks!
Remco NCrunch Developer
#7089
19 Mar 2015 22:21 UTC
Thanks for sending through the bug report. The report contained a couple of very interesting errors:
MS Fakes configuration file for assembly 'DSF.Service.CPS.TerminalId.Contrat' was not found. Module information will be unavailable in generated collection plan file
MS Fakes configuration file for assembly 'DSF.Service.GDC.GDC610.Contrat' was not found. Module information will be unavailable in generated collection plan file
It may be worth checking that the configuration files for these assemblies exist in the normal places and that they aren't corrupt in any way. NCrunch relies on these files to build an MS Fakes collection plan, so if they aren't there then I'm not sure exactly how the runtime environment will behave. It's possible that VS has some kind of fallback method that allows it to operate without the files. This may be as simple as just removing the fakes assemblies and re-creating them.
MS Fakes configuration file for assembly 'DSF.Service.CPS.TerminalId.Contrat' was not found. Module information will be unavailable in generated collection plan file
MS Fakes configuration file for assembly 'DSF.Service.GDC.GDC610.Contrat' was not found. Module information will be unavailable in generated collection plan file
It may be worth checking that the configuration files for these assemblies exist in the normal places and that they aren't corrupt in any way. NCrunch relies on these files to build an MS Fakes collection plan, so if they aren't there then I'm not sure exactly how the runtime environment will behave. It's possible that VS has some kind of fallback method that allows it to operate without the files. This may be as simple as just removing the fakes assemblies and re-creating them.
Deleted post
#7100
23 Mar 2015 13:28 UTC
I finally found the reason why.
When we created the fakes, for those two DLL in particular, the developper who created them didn't put the version in the config file, so it was 0.0.0.0
I don't know why, but it seems that NCrunch doesn't like that, but that MSTest does not care :) I changed the config to put the real version number. Then recreated the references since changing the version number renamed the dll that the fakes framework create and voila. Everything works fine now!
Thanks for your time Remco, and for your amazing product!
When we created the fakes, for those two DLL in particular, the developper who created them didn't put the version in the config file, so it was 0.0.0.0
I don't know why, but it seems that NCrunch doesn't like that, but that MSTest does not care :) I changed the config to put the real version number. Then recreated the references since changing the version number renamed the dll that the fakes framework create and voila. Everything works fine now!
Thanks for your time Remco, and for your amazing product!
Remco NCrunch Developer
#7107
23 Mar 2015 22:52 UTC
Great! It's interesting that MSTest didn't complain about this.
I'm glad all is working well now :)
I'm glad all is working well now :)
It's work fine with VS2017 but NOT with VS2019:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.ResolveProfilerPath()
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize()
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
at G2019.Notifications.Tests.SpeechTests.Notifications_TextToSpeech_Speech_ShouldConfigOutput_WhenValidTextIsGiven() in
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.ResolveProfilerPath()
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize()
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
at G2019.Notifications.Tests.SpeechTests.Notifications_TextToSpeech_Speech_ShouldConfigOutput_WhenValidTextIsGiven() in
Remco NCrunch Developer
#13336
05 Apr 2019 03:17 UTC
Thanks for sharing this issue.
As VS2019 is still very new, we haven't yet had a chance to integrate with MSFakes in it.
We hope to implement this very soon. For now I recommend sticking with VS2017 if you need MSFakes with NCrunch.
As VS2019 is still very new, we haven't yet had a chance to integrate with MSFakes in it.
We hope to implement this very soon. For now I recommend sticking with VS2017 if you need MSFakes with NCrunch.
Deleted post
#13340
05 Apr 2019 08:46 UTC
Remco wrote:Thanks for sharing this issue.
As VS2019 is still very new, we haven't yet had a chance to integrate with MSFakes in it.
We hope to implement this very soon. For now I recommend sticking with VS2017 if you need MSFakes with NCrunch.
Would be great for us as well when Fakes are working in VS 2019.
thx!
Remco NCrunch Developer
#13364
11 Apr 2019 05:09 UTC
UppSol wrote:Remco wrote:Thanks for sharing this issue.
As VS2019 is still very new, we haven't yet had a chance to integrate with MSFakes in it.
We hope to implement this very soon. For now I recommend sticking with VS2017 if you need MSFakes with NCrunch.
Would be great for us as well when Fakes are working in VS 2019.
thx!
I'm hopeful that we'll have a release with this included some time next week.
Remco NCrunch Developer
#13389
17 Apr 2019 01:15 UTC
The fix for this is now available in the just-released v3.26.
Post a reply
Log in to reply.