好的。所以這就是我所處的位置。我使用Specflow 2.2.0將自動化單元測試與我們的CodedUI測試工作配對。我正在開發一個插件來將CodedUI Test屬性添加到Specflow Feature測試中,我遇到了一些問題。 Specflow無法識別我的插件來爲Specflow特性文件生成CodedUI測試屬性,我不明白爲什麼,因爲我遵循了文檔中的每條指令以及查看GitHub上的其他插件以確保我做得正確。Specflow CodedUI Generator插件不生成功能文件
我在自己的類庫項目中擁有該插件,並將其dll autocopies構建到Spectro所在解決方案中的packages文件夾。我編輯了彙編文件以指向生成器。我有事件處理程序的初始化程序。我的CodedUI項目的app.config中的所有內容都是正確的,據我所知,我仍然遇到錯誤。這裏是我的一切都在問候插件和其他相關作品:
這裏是我的插件的代碼初始化IGenerator類:
namespace SpecflowCUITPluginLib
{
public class CodedUiPlugin : IGeneratorPlugin
{
public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
{
generatorPluginEvents.CustomizeDependencies += this.GeneratorPluginEventsOnCustomizeDependencies;
}
private void GeneratorPluginEventsOnCustomizeDependencies(object sender, CustomizeDependenciesEventArgs customizeDependenciesEventArgs)
{
string unitTestProviderName =
customizeDependenciesEventArgs.SpecFlowProjectConfiguration.SpecFlowConfiguration.UnitTestProvider;
if (unitTestProviderName.Equals("mstest", StringComparison.InvariantCultureIgnoreCase)
|| unitTestProviderName.Equals("mstest.2010", StringComparison.InvariantCultureIgnoreCase))
{
customizeDependenciesEventArgs.ObjectContainer.RegisterTypeAs<CodedUIGeneratorProvider, IUnitTestGeneratorProvider>();
}
}
#region IGeneratorPlugin Members
public void RegisterConfigurationDefaults(TechTalk.SpecFlow.Generator.Configuration.SpecFlowProjectConfiguration specFlowConfiguration) { }
public void RegisterCustomizations(BoDi.ObjectContainer container, TechTalk.SpecFlow.Generator.Configuration.SpecFlowProjectConfiguration generatorConfiguration)
{
container.RegisterTypeAs<CodedUIGeneratorProvider, IUnitTestGeneratorProvider>();
container.RegisterTypeAs<MsTest2010RuntimeProvider, IUnitTestRuntimeProvider>();
}
public void RegisterDependencies(BoDi.ObjectContainer container) { }
#endregion
}
}
這裏是我的發電機提供的代碼,位於一個單獨的cs文件:
namespace SpecflowCUITPluginLib
{
public class CodedUIGeneratorProvider : MsTest2010GeneratorProvider
{
public CodedUIGeneratorProvider(CodeDomHelper codeDomHelper)
: base(codeDomHelper) { }
private const string TestClassAttribute = @"Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
private const string CodedUiTestClassAttribute = @"Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute";
private const string DeploymentItemAttribute = "Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute";
public override void SetTestClass(TestClassGenerationContext generationContext, string featureTitle, string featureDescription)
{
base.SetTestClass(generationContext, featureTitle, featureDescription);
foreach (CodeAttributeDeclaration declaration in generationContext.TestClass.CustomAttributes)
{
if (declaration.Name == TestClassAttribute)
{
generationContext.TestClass.CustomAttributes.Remove(declaration);
break;
}
}
generationContext.TestClass.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(CodedUiTestClassAttribute)));
string filename = new Uri(this.GetType().Assembly.CodeBase).LocalPath;
// Add deployment item in each test for the driver.
generationContext.TestClass.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(DeploymentItemAttribute),
new CodeAttributeArgument(new CodePrimitiveExpression("SpecflowCUITPluginLib.SpecFlowPlugin.dll"))));
}
}
}
這裏是我添加到裝配文件的行:
[assembly: GeneratorPlugin(typeof(CodedUiPlugin))]
Here is a screencap of my build settings for the plugin project
這裏是我的app.config從我CodedUI項目
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<unitTestProvider name="MsTest" />
<plugins>
<add name="SpecflowCUITPluginLib.SpecflowPlugin" path=".\MedchartUITesting\packages\specflow2.2.0\tools" type="Generator" />
</plugins>
</specFlow>
</configuration>
而且不管我做什麼,我得到這個錯誤我的特點文件:#error Generation error: Unable to find plugin in the plugin search path: SpecflowCUITPluginLib.SpecflowPlugin. Please check http://go.specflow.org/doc-plugins for details.
任何人看到的溶液或這是一個問題,因爲在這個時候我真的不知道我應該在哪裏尋找解決方案。