XUnit测试仅在命令行中有效,而在VSCode GUI中无效

时间:2019-11-30 15:35:28

标签: .net-core visual-studio-code xunit

我有一个在VisualStudio中创建并迁移到Visual Studio Code之后的项目。现在,在VSCode中执行const updateObj = (value, keys, obj) => keys.forEach(k => obj[k] = value) const obj = { w: true, a: true, s: true, d: true }; updateObj(false, Object.keys(obj), obj); console.log(obj) updateObj(true, ['w', 's'], obj); console.log(obj)Debug Test时,我遇到以下问题:

enter image description here

我遇到以下错误:

Run Test

但是在Test run will use DLL(s) built for framework .NETCoreApp,Version=v2.1 and platform X86. Following DLL(s) do not match framework/platform settings. CoreTests.dll is built for Framework 2.0 and Platform AnyCPU. Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings. Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find /home/ronaldo.lanhellas/Workspace/safepark/backend-netcore/CoreTests/bin/Debug/netstandard2.0/testhost.dll. Please publish your test project and retry. at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler) Debugging complete. 命令下执行,一切正常:

enter image description here

这是我的CoreTests.csproj文件:

dotnet test

1 个答案:

答案 0 :(得分:0)

测试项目和您的项目应该在同一平台上,即X86或X64。

  

CoreTests.dll是为Framework 2.0和平台AnyCPU构建的。

将其从AnyCPU更改为特定平台。