Okay. So here is where I am at. I am using Specflow 2.2.0 to pair automated unit testing with our CodedUI testing effort. I am developing a plugin to add the CodedUI Test attribute to the Specflow Feature tests and I am running into some problems. Specflow is not recognizing my plugin to generate the CodedUI Test Attribute to Specflow feature files and I don't understand why because I have followed every instruction in the documentation as well as looked at other plugins on GitHub to make sure I am doing it right.

I have the plugin in its own class library project and upon build its dll autocopies to the packages folder in the Solution where Specflow is located. I have the assembly files edited to point to the generator. I have the initializers for the eventhandler. I have everything in the app.config of my CodedUI project correct as far as I can tell and I still get errors. Here is everything I have in regards to the plugin and the other relevant pieces:

Here is the code from my plugin that initializes the IGenerator Class:

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 =
            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) { }

Here is the code from my Generator Provider that is located in a separate .cs  file:

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.Add(new CodeAttributeDeclaration(new CodeTypeReference(CodedUiTestClassAttribute)));
            string filename = new Uri(this.GetType().Assembly.CodeBase).LocalPath;
            // Add deployment item in each test for the driver.
                new CodeAttributeDeclaration(
                    new CodeTypeReference(DeploymentItemAttribute),
                    new CodeAttributeArgument(new CodePrimitiveExpression("SpecflowCUITPluginLib.SpecFlowPlugin.dll"))));

Here is the line I added to the assembly file:

[assembly: GeneratorPlugin(typeof(CodedUiPlugin))]

Here is a screencap of my build settings for the plugin project

And here is my app.config from my CodedUI Project

<?xml version="1.0" encoding="utf-8"?>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
    <unitTestProvider name="MsTest" />
      <add name="SpecflowCUITPluginLib.SpecflowPlugin" path=".\MedchartUITesting\packages\specflow2.2.0\tools" type="Generator" />

And no matter what I do I get this error for my feature files: #error Generation error: Unable to find a plugin in the plugin search path: SpecflowCUITPluginLib.SpecflowPlugin. Please check http://go.specflow.org/doc-plugins for details.

Anyone see a solution or a problem because at this moment I am really at a loss as to where I should be looking for a solution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.