Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Specflow&x2B;MSTest:测试失败,出现错误;无法加载文件或程序集';MyPlugin.SpecFlowPlugin';或它的一个依赖项“;_C#_.net_Mstest_Specflow - Fatal编程技术网

C# Specflow&x2B;MSTest:测试失败,出现错误;无法加载文件或程序集';MyPlugin.SpecFlowPlugin';或它的一个依赖项“;

C# Specflow&x2B;MSTest:测试失败,出现错误;无法加载文件或程序集';MyPlugin.SpecFlowPlugin';或它的一个依赖项“;,c#,.net,mstest,specflow,C#,.net,Mstest,Specflow,我正在使用MSTest和命令行运行specflow测试。 项目生成没有错误,但测试失败并出现错误: Class Initialization method MyProject.SpecFiles.MyFeature.FeatureSetup threw exception. TechTalk.SpecFlow.SpecFlowException: TechTalk.SpecFlow.SpecFlowException: Unable to load plugin: MyPlugin. P

我正在使用MSTest和命令行运行specflow测试。 项目生成没有错误,但测试失败并出现错误:

    Class Initialization method MyProject.SpecFiles.MyFeature.FeatureSetup threw exception. TechTalk.SpecFlow.SpecFlowException: TechTalk.SpecFlow.SpecFlowException: Unable to load plugin: MyPlugin. Please check http://go.specflow.org/doc-plugins for details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'MyPlugin.SpecFlowPlugin' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
.
+++++++++++++++++++
STACK TRACE:
    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.RuntimePluginLoader.LoadPlugin(PluginDescriptor pluginDescriptor)
 --- End of inner exception stack trace ---
    at TechTalk.SpecFlow.Infrastructure.RuntimePluginLoader.LoadPlugin(PluginDescriptor pluginDescriptor)
   at TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.<>c__DisplayClass3.<LoadPlugins>b__1(PluginDescriptor pd)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container)
   at TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.CreateContainer(IRuntimeConfigurationProvider configurationProvider)
   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 MyProject.SpecFiles.MyFeature.FeatureSetup(TestContext testContext) in d:\Jenkins\workspace\MyProject\SpecFiles\MyFeature.feature.cs:line 0
类初始化方法MyProject.SpecFiles.MyFeature.FeatureSetup引发异常。TechTalk.SpecFlow.SpecFlowException:TechTalk.SpecFlow.SpecFlowException:无法加载插件:MyPlugin。请查收http://go.specflow.org/doc-plugins 有关详细信息。-->System.IO.FileNotFoundException:无法加载文件或程序集“MyPlugin.SpecFlowPlugin”或其依赖项之一。系统找不到指定的文件。WRN:程序集绑定日志记录已关闭。
要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1。
注意:程序集绑定失败日志记录会带来一些性能损失。
要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog]。
.
+++++++++++++++++++
堆栈跟踪:
在System.Reflection.RuntimeAssembly.\n加载(AssemblyName文件名、字符串代码基、证据assemblySecurity、RuntimeAssembly位置提示、StackScrawMark和stackMark、IntPtr pPrivHostBinder、Boolean throwOnFileNotFound、Boolean for Inspection、Boolean suppressSecurityChecks)
位于System.Reflection.RuntimeAssembly.nLoad(AssemblyName文件名、字符串代码基、证据assemblySecurity、RuntimeAssemblyLocationHint、StackScrawlMark和stackMark、IntPtr pPrivHostBinder、Boolean throwOnFileNotFound、Boolean For Inspection、Boolean suppressSecurityChecks)
位于System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackScrawMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean For Inspection,Boolean suppressSecurityChecks)
在System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString、证据assemblySecurity、StackScrawMark和stackMark、IntPtr pPrivHostBinder、用于内省的布尔值)
在System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString、证据assemblySecurity、StackScrawMark和stackMark,布尔值用于内省)
在System.Reflection.Assembly.Load处(字符串assemblyString)
位于TechTalk.SpecFlow.Infrastructure.RuntimePluginLoader.LoadPlugin(PluginDescriptor PluginDescriptor)
---内部异常堆栈跟踪的结束---
位于TechTalk.SpecFlow.Infrastructure.RuntimePluginLoader.LoadPlugin(PluginDescriptor PluginDescriptor)
在TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.c__DisplayClass3.b__1(PluginDescriptor pd)
在System.Linq.Enumerable.WhereSelectEnumerableInterator`2.MoveNext()中
在System.Linq.Enumerable.d_u71`1.MoveNext()中
在System.Linq.Buffer`1..ctor处(IEnumerable`1源)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1源)
位于TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.LoadPlugins(iRuntimeConfiguration提供程序配置提供程序,ObjectContainer容器)
位于TechTalk.SpecFlow.Infrastructure.TestRunContainerBuilder.CreateContainer(iRuntimeConfiguration提供程序配置提供程序)
位于TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(TestRunnerKey)
位于TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(TestRunnerKey)
在TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(程序集testAssembly,布尔异步)
在TechTalk.SpecFlow.TestRunnerManager.GetTestRunner()上
在d:\Jenkins\workspace\MyProject\SpecFiles\MyFeature.feature.cs中的MyProject.SpecFiles.MyFeature.FeatureSetup(TestContext TestContext)中:第0行

有人能帮我吗

问题可能是在specflow希望从中加载插件dll的位置找不到插件dll(或其依赖项之一)

您可以在app.config中指定查找插件的位置,如下所示:

以下示例用于加载名为“MyNewPlugin.SpecFlowPlugin.dll”的插件程序集,该插件程序集位于与当前项目处于同一级别的名为“Binaries”的文件夹中



检查生成服务器上的输出以查看插件dll的创建位置,并适当调整生成或配置

看起来您正试图在项目中加载程序集。为了加载程序集,您必须在app.config中添加以下代码

<stepAssemblies>
     <stepAssembly assembly="{name-of-assembly-containing-bindgins}" /> 
</stepAssemblies>


问题已解决。我已经添加了带有选中部署复选框的.testsettings文件。用于部署的项目-包含所有必需DLL的bin文件夹

使用Visual Studio运行测试时,App.config“”中存在以下行。此问题不存在,但如果使用命令行和MStest.exe,则会出现此问题。App.config中存在步骤程序集。
<stepAssemblies>
     <stepAssembly assembly="{name-of-assembly-containing-bindgins}" /> 
</stepAssemblies>