axodox / AxoCover

Nice and free .Net code coverage support for Visual Studio with OpenCover.
https://marketplace.visualstudio.com/items?itemName=axodox1.AxoCover
MIT License
248 stars 60 forks source link

Not using MSTest.TestAdapter from VS bin folder #161

Open sivagorrepati opened 6 years ago

sivagorrepati commented 6 years ago

Hi,

We recently updated our project MSTest.TestAdapter to new version v1.2.0 to make use of latest features like DynamicData for test cases.

MSTest.TestAdapter included in AxoCover doesn't support the DynamicData attribute yet. Because of this, we are seeing errors while running test classes that contain DynamicData attribute.

Replacing the dll's in AxoCover's extension folder solved this issue. Is there a way to specify AxoCover to use MSTest.TestAdapter from project bin folder?

Thanks

======== Error Log ========

`Test execution started. Test discovery started.

   ___
  /   \
  |   |
  \   /
  /   \
 /     \

/ \ / \ | ____ | \/ ___/

AxoCover Test Runner Console (c) Peter Major 2017

Discovering tests... | Runner version is 1.1.378.0. | We are on x86 platform. | File redirection is enabled for the following files: | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll | Setting up file redirection hooks... | File redirection hooks are enabled.

Loading assembly from C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll... || Loaded discoverer: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestDiscoverer. << Assembly loaded. Running discoverer: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestDiscoverer... || Checking \\Release\dummy.UnitTests.dll...

   ___
  /   \
  |   |
  \   /
  /   \
 /     \

/ \ / \ | ____ | \/ ___/

AxoCover Test Runner Console (c) Peter Major 2017

Executing tests... | Runner version is 1.1.378.0. | We are on x86 platform. | File redirection is enabled for the following files: | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.dll | C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll | Setting up file redirection hooks... | File redirection hooks are enabled.

Loading assembly from C:\USERS\\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_77DF8791\EXTENSIONS\4bt01noz.jgp\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll... || Loaded executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor << Assembly loaded. Running executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor... || Processing tests in: \\Release\dummy.dll... || Checking \\Release\dummy.dll... | File redirection rules are cleared. < Could not execute tests. < SerializableException: Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. < < Server stack trace: < at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr typeInstArgs, Int32 typeInstCount, IntPtr methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) < at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) < at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) < at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) < at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) < at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit) < at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit) < at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.ReflectionUtility.GetCustomAttributes(MemberInfo memberInfo, Type type, Boolean inherit) < at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.ReflectionOperations.GetCustomAttributes(MemberInfo memberInfo, Type type, Boolean inherit) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers.ReflectHelper.GetCustomAttributes(MemberInfo memberInfo, Type type, Boolean inherit) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers.ReflectHelper.IsAttributeDefined(MemberInfo memberInfo, Type attributeType, Boolean inherit) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.IsAssemblyOrClassInitializeMethod(MethodInfo methodInfo, Type initializeAttributeType) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.GetAssemblyInfo(Type type) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.CreateClassInfo(Type classType, TestMethod testMethod) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.GetClassInfo(TestMethod testMethod) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TypeCache.GetTestMethodInfo(TestMethod testMethod, ITestContext testContext, Boolean captureDebugTraces) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunSingleTest(TestMethod testMethod, IDictionary2 testRunParameters) < at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) < at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) < < Exception rethrown at [0]: < at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) < at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunSingleTest(TestMethod testMethod, IDictionary2 testRunParameters) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsWithTestRunner(IEnumerable1 tests, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, String source, UnitTestRunner testRunner) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsInSource(IEnumerable1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, String source, Boolean isDeploymentDone) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTests(IEnumerable1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, Boolean isDeploymentDone) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(IEnumerable1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken runCancellationToken) < at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle) < at AxoCover.Runner.TestExecutionService.<>c__DisplayClass6_0.<RunTestsWorker>b__0() in C:\projects\axotools\AxoCover.Runner\TestExecutionService.cs:line 124 < at AxoCover.Runner.NativeServices.ExecuteWithFileRedirectionInternal(TestAdapterOptions adapterOptions, Action action, Action2 log) in C:\projects\axotools\AxoCover.Runner\NativeServices.cs:line 88 < at AxoCover.Runner.NativeServices.<>c__DisplayClass2_0.b__0() in C:\projects\axotools\AxoCover.Runner\NativeServices.cs:line 18 < at AxoCover.Runner.NativeServices.ExecuteCall(Action action, Action2 log) in C:\projects\axotools\AxoCover.Runner\NativeServices.cs:line 44 < at AxoCover.Runner.NativeServices.ExecuteWithFileRedirection(TestAdapterOptions adapterOptions, Action action, Action2 log) in C:\projects\axotools\AxoCover.Runner\NativeServices.cs:line 18 < at AxoCover.Runner.TestExecutionService.RunTestsWorker(TestExecutionTask[] executionTasks, TestExecutionOptions options) in C:\projects\axotools\AxoCover.Runner\TestExecutionService.cs:line 114 Shutting down... Test execution finished. || Checking \\Release\dummy.dll... MSTestAdapter failed to discover tests in class 'dummy.dll' because Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.. || Checking \\Release\dummy.dll... << Discoverer finished. | File redirection rules are cleared. < Test discovery finished. Test discovery finished. `

axodox commented 6 years ago

AxoCover uses the built-in runners as otherwise I was running into compatibility problems. However I tested it with latest MSTest, and now the master branch has it. Please download it from releases until it is released.

axodox commented 6 years ago

Released

sivagorrepati commented 6 years ago

Hi, Thanks for quick response to look into this issue.

I updated my AxoCover version to 1.1.385, but I am still seeing errors to detect test cases with DynamicData attribute.

MSTestAdapter failed to discover tests in class '' of assembly 'C:\.dll' because Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'..

jmacia commented 6 years ago

FYI, I've been able to work around this problem by disabling AxoCover's redirection feature, though (as @axodox points out, that's hardly ideal, as it could cause other downstream issues.