我在Visual Studio 2013中有一个CodedUI测试项目。按照说明将SpecFlow与CodedUI API集成后,我在FeatureSetup
中收到以下错误(已打开程序集绑定日志记录)
测试名称:TheWelcomeScreen
测试FullName :( ...)功能。欢迎屏幕
测试来源:c:\ path \ to \ My.feature:第6行
测试结果:失败
测试时间:0:00:00
结果讯息: 类初始化方法(...)Feature.FeatureSetup抛出异常。 System.IO.FileNotFoundException:System.IO.FileNotFoundException:无法加载文件或程序集“SpecFlow.Assist.Dynamic,Version = 1.0.2.0,Culture = neutral”或其依赖项之一。系统找不到指定的文件。
=== 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.
结果StackTrace:
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:
我打开并关闭了Visual Studio,卸载并重新安装了NuGet包,在本地删除了包源,清理,重建,重新启动,手动删除bin\Debug
文件夹并重建......列表继续。我仍然得到同样的例外。
答案 0 :(得分:1)
我不知道它是否符合设计要求,但MSTest不会将程序集部署到测试文件夹,除非在测试或测试代码中至少使用该程序集中的一种类型。因此,如果您通过反射实例化类型和汇编,那么您将遇到问题。
简单的解决方案是做两件事之一:
var dummy = new TheType()