升级到 xunit2 并遵循迁移指南 (http://xunit.github.io/docs/test-migration.html) 后,在我的项目中发现测试时出现以下错误:------ Discover test started ------[xUnit.net 00:00:00.0701819] Exception discovering tests from MyLibrary.Tests.dll: System.MissingMethodException: Constructor on type 'Xunit.Sdk.TestFrameworkProxy' not found. at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at Xunit.RemoteAppDomainManager.CreateObject[TObject](String assemblyName, String typeName, Object[] args) at Xunit.Xunit2Discoverer..ctor(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder) at Xunit.XunitFrontController.CreateInnerController() at Xunit.XunitFrontController.get_InnerController() at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.DiscoverTests[TVisitor](IEnumerable`1 sources, IMessageLogger logger, Func`3 visitorFactory, Action`3 visitComplete, Stopwatch stopwatch)========== Discover test finished: 0 found (0:00:00.2454142) ==========
我没有调试 testrunners 或 xunit 的经验,所以我不知道去哪里找。我希望之前有人遇到过这个问题并能快速给出答案,但我的 google-fu 什么也没显示。
我不知道哪些信息对追踪这个问题有用,所以我会根据人们的要求添加一些东西。
最佳答案
来自测试运行器文档: If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio
。
删除 %TEMP%\VisualStudioTestExplorerExtensions
似乎可以解决这个问题。
引用:http://xunit.github.io/docs/running-tests-in-vs.html
关于升级到 v2 后 xunit 无法发现测试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29632900/