Pro-Coded-Public / Pro.NBench.xUnit

Integration of NBench, xUnit and ReSharper / Visual Studio Test Explorer
MIT License
16 stars 4 forks source link

Getting ReflectionTypeLoadException when executing test in visualstudio (using xunit visualstudio runner) #1

Closed nripendra closed 7 years ago

nripendra commented 7 years ago

Dump from Test Report

Test Name: Monotype.DataFlow.SDK.PerfTests.DictionaryMemoryTests.AddMemory_Measurement_Theory(numberOfAdds: 1000000) Test FullName: Monotype.DataFlow.SDK.PerfTests.DictionaryMemoryTests.AddMemory_Measurement_Theory (5425e0db5a95397c06785171997878f5d285d753) Test Source: D:\Projects\MEL-POC2\MEL\Monotype.DataFlow.SDK.PerfTests\AbstractDataFlowPerfTests.cs : line 45 Test Outcome: Failed Test Duration: 0:00:00.001

Result StackTrace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeAssembly.get_DefinedTypes() at NBench.Sdk.Compiler.ReflectionDiscovery.<>c.b4_0(IEnumerable1 types, Assembly assembly) at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func`3 func) at NBench.Sdk.Compiler.ReflectionDiscovery.LoadAllTypeConfigurators() at NBench.Sdk.Compiler.ReflectionDiscovery.GetConfiguratorTypeForMeasurement(Type measurementType, Assembly specificAssembly) at NBench.Sdk.Compiler.ReflectionDiscovery.GetConfiguratorForMeasurement(Type measurementType, Assembly specificAssembly) at NBench.Sdk.Compiler.ReflectionDiscovery.CreateSettingsForBenchmark(BenchmarkClassMetadata benchmarkClass) at Pro.NBench.xUnit.XunitExtensions.NBenchTestInvoker.RunNBenchTest(Object testClassInstance) in C:\Code\Projects\VS2015\Pro.NBench.xUnit\Pro.NBench.xUnit\XunitExtensions\NBenchTestInvoker.cs:line 150 at Pro.NBench.xUnit.XunitExtensions.NBenchTestInvoker.<>c__DisplayClass4_0.b0() in C:\Code\Projects\VS2015\Pro.NBench.xUnit\Pro.NBench.xUnit\XunitExtensions\NBenchTestInvoker.cs:line 71 at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Pro.NBench.xUnit.XunitExtensions.NBenchTestInvoker.d__4.MoveNext() in C:\Code\Projects\VS2015\Pro.NBench.xUnit\Pro.NBench.xUnit\XunitExtensions\NBenchTestInvoker.cs:line 71 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Result Message: System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

mcquiggd commented 7 years ago

@nripendra

Ok, at first sight the error Unable to load one or more of the requested type occurs when invoking the Test Method.

Now, a couple of questions:

  1. Is this running on Windows, or Mono on another platform?
  2. If you download the example solution, and make no changes, does that execute tests correctly?
  3. Can you supply an example of the code you are attempting to test so I can debug this?

David

nripendra commented 7 years ago
  1. It is running on Windows...
  2. I haven't tested downloading the solutions, but for exact copied code problem still exists. I'll try downloading the solutions.
  3. Sorry, this is part of my work code, I'll see if I can provide similar code.
mcquiggd commented 7 years ago

@nripendra

Ok, thanks.. I would first suggest trying the supplied sample project. If that gives you the same error that is easier for me to investigate.

Something did occur to me - an instance of the Test to be executed is created using a Dynamic Method Delegates. In the current implementation. the creation of this Delegate is currently limited to have three parameters, which is a reasonable number for a Test. It would fail if the Test has more, but I would have expected a different error message if this was the case...

mcquiggd commented 7 years ago

I have closed this, as I have not heard back regarding whether the sample project is functional for you. If you have further information, please feel free to supply it, and I will investigate.