当在Visual Studio 2017年将SQL服务器单元测试项目的单元测试项目,我得到以下错误:错误的单元测试项目2017年
The reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework,
Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" could not be added to the project.
This wizard will continue to run, but the resulting project may not build properly.
该项目似乎构建细算账,但所有SQL单元测试失败,出现以下错误:
Test Name: SqlTest1
Test FullName: UnitTestProject1.SqlServerUnitTest1.SqlTest1
Test Source: c:\[path]\SqlServerUnitTest1.cs : line 34
Test Outcome: Failed
Test Duration: 0:00:00.0278356
Result StackTrace:
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
Result Message:
Unable to set TestContext property for the class
UnitTestProject1.SqlServerUnitTest1.
Error: System.ArgumentException: Object of type
'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation'
cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'..
[我已经解决了这个问题,并将下面的答案添加到我的解决方案中,我将其创建为记录其他人可能会觉得有用的解决方案。如果其他任何人遇到过这种情况,我仍会感兴趣,并且可以从中找出原因]