gpt4 book ai didi

MSTest DeploymentItem 属性导致找不到 SQLite.Interop.dll

转载 作者:行者123 更新时间:2023-12-04 15:41:02 25 4
gpt4 key购买 nike

我的单元测试套件立即未能通过测试运行 System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll'这是测试中所需的依赖项 [AssemblyInitialize]方法。

我确定这是由执行任何使用 [DeploymentItem] 的测试引起的属性,对于类或方法都是如此。任何不使用此属性的测试都会通过。

在 VS2019 中启用测试诊断日志记录后,没有明显的错误,但我可以看到此配置。

 <RunSettings>
<RunConfiguration>
<ResultsDirectory>D:\Dev\****\src\TestResults</ResultsDirectory>
<SolutionDirectory>D:\Dev\****\src\</SolutionDirectory>
<TargetPlatform>X86</TargetPlatform>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
</RunSettings>

我的测试项目都是为<PlatformTarget>AnyCPU</PlatformTarget>配置的所以我想知道 SQLite.Interop.dll 是否未找到,因为 x86 与 x64 存在问题。

  • 我在哪里可以配置 <RunSettings>
  • 为什么 SQLite.Interop.dll找不到?

更新

使用 procmon.exe过滤 testhost.exeSQLite.Interop.dll我可以看到没有 [DeploymentItem] 的测试属性开始寻找项目中的dll bin\Debugbin\Debug\x64\SQLite.Interop.dll 找到它的文件夹.

那些具有属性的测试开始在测试结果目录中查找 TestResults\...\Out然后全机C:\Windows , C:\Program Files , C:Users但再也不会低于bin\Debug .

使用 VSTest.Console.exe 运行相同的测试没有这个问题。

最佳答案

解决;

  1. Configure unit tests by using a .runsettings file
  2. 添加设置 <DisableAppDomain>True</DisableAppDomain> , 请参阅 Configure a test run

请注意,运行设置不能保留在项目或解决方案级别,需要在IDE中设置; https://developercommunity.visualstudio.com/content/problem/151608/ability-to-set-runsettings-in-project-file.html

关于MSTest DeploymentItem 属性导致找不到 SQLite.Interop.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57780371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com