From 20461dc10709bc69b450a02be67ac9e16280279f Mon Sep 17 00:00:00 2001 From: jbandi Date: Thu, 11 Feb 2010 22:18:59 +0100 Subject: [PATCH] Using steps defined in other assemblies. Enable writing steps in VB. Cleaning up ContextInjection --- .../ConfigurationSectionHandler.cs | 31 +++++ Runtime/Configuration/RuntimeConfiguration.cs | 20 +++ Runtime/ObjectContainer.cs | 7 +- TechTalk.SpecFlow.sln | 14 +++ Tests/FeatureTests/App.config | 30 +++++ .../ContextInjection.feature.cs | 81 +++++++----- .../ExternalSteps/ExternalSteps.feature | 9 ++ .../ExternalSteps/ExternalSteps.feature.cs | 71 +++++++++++ .../ExternalSteps/ExternalStepsCS/CSSteps.cs | 19 +++ .../ExternalStepsCS/ExternalStepsCS.csproj | 69 +++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++ .../ExternalStepsVB/ExternalStepsVB.vbproj | 113 +++++++++++++++++ .../My Project/Application.Designer.vb | 13 ++ .../My Project/Application.myapp | 10 ++ .../My Project/AssemblyInfo.vb | 35 ++++++ .../My Project/Resources.Designer.vb | 62 ++++++++++ .../ExternalStepsVB/My Project/Resources.resx | 117 ++++++++++++++++++ .../My Project/Settings.Designer.vb | 73 +++++++++++ .../My Project/Settings.settings | 7 ++ .../ExternalSteps/ExternalStepsVB/VBSteps.vb | 16 +++ Tests/FeatureTests/FeatureTests.csproj | 23 +++- Tests/RuntimeTests/App.config | 4 +- changelog.txt | 5 + 23 files changed, 827 insertions(+), 38 deletions(-) create mode 100644 Tests/FeatureTests/App.config create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalSteps.feature create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalSteps.feature.cs create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsCS/CSSteps.cs create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsCS/ExternalStepsCS.csproj create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsCS/Properties/AssemblyInfo.cs create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/ExternalStepsVB.vbproj create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.Designer.vb create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.myapp create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/AssemblyInfo.vb create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.Designer.vb create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.resx create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.Designer.vb create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.settings create mode 100644 Tests/FeatureTests/ExternalSteps/ExternalStepsVB/VBSteps.vb diff --git a/Runtime/Configuration/ConfigurationSectionHandler.cs b/Runtime/Configuration/ConfigurationSectionHandler.cs index dbd3b3e00..00fabc369 100644 --- a/Runtime/Configuration/ConfigurationSectionHandler.cs +++ b/Runtime/Configuration/ConfigurationSectionHandler.cs @@ -94,6 +94,14 @@ public TraceConfigElement Trace set { this["trace"] = value; } } + [ConfigurationProperty("stepAssemblies", IsDefaultCollection = false, IsRequired = false)] + [ConfigurationCollection(typeof(StepAssemblyCollection), AddItemName = "stepAssembly")] + public StepAssemblyCollection StepAssemblies + { + get { return (StepAssemblyCollection)this["stepAssemblies"]; } + set { this["stepAssemblies"] = value; } + } + static internal ConfigurationSectionHandler CreateFromXml(string xmlContent) { ConfigurationSectionHandler section = new ConfigurationSectionHandler(); @@ -229,4 +237,27 @@ public string Listener set { this["listener"] = value; } } } + + public class StepAssemblyCollection : ConfigurationElementCollection + { + protected override ConfigurationElement CreateNewElement() + { + return new StepAssemblyConfigElement(); + } + + protected override object GetElementKey(ConfigurationElement element) + { + return ((StepAssemblyConfigElement) element).File; + } + } + + public class StepAssemblyConfigElement : ConfigurationElement + { + [ConfigurationProperty("file", DefaultValue = null, IsRequired = false)] + public string File + { + get { return (string)this["file"]; } + set { this["file"] = value; } + } + } } diff --git a/Runtime/Configuration/RuntimeConfiguration.cs b/Runtime/Configuration/RuntimeConfiguration.cs index add2e289f..7eb6293e6 100644 --- a/Runtime/Configuration/RuntimeConfiguration.cs +++ b/Runtime/Configuration/RuntimeConfiguration.cs @@ -1,8 +1,11 @@ using System; +using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.Globalization; +using System.IO; using System.Linq; +using System.Reflection; using TechTalk.SpecFlow.Tracing; using TechTalk.SpecFlow.UnitTestProvider; @@ -15,6 +18,8 @@ public partial class ConfigurationSectionHandler internal class RuntimeConfiguration { + private List _additionalStepAssemblies = new List(); + static public RuntimeConfiguration Current { get { return ObjectContainer.Configuration; } @@ -37,6 +42,13 @@ static public RuntimeConfiguration Current public bool TraceTimings { get; set; } public TimeSpan MinTracedDuration { get; set; } + public IEnumerable AdditionalStepAssemblies + { + get { + return _additionalStepAssemblies; + } + } + public RuntimeConfiguration() { ToolLanguage = string.IsNullOrEmpty(ConfigDefaults.ToolLanguage) ? @@ -103,6 +115,14 @@ public static RuntimeConfiguration LoadFromConfigFile(ConfigurationSectionHandle config.MinTracedDuration = configSection.Trace.MinTracedDuration; } + foreach(var element in configSection.StepAssemblies) + { + string stepAssemblyFileName = ((StepAssemblyConfigElement)element).File; + string fullPath = Path.GetFullPath(stepAssemblyFileName); + Assembly stepAssembly = Assembly.LoadFile(fullPath); + config._additionalStepAssemblies.Add(stepAssembly); + } + return config; } diff --git a/Runtime/ObjectContainer.cs b/Runtime/ObjectContainer.cs index 0a01ee14c..34f8eff82 100644 --- a/Runtime/ObjectContainer.cs +++ b/Runtime/ObjectContainer.cs @@ -1,4 +1,5 @@ using System; +using System.CodeDom.Compiler; using System.Collections.Generic; using System.Configuration; using System.Reflection; @@ -6,6 +7,7 @@ using TechTalk.SpecFlow.ErrorHandling; using TechTalk.SpecFlow.Tracing; using TechTalk.SpecFlow.UnitTestProvider; +using System.Linq; namespace TechTalk.SpecFlow { @@ -53,7 +55,10 @@ internal static ITestRunner EnsureTestRunner(Assembly callingAssembly) var result = new TestRunner(); List bindingAssemblies = new List(); - bindingAssemblies.Add(callingAssembly); //TODO: add more assemblies from config + bindingAssemblies.Add(callingAssembly); + + bindingAssemblies.AddRange(configuration.AdditionalStepAssemblies); + result.InitializeTestRunner(bindingAssemblies.ToArray()); return result; diff --git a/TechTalk.SpecFlow.sln b/TechTalk.SpecFlow.sln index 3c3baa592..f8a03a367 100644 --- a/TechTalk.SpecFlow.sln +++ b/TechTalk.SpecFlow.sln @@ -38,6 +38,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechTalk.SpecFlow.Tools", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatureTests", "Tests\FeatureTests\FeatureTests.csproj", "{3FE793A8-E662-4026-B4EC-891324073235}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ExternalStepsVB", "Tests\FeatureTests\ExternalSteps\ExternalStepsVB\ExternalStepsVB.vbproj", "{D3F6B835-B228-4DCF-B533-B6ED469A33B3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalStepsCS", "Tests\FeatureTests\ExternalSteps\ExternalStepsCS\ExternalStepsCS.csproj", "{3836A6FC-4ECC-413A-AC8F-83A0A773EC9E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -87,6 +91,14 @@ Global {3FE793A8-E662-4026-B4EC-891324073235}.Debug|Any CPU.Build.0 = Debug|Any CPU {3FE793A8-E662-4026-B4EC-891324073235}.Release|Any CPU.ActiveCfg = Release|Any CPU {3FE793A8-E662-4026-B4EC-891324073235}.Release|Any CPU.Build.0 = Release|Any CPU + {D3F6B835-B228-4DCF-B533-B6ED469A33B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3F6B835-B228-4DCF-B533-B6ED469A33B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3F6B835-B228-4DCF-B533-B6ED469A33B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3F6B835-B228-4DCF-B533-B6ED469A33B3}.Release|Any CPU.Build.0 = Release|Any CPU + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,5 +109,7 @@ Global {70376361-0BE1-478D-8EEC-47BD1C768165} = {A10B5CD6-38EC-4D7E-9D1C-2EBA8017E437} {F8FACCF0-5497-4C6B-861F-78D72FD9561B} = {A10B5CD6-38EC-4D7E-9D1C-2EBA8017E437} {3FE793A8-E662-4026-B4EC-891324073235} = {A10B5CD6-38EC-4D7E-9D1C-2EBA8017E437} + {D3F6B835-B228-4DCF-B533-B6ED469A33B3} = {A10B5CD6-38EC-4D7E-9D1C-2EBA8017E437} + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E} = {A10B5CD6-38EC-4D7E-9D1C-2EBA8017E437} EndGlobalSection EndGlobal diff --git a/Tests/FeatureTests/App.config b/Tests/FeatureTests/App.config new file mode 100644 index 000000000..fe47acad7 --- /dev/null +++ b/Tests/FeatureTests/App.config @@ -0,0 +1,30 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/FeatureTests/ContextInjection/ContextInjection.feature.cs b/Tests/FeatureTests/ContextInjection/ContextInjection.feature.cs index 2856da539..f1f52ec1f 100644 --- a/Tests/FeatureTests/ContextInjection/ContextInjection.feature.cs +++ b/Tests/FeatureTests/ContextInjection/ContextInjection.feature.cs @@ -1,14 +1,14 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.21006.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace FeatureTests.ContextInjection +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.2.0.0 +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace TechTalk.SpecFlow.FeatureTests.ContextInjection { using TechTalk.SpecFlow; @@ -20,6 +20,9 @@ public partial class InjectingContextIntoStepSpecificationsFeature private static TechTalk.SpecFlow.ITestRunner testRunner; +#line 1 "ContextInjection.feature" +#line hidden + [NUnit.Framework.TestFixtureSetUpAttribute()] public virtual void FeatureSetup() { @@ -54,9 +57,13 @@ public virtual void ScenarioTearDown() public virtual void FeatureWithNoContext() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Feature with no context", ((string[])(null))); - this.ScenarioSetup(scenarioInfo); - testRunner.Given("a feature which requires no context"); - testRunner.Then("everything is dandy"); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 7 + testRunner.Given("a feature which requires no context"); +#line 8 + testRunner.Then("everything is dandy"); +#line hidden testRunner.CollectScenarioErrors(); } @@ -65,9 +72,13 @@ public virtual void FeatureWithNoContext() public virtual void FeatureWithASingleContext() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Feature with a single context", ((string[])(null))); - this.ScenarioSetup(scenarioInfo); - testRunner.Given("a feature which requires a single context"); - testRunner.Then("the context is set"); +#line 10 +this.ScenarioSetup(scenarioInfo); +#line 11 + testRunner.Given("a feature which requires a single context"); +#line 12 + testRunner.Then("the context is set"); +#line hidden testRunner.CollectScenarioErrors(); } @@ -76,9 +87,13 @@ public virtual void FeatureWithASingleContext() public virtual void FeatureWithMultipleContexts() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Feature with multiple contexts", ((string[])(null))); - this.ScenarioSetup(scenarioInfo); - testRunner.Given("a feature which requires multiple contexts"); - testRunner.Then("the contexts are set"); +#line 14 +this.ScenarioSetup(scenarioInfo); +#line 15 + testRunner.Given("a feature which requires multiple contexts"); +#line 16 + testRunner.Then("the contexts are set"); +#line hidden testRunner.CollectScenarioErrors(); } @@ -87,10 +102,15 @@ public virtual void FeatureWithMultipleContexts() public virtual void FeatureWithRecursiveContexts() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Feature with recursive contexts", ((string[])(null))); - this.ScenarioSetup(scenarioInfo); - testRunner.Given("a feature which requires a recursive context"); - testRunner.Then("the context is set"); - testRunner.And("its sub-context is set"); +#line 18 +this.ScenarioSetup(scenarioInfo); +#line 19 + testRunner.Given("a feature which requires a recursive context"); +#line 20 + testRunner.Then("the context is set"); +#line 21 + testRunner.And("its sub-context is set"); +#line hidden testRunner.CollectScenarioErrors(); } @@ -99,10 +119,15 @@ public virtual void FeatureWithRecursiveContexts() public virtual void FeatureWithADependentContext() { TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Feature with a dependent context", ((string[])(null))); - this.ScenarioSetup(scenarioInfo); - testRunner.Given("a feature which requires a single context"); - testRunner.Then("the context is set"); - testRunner.And("the context was created by the feature with a single context scenario"); +#line 23 +this.ScenarioSetup(scenarioInfo); +#line 24 + testRunner.Given("a feature which requires a single context"); +#line 25 + testRunner.Then("the context is set"); +#line 26 + testRunner.And("the context was created by the feature with a single context scenario"); +#line hidden testRunner.CollectScenarioErrors(); } } diff --git a/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature b/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature new file mode 100644 index 000000000..f78ac1c99 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature @@ -0,0 +1,9 @@ +Feature: External Step Definitions + In order to modularize my solution + As a bdd enthusiast + I want to use step definitions from other assemblies + +Scenario: Steps defined in an external VB project and an external c-sharp project + Given I have external step definitions in a separate assembly referenced by this project + When I call those steps + Then the scenario should pass diff --git a/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature.cs b/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature.cs new file mode 100644 index 000000000..8389bf338 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalSteps.feature.cs @@ -0,0 +1,71 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.2.0.0 +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +namespace TechTalk.SpecFlow.FeatureTests.ExternalSteps +{ + using TechTalk.SpecFlow; + + + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("External Step Definitions")] + public partial class ExternalStepDefinitionsFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "ExternalSteps.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en"), "External Step Definitions", "In order to modularize my solution\r\nAs a bdd enthusiast\r\nI want to use step defin" + + "itions from other assemblies", ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Steps defined in an external VB project and an external c-sharp project")] + public virtual void StepsDefinedInAnExternalVBProjectAndAnExternalC_SharpProject() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Steps defined in an external VB project and an external c-sharp project", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 7 + testRunner.Given("I have external step definitions in a separate assembly referenced by this projec" + + "t"); +#line 8 + testRunner.When("I call those steps"); +#line 9 + testRunner.Then("the scenario should pass"); +#line hidden + testRunner.CollectScenarioErrors(); + } + } +} diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/CSSteps.cs b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/CSSteps.cs new file mode 100644 index 000000000..2ac2bf7af --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/CSSteps.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using TechTalk.SpecFlow; + +namespace ExternalStepsCS +{ + [Binding] + public class CSSteps + { + [Then("the scenario should pass")] + public void GivenAFeatureWhichRequiresADependentContext() + { + Assert.AreEqual(2,(int)ScenarioContext.Current["counter"]); + } + } +} diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/ExternalStepsCS.csproj b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/ExternalStepsCS.csproj new file mode 100644 index 000000000..cdde99650 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/ExternalStepsCS.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {3836A6FC-4ECC-413A-AC8F-83A0A773EC9E} + Library + Properties + ExternalStepsCS + ExternalStepsCS + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\lib\nunit\nunit.framework.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + {413EE28C-4F89-4C6F-BA1E-2CDEE4CD43B4} + TechTalk.SpecFlow + + + + + \ No newline at end of file diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/Properties/AssemblyInfo.cs b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..09c0f86a2 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsCS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ExternalStepsCS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("ExternalStepsCS")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e3199977-e6e2-4c14-97da-4376e105c1e3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/ExternalStepsVB.vbproj b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/ExternalStepsVB.vbproj new file mode 100644 index 000000000..3b4b0fd39 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/ExternalStepsVB.vbproj @@ -0,0 +1,113 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {D3F6B835-B228-4DCF-B533-B6ED469A33B3} + Library + ExternalStepsVB + ExternalStepsVB + 512 + Windows + v3.5 + On + Binary + Off + On + + + true + full + true + true + bin\Debug\ + ExternalStepsVB.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + ExternalStepsVB.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + {413EE28C-4F89-4C6F-BA1E-2CDEE4CD43B4} + TechTalk.SpecFlow + + + + + \ No newline at end of file diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.Designer.vb b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.Designer.vb new file mode 100644 index 000000000..d4e7c6707 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.4927 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.myapp b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.myapp new file mode 100644 index 000000000..758895def --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/AssemblyInfo.vb b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/AssemblyInfo.vb new file mode 100644 index 000000000..c2414cd00 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.Designer.vb b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.Designer.vb new file mode 100644 index 000000000..80f727dc5 --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.4927 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ' + ' A strongly-typed resource class, for looking up localized strings, etc. + ' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ' + ' Returns the cached ResourceManager instance used by this class. + ' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ExternalStepsVB.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ' + ' Overrides the current thread's CurrentUICulture property for all + ' resource lookups using this strongly typed resource class. + ' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.resx b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.Designer.vb b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.Designer.vb new file mode 100644 index 000000000..ac249979b --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:2.0.50727.4927 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.ExternalStepsVB.My.MySettings + Get + Return Global.ExternalStepsVB.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.settings b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.settings new file mode 100644 index 000000000..85b890b3c --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/VBSteps.vb b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/VBSteps.vb new file mode 100644 index 000000000..299f1ac5d --- /dev/null +++ b/Tests/FeatureTests/ExternalSteps/ExternalStepsVB/VBSteps.vb @@ -0,0 +1,16 @@ +Imports TechTalk.SpecFlow + + _ +Public Class VBStepDefinitions + + _ + Public Function step1() + ScenarioContext.Current.Item("counter") = 1 + End Function + + <[When]("I call those steps")> _ + Public Function step2() + ScenarioContext.Current.Item("counter") += 1 + End Function + +End Class diff --git a/Tests/FeatureTests/FeatureTests.csproj b/Tests/FeatureTests/FeatureTests.csproj index 120a43809..5fa3e6187 100644 --- a/Tests/FeatureTests/FeatureTests.csproj +++ b/Tests/FeatureTests/FeatureTests.csproj @@ -8,10 +8,13 @@ {3FE793A8-E662-4026-B4EC-891324073235} Library Properties - FeatureTests - FeatureTests - v4.0 + TechTalk.SpecFlow.FeatureTests + TechTalk.SpecFlow.FeatureTests + v3.5 512 + true + + true @@ -39,7 +42,9 @@ ..\..\lib\mocking\Rhino.Mocks.dll - + + 3.5 + @@ -58,6 +63,11 @@ + + True + True + ExternalSteps.feature + @@ -72,13 +82,14 @@ + SpecFlowSingleFileGenerator ContextInjection.feature.cs - + SpecFlowSingleFileGenerator - ListArguments.feature.cs + ExternalSteps.feature.cs diff --git a/Tests/RuntimeTests/App.config b/Tests/RuntimeTests/App.config index 033c8c29a..695fd07a1 100644 --- a/Tests/RuntimeTests/App.config +++ b/Tests/RuntimeTests/App.config @@ -7,9 +7,7 @@ - + diff --git a/changelog.txt b/changelog.txt index 4f63de970..7ac47f5c2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ +next release +New features: ++ Context injection in step definitions. Step definitions can get a context injected with constructor injection. See examples in Tests/FeatureTests/ContextInjection. ++ Using steps in other assemblies. This enables writing steps in VB. See examples in Tests/FeatureTests/ExternalSteps. + 1.2.0 - 2009/11/25 New features: