我的测试都在昨天进行,但今天它们都失败了。我尝试制作一个新的测试类,只是运行一个空测试,但也失败了。我不知道发生了什么。这是堆栈跟踪:
ERROR: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
at NUnit.Framework.Api.FrameworkController+LoadTestsAction..ctor (NUnit.Framework.Api.FrameworkController controller, System.Object handler)[0x00008] in <116d15b838ac4e24a87624af132b3294>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke(System.Reflection.MonoCMethod, object, object[], System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke(System.Object obj, System.Object[] parameters) [0x00002] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:661
--- End of inner exception stack trace ---
Server stack trace:
at System.Reflection.MonoCMethod.InternalInvoke(System.Object obj, System.Object[] parameters) [0x0000f] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:667
at System.Reflection.MonoCMethod.DoInvoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:652
at System.Reflection.MonoCMethod.Invoke(System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:680
at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/rttype.cs:5419
at System.Activator.CreateInstance(System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000ae] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:107
at System.Activator.CreateInstance(System.String assemblyString, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo, System.Threading.StackCrawlMark& stackMark) [0x00077] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:365
at System.Activator.CreateInstance(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo) [0x00016] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:278
at System.AppDomain.CreateInstance(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x0000e] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System/AppDomain.cs:391
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstance(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at System.AppDomain.CreateInstanceAndUnwrap(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System/AppDomain.cs:412
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at(wrapper xdomain-dispatch) System.AppDomain:CreateInstanceAndUnwrap(object, byte[]&, byte[]&, string, string, bool)
Exception rethrown at[0]:
at(wrapper xdomain-invoke) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(System.String typeName, System.Object[] args) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(System.String testAssemblyPath, System.Collections.Generic.IDictionary`2[TKey, TValue] settings) [0x000a1] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage() [0x0007a] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.TestDomainRunner.LoadPackage() [0x00017] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.Load() [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.MasterTestRunner.LoadPackage() [0x0001d] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.EnsurePackageIsLoaded() [0x00008] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.Run(NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.MasterTestRunner.NUnit.Engine.ITestRunner.Run(NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit3Runner.NUnitTestRunner.Run(NUnit.Engine.ITestEventListener listener, System.String[] nameFilter, System.String path, System.String suiteName, System.String[] supportAssemblies, System.String testRunnerType, System.String testRunnerAssembly) [0x00076] in /Users/builder/data/lanes/4693/7ab1ca2c/source/monodevelop/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnitTestRunner.cs:129
at NUnit3Runner.NUnitTestRunner.Run(MonoDevelop.UnitTesting.NUnit.RunRequest r) [0x00031] in /Users/builder/data/lanes/4693/7ab1ca2c/source/monodevelop/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnitTestRunner.cs:72
at(wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod, object, object[], System.Exception&)
at System.Reflection.MonoMethod.Invoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.
at NUnit.Framework.Api.FrameworkController+LoadTestsAction..ctor (NUnit.Framework.Api.FrameworkController controller, System.Object handler)[0x00008] in <116d15b838ac4e24a87624af132b3294>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke(System.Reflection.MonoCMethod, object, object[], System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke(System.Object obj, System.Object[] parameters) [0x00002] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:661
--- End of inner exception stack trace ---
Server stack trace:
at System.Reflection.MonoCMethod.InternalInvoke(System.Object obj, System.Object[] parameters) [0x0000f] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:667
at System.Reflection.MonoCMethod.DoInvoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:652
at System.Reflection.MonoCMethod.Invoke(System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:680
at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/rttype.cs:5419
at System.Activator.CreateInstance(System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000ae] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:107
at System.Activator.CreateInstance(System.String assemblyString, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo, System.Threading.StackCrawlMark& stackMark) [0x00077] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:365
at System.Activator.CreateInstance(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo) [0x00016] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/activator.cs:278
at System.AppDomain.CreateInstance(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x0000e] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System/AppDomain.cs:391
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstance(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at System.AppDomain.CreateInstanceAndUnwrap(System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System/AppDomain.cs:412
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at(wrapper xdomain-dispatch) System.AppDomain:CreateInstanceAndUnwrap(object, byte[]&, byte[]&, string, string, bool)
Exception rethrown at[0]:
at(wrapper xdomain-invoke) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at(wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap(string, string, bool, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Globalization.CultureInfo, object[], System.Security.Policy.Evidence)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(System.String typeName, System.Object[] args) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(System.String testAssemblyPath, System.Collections.Generic.IDictionary`2[TKey, TValue] settings) [0x000a1] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage() [0x0007a] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.TestDomainRunner.LoadPackage() [0x00017] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.Load() [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.MasterTestRunner.LoadPackage() [0x0001d] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.EnsurePackageIsLoaded() [0x00008] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.AbstractTestRunner.Run(NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit.Engine.Runners.MasterTestRunner.NUnit.Engine.ITestRunner.Run(NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7934713e6a5945a48b191c3250979bc9>:0
at NUnit3Runner.NUnitTestRunner.Run(NUnit.Engine.ITestEventListener listener, System.String[] nameFilter, System.String path, System.String suiteName, System.String[] supportAssemblies, System.String testRunnerType, System.String testRunnerAssembly) [0x00076] in /Users/builder/data/lanes/4693/7ab1ca2c/source/monodevelop/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnitTestRunner.cs:129
at NUnit3Runner.NUnitTestRunner.Run(MonoDevelop.UnitTesting.NUnit.RunRequest r) [0x00031] in /Users/builder/data/lanes/4693/7ab1ca2c/source/monodevelop/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnit3Runner/NUnitTestRunner.cs:72
at(wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod, object, object[], System.Exception&)
at System.Reflection.MonoMethod.Invoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
有谁知道为什么我的测试可能会失败?测试类的内容只是一个空文件,带有测试方法存根。当然你不需要在这里看到一个空的方法存根?您可以通过转到Unity来复制完全相同的文件 - &gt;新的编辑模式脚本,然后不修改生成的文件。我的项目构建正常,测试在调试模式下运行。有什么想法吗?
更新
如果我使用Unity创建测试脚本并使用monodevelop运行它们,它们可以正常工作。我使用的是Unity Collaborate。他们没有与Rider或Visual Studio一起运行。也许是因为Unity Collaborate不能与除了Monodevelop之外的IDE一起使用?我必须设置某种项目设置吗?