Hello,
we just switched from MS Fakes to Telerik JustMock.
Upon that, NCrunch showed the following error:
Quote:
NCrunch: This test was executed on server '(local)'
*** Failures ***
Exception
System.TypeInitializationException: System.TypeInitializationException : Der Typeninitialisierer für "Telerik.JustMock.Core.Context.MockingContext" hat eine Ausnahme verursacht.
---- System.InvalidOperationException : Some attribute type among MbUnit.Framework.SetUpAttribute, mbunit,MbUnit.Framework.TearDownAttribute, mbunit not found.
bei Telerik.JustMock.Core.Context.MockingContext.RetireRepository()
bei Telerik.JustMock.Mock.<>c.<Reset>b__43_0()
bei Telerik.JustMock.Mock.Reset()
bei JustMockWithNCrunch.JustMockTest.TestMethod() in C:\Users\dklinger\Documents\Visual Studio 2017\Projects\JustMockWithNCrunch\JustMockWithNCrunch\JustMockTest.cs:Zeile 15.
----- Inner Stack Trace -----
bei Telerik.JustMock.Core.Context.HierarchicalTestFrameworkContextResolver.CreateAttributeMatcher(String[] attributeTypeNames)
bei Telerik.JustMock.Core.Context.HierarchicalTestFrameworkContextResolver.AddRepositoryOperations(String[] attributeTypeNames, Func`2 getKey, Func`3 isInheritingContext, Boolean isLeaf, Boolean isUsedOnAllThreads)
bei Telerik.JustMock.Core.Context.HierarchicalTestFrameworkContextResolver.SetupStandardHierarchicalTestStructure(String[] testMethodAttrs, String[] testSetupAttrs, String[] fixtureSetupAttrs, String[] assemblySetupAttrs, FixtureConstuctorSemantics fixtureConstructorSemantics)
bei Telerik.JustMock.Core.Context.MbUnitContextResolver..ctor()
bei Telerik.JustMock.Core.Context.MockingContext..cctor()
That one was very unexpected as we are not using the MBUnit-Framework anywhere in our projects.
After further research we discovered the following file within JustMock:
https://github.com/teler...bUnitContextResolver.cs
In there it will be checked if the type "Gallio.Framework.Assertions.AssertionException" is present in an assembly "gallio.dll" within the current execution Test-AppDomain.
Digging depper we saw that NCrunch is loading the Gallio-DLL in its nCrunch.TestHost-Process if xUnit1 is used:
[img=(- BROKEN LINK -)]NCrunch-AppDomain using xUnit1[/img]
Because of the existence of the Gallio-DLL - which, as we think, is not needed for xUnit1 - JustMock ist trying to initialize its MBUnitContextResolver and fails on doing this as MBUnit is not present.
The workaround is to enable the NCrunch-option "Pre-load all assembly references into test environment" which is not recommended from your side.
So we have a few questions:
- Is it expected that NCrunch fails with JustMock and xUnit1 without having the Pre-Load-option set?
- Is ist save and recommend to enable the Pre-Load-option in this case?
- Is this some kind of edge-case-bug which you could fix in any way so we don't have to enable the Pre-Load-option as it slows down text execution?
I have a minimal-example available if you want to reproduce the behaviour.
Kind Regards,
Daniel