Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Problem with Fakes
rlejeune
#1 Posted : Tuesday, March 17, 2015 3:10:28 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/10/2012(UTC)
Posts: 8
Location: Quebec

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
#2 Posted : Tuesday, March 17, 2015 10:19:29 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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
rlejeune
#3 Posted : Wednesday, March 18, 2015 12:19:00 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/10/2012(UTC)
Posts: 8
Location: Quebec

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!
Remco
#4 Posted : Wednesday, March 18, 2015 10:45:59 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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?
rlejeune
#5 Posted : Thursday, March 19, 2015 1:33:27 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/10/2012(UTC)
Posts: 8
Location: Quebec

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!
Remco
#6 Posted : Thursday, March 19, 2015 10:21:45 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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.
rlejeune
#8 Posted : Monday, March 23, 2015 3:31:11 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/10/2012(UTC)
Posts: 8
Location: Quebec

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!
Remco
#9 Posted : Monday, March 23, 2015 10:52:44 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Great! It's interesting that MSTest didn't complain about this.

I'm glad all is working well now :)
GYSSELS
#10 Posted : Friday, April 5, 2019 3:07:06 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/5/2019(UTC)
Posts: 1
Location: Canada

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
Remco
#11 Posted : Friday, April 5, 2019 3:17:46 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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.
UppSol
#12 Posted : Thursday, April 11, 2019 4:49:52 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/21/2019(UTC)
Posts: 39
Location: Austria

Thanks: 30 times
Was thanked: 7 time(s) in 7 post(s)
Remco;13336 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
#13 Posted : Thursday, April 11, 2019 5:09:03 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
UppSol;13363 wrote:
Remco;13336 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.
1 user thanked Remco for this useful post.
UppSol on 4/11/2019(UTC)
Remco
#15 Posted : Wednesday, April 17, 2019 1:15:39 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
The fix for this is now available in the just-released v3.26.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.083 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download