我在 Visual Studio 2013 中有一个 CodedUI 测试项目。按照说明将 SpecFlow 与 CodedUI API 集成后,我在FeatureSetup
(Assembly binding logging was enabled)中收到以下错误
测试名称:TheWelcomeScreen
测试全名:(...)Feature.TheWelcomeScreen
测试来源:c:\path\to\My.feature:第 6 行
测试结果:失败
测试时间:0:00:00
结果消息:类初始化方法 (...)Feature.FeatureSetup 引发异常。System.IO.FileNotFoundException:System.IO.FileNotFoundException:无法加载文件或程序集“SpecFlow.Assist.Dynamic,版本=1.0.2.0,文化=中性”或其依赖项之一。该系统找不到指定的文件。
=== Pre-bind state information === LOG: DisplayName = SpecFlow.Assist.Dynamic, Version=1.0.2.0, Culture=neutral (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: SpecFlow.Assist.Dynamic, Version=1.0.2.0, Culture=neutral | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/Path/To/Current/TestResults/Directory/Out LOG: Initial PrivatePath = NULLCalling assembly : TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral, PublicKeyToken=0778194805d6db41. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Path\To\Current\TestResults\Directory\Out\BWE.Tests.DLL.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Path/To/Current/TestResults/Directory/Out/SpecFlow.Assist.Dynamic.DLL. LOG: Attempting download of new URL file:///C:/Path/To/Current/TestResults/Directory/Out/SpecFlow.Assist.Dynamic/SpecFlow.Assist.Dynamic.DLL. LOG: Attempting download of new URL file:///C:/Path/To/Current/TestResults/Directory/Out/SpecFlow.Assist.Dynamic.EXE. LOG: Attempting download of new URL file:///C:/Path/To/Current/TestResults/Directory/Out/SpecFlow.Assist.Dynamic/SpecFlow.Assist.Dynamic.EXE.
结果堆栈跟踪:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at TechTalk.SpecFlow.Infrastructure.BindingAssemblyLoader.Load(String assemblyName) at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at TechTalk.SpecFlow.Infrastructure.TestRunnerFactory.Create(Assembly testAssembly) at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(TestRunnerKey key) at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(TestRunnerKey key) at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Assembly testAssembly, Boolean async) at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner() at (...)Feature.FeatureSetup(TestContext testContext) in c:\path\to\My.feature.cs:line 0
我packages.config
的这个解决方案的文件:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="3.3.0" targetFramework="net40" />
<package id="CompareNETObjects" version="3.01.0.0" targetFramework="net40" />
<package id="ImpromptuInterface" version="6.2.2" targetFramework="net40" />
<package id="SpecFlow" version="1.9.0" targetFramework="net40" />
<package id="SpecFlow.Assist.Dynamic" version="1.0.2" targetFramework="net40" />
</packages>
在 SpecFlow.Assist.Dynamic DLL 的“属性”中,该CopyLocal
设置设置为true
. 构建解决方案后,该bin\Debug
文件夹SpecFlow.Assist.Dynamic.dll
在其中,但该文件夹中当前测试运行的TestResults
文件夹不包含此 DLL。它确实包含以下 DLL:
- 我的项目的 DLL
- AutoMapper.dll
- KellermanSoftware.Compare-Net-Objects.dll
- TechTalk.SpecFlow.dll
我已经打开并关闭了 Visual Studio,卸载并重新安装了 NuGet 包,在本地删除了包源,清理、重建、重新启动、手动删除了bin\Debug
文件夹并重新构建了......列表还在继续。我仍然遇到同样的异常。