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

Notification

Icon
Error

MissingMethodException during Analyzing
Silvenga
#1 Posted : Wednesday, December 2, 2020 9:56:39 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/24/2016(UTC)
Posts: 34
Location: United States of America

Was thanked: 2 time(s) in 2 post(s)
We have unit tests for a wide gamut of frameworks, everything from e.g. .NET Framework, .NET Core, and .NET 5. When analysing the .NET 5 builds, the following error is thrown:

Code:

An error occurred while analysing this project after it was built: System.MissingMethodException: Method not found: 'System.String System.AppDomainSetup.get_ConfigurationFile()'.
   at Xunit.Sdk.XunitTestFrameworkDiscoverer..ctor(IAssemblyInfo assemblyInfo, ISourceInformationProvider sourceProvider, IMessageSink diagnosticMessageSink, IXunitTestCollectionFactory collectionFactory)
   at Xunit.Sdk.XunitTestFramework.CreateDiscoverer(IAssemblyInfo assemblyInfo) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\XunitTestFramework.cs:line 21
   at Xunit.Sdk.TestFramework.GetDiscoverer(IAssemblyInfo assemblyInfo) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\TestFramework.cs:line 71
   at Xunit.Sdk.TestFrameworkProxy.GetDiscoverer(IAssemblyInfo assembly) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\TestFrameworkProxy.cs:line 67
   at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2Discoverer.cs:line 106
   at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2Discoverer.cs:line 62
   at Xunit.Xunit2..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyTestAssemblyExists) in C:\Dev\xunit\xunit\src\xunit.runner.utility\Frameworks\v2\Xunit2.cs:line 41
   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.<>c__DisplayClass0_2.<FindTestsForFrameworks>b__1()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.TestExecution.TestFinder.<>c__DisplayClass0_0.<FindTestsForFrameworks>b__0()
   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)


This appears to be related to a custom XunitTestFramework that we use to selectively ignore tests using attributes e.g. WindowsOnlyAttribute. Removing all the code from the custom XunitTestFramework still causes the issue.

Code:


[assembly: TestFramework(TestFramework.FullName, TestFramework.Assembly)]

...


public class TestFramework : XunitTestFramework
{
    public const string FullName = "Blah.TestsCommon.XUnit.TestFramework";
    public const string Assembly = "Blah.TestsCommon";

    public TestFramework(IMessageSink messageSink) : base(messageSink)
    {
    }
}



We've been using this custom XunitTestFramework for years with NCrunch and again, the failures only occur when building under .NET 5. The same project targets .NET Core 3.1 and .NET Core 2.1 and is analyzed successfully.

Removing the TestFrameworkAttribute does work, but of course, breaks our tests since we have a custom XunitTestFrameworkDiscoverer.

Using the latest version of Visual Studio, with the latest .NET 5 SDK's. Also using the most recent version of NCrunch.
michaelkroes
#2 Posted : Thursday, December 3, 2020 4:53:09 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 228
Location: Netherlands

Thanks: 100 times
Was thanked: 50 time(s) in 48 post(s)
Hi Thanks for posting!

I've tried to reproduce the problem given the example you've given above. On my machine this works.

I've created a multi target project with netcoreapp3.1;net5.0;net472. I've added the xunit TestFramework as you mentioned above. The tests pass.

Could you help me out by providing a small sample project for me to run?
Silvenga
#3 Posted : Thursday, December 3, 2020 4:25:23 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/24/2016(UTC)
Posts: 34
Location: United States of America

Was thanked: 2 time(s) in 2 post(s)
Oops, sorry about that. I messed around with it and was able to repo the behavior here: https://github.com/Silvenga/ncrunch-bug-repo

The exception seems to be triggered when the custom TestFramework exists in a different assembly under a different target framework.
1 user thanked Silvenga for this useful post.
michaelkroes on 12/3/2020(UTC)
michaelkroes
#4 Posted : Friday, December 4, 2020 5:42:38 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 228
Location: Netherlands

Thanks: 100 times
Was thanked: 50 time(s) in 48 post(s)
Thanks for that!

I've tried the test solution all the tests pass without any errors. Would you mind confirming that you are running version 4.6.0.3? There was a change between the first net5.0 release that NCrunch supported (4.5.0.3) that solved an issue with multi target projects.
Silvenga
#5 Posted : Friday, December 4, 2020 8:51:54 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/24/2016(UTC)
Posts: 34
Location: United States of America

Was thanked: 2 time(s) in 2 post(s)
You're right, I upgraded NCrunch on all my machines except one. I just downloaded NCrunch 4.6.0.3, but never installed it. Upgrading fixes this problem.

Apologies.
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.213 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download