使用.NET Core MSTest运行单元测试:“未找到以下TestContainer ......”

问题描述 投票:5回答:3

我搜索了高低,无法找到这个例外的答案。当我搜索时,This question是主要出现的,但它没有解决这个问题。

[7/8/2018 6:22:22 PM Informational] Executing test method 'CoreScraper.FlyerScraper.GetAllCurrentFlyers'
[7/8/2018 6:22:22 PM Error] System.InvalidOperationException: The following TestContainer was not found 'C:\Users\Username\Documents\Visual Studio 2017\Projects\ProductApp\CoreScraper\bin\Debug\netcoreapp2.0\CoreScraper.dll'
   at Microsoft.VisualStudio.TestWindow.Controller.TestContainerProvider.<GetTestContainerAsync>d__61.MoveNext()

“CoreScraper”是项目的名称。当我查看...\netcoreapp2.0\文件夹时,CoreScraper.dll肯定在那里。我通过右键单击测试方法并选择“运行测试”来运行测试。我第一次运行时测试运行良好,但从那以后它就给了我这个错误。我已经关闭了Visual Studio并重新打开,删除了bin\的内容,清理并重建了项目等。

c# selenium-webdriver mstest asp.net-core-2.1
3个回答
11
投票

问题是没有安装NuGet包Microsoft.NET.Test.Sdk。通过NuGet Package Manager在项目中安装此软件包解决了这个问题。

这对我来说并不直观,因为我有另一个没有Microsoft.NET.Test.Sdk包的单元测试项目,但该项目是.NET Framework 4.6.2。


5
投票

今天我遇到了与Visual Studio 2017 for xUnit Tests类似的问题。我的观察:

  1. 在Release / Debug模式之间切换时出现问题。
  2. 解决方案:重新启动Visual Studio并解决了该问题。

注意在一些Google / Bing之后,我发现每个人都通过安装一些软件包来获得解决方案。但是在我的情况下,一切都在以前工作,因此决定不再安装任何东西。

希望能帮助到你。


3
投票

正如@ Marathon55所说安装Microsoft.NET.Test.Sdk解决了这个问题,但在我的情况下,我要安装另外两个包MSTest.TestFrameworkMSTest.TestAdapter。可能会帮助别人

© www.soinside.com 2019 - 2024. All rights reserved.