baseclass / Contrib.SpecFlow.Selenium.NUnit

Test class generator to drive automated web ui tests with Selenium and SpecFlow
http://www.nuget.org/packages/Baseclass.Contrib.SpecFlow.Selenium.NUnit/
22 stars 13 forks source link

Allows scenario annotation with key:value syntax #6

Open bbaumann opened 9 years ago

bbaumann commented 9 years ago

Hi!

I've extended the @browser tag principle to match any @key:value tags. I needed it for a multi-language site (needed to test all the sites but the language did not impact the test logic). I've let the IoC for the browser tag but any other @key:value tag is stored in the scenario Context as is.

Updated test cases are provided with the update.

We use it since July and everything's fine in our company. If you think that it could be useful to other people, feel free to merge it.

Regards, Benjamin

romerod commented 9 years ago

Is it that generic, what about the InitializeSeleneniumAndLanguage method?

bbaumann commented 9 years ago

The InitializeSeleneniumAndLanguage method is in the CalculatorFeature.feature.cs file which is generated by the plugin. The name of the method depends on the key part of the @key:value syntax. The code generating these method can be found in SeleniumNUnitTestGeneratorProvider.cs line 117 :

string methodName = "InitializeSelenium"+String.Join("",orderedTags);
string initializeSeleniumArgs = String.Join(",",orderedTags).ToLowerInvariant();
//Create the call to the initialization Method
testMethod.Statements.Insert(0, new CodeSnippetStatement(methodName+"(" + initializeSeleniumArgs + ");"));

So yes it is generic ^^ If you prefer I may adapt my test case so that it uses an abstract concept for the @key:value instead of @Language:FR one.