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

Notification

Icon
Error

InvalidCastException when building assembly containing xunit 2.2 tests for a ASP.NET Core 2.0
distilled
#1 Posted : Tuesday, July 25, 2017 6:48:29 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/3/2012(UTC)
Posts: 6

Was thanked: 2 time(s) in 2 post(s)
I have a .NET Core 2.0 project (target .NET Framework 4.7) that contains xunit v2.2 tests for an ASP.NET Core 2.0 project in the same solution. When NCrunch tries to build the project an InvalidCastException gets thrown:

Code:

An error occurred while analysing this project after it was built: System.InvalidCastException: Unable to cast object of type 'Xunit.Sdk.ReflectionAssemblyInfo' to type 'Xunit.Abstractions.IAssemblyInfo'.
at Xunit.AppDomainManager_NoAppDomain.CreateObject[TObject](AssemblyName assemblyName, String typeName, Object[] args)
at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk)
at nCrunch.Module.XUnit2.Integration.XUnitTestFrameworkContainer.GetDynamicFramework(FilePath assemblyFilePath, DirectoryPath workingDirectory)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.<>c__DisplayClass2_0.<FindFrameworkTestsInAssembly>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)


I have both "Pre-load all assembly references into test environment" and "Copy referenced assemblies to workspace" set to "true" for the test project.
Remco
#2 Posted : Tuesday, July 25, 2017 11:06:55 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 664 times
Was thanked: 780 time(s) in 742 post(s)
Hi, thanks for sharing this issue.

See here for more information about this - http://forum.ncrunch.net/yaf_postsm10835_AutoFixture-Warning-Incorrect.aspx#post10835.

This is caused by there being an inconsistent version of xunit.abstractions loaded into your test environment. From v3.9, NCrunch will always try to use the version of xunit.abstractions that corresponds with the version of xunit you're using. This is a difference in behaviour with v3.8, where the version of xunit.abstractions was forced to v2.1 through a binding redirection.

Try removing and reinstating your xunit references. Check that you aren't using other tools that might be referencing different versions of xunit.abstractions.
Users browsing this topic
Guest (3)
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.024 seconds.