SpecFlow.VisualStudio
SpecFlow.VisualStudio copied to clipboard
Problem with Specflow 2.0 and 2.1 and French language. Binding generation error
Since version 2, we have mismatch between attribute and generated feature codebehind using french language. Version 1.9 was working fine.
No matching step definition found for the step. Use the following code to create one: [Given(@"je suis authentifié avec l'utilisateur ""(.)"" et le rôle ""(.)"" et que je possède plusieurs rôles")]
Config : ...
<specFlow>
<language feature="fr-CA" />
<bindingCulture name="fr-CA" />
<generator generateAsyncTests="true" />
<unitTestProvider name="NUnit" />
</specFlow>
....
StepFile.cs
We can see that the attribute binding start with the word que
[Given(@"que je suis authentifié avec l'utilisateur ""(.*)"" et le rôle ""(.*)"" et que je possède plusieurs rôles")]
public void SoitQueJeSuisAuthentifieAvecLUtilisateurEtLeRoleEtQueJePossedePlusieursRoles(string username, string roleName)
{
var roleServiceType = _sharedSteps.GuessServiceTypeFromRoleName(roleName);
CreateUserAndAssociateToRole(username, roleName, roleServiceType);
AssociateMultiRoles(username, roleServiceType);
StartTest(username, roleName);
}
Feature code behind :
We can see that the generated code does not start with the word que. Therefore we get a No matching step definition at runtime
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:2.1.0.0
// SpecFlow Generator Version:2.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
#pragma warning disable
namespace Emergensys.Cad.Specs.Features.Authentification
{
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.1.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Effectuer le login d\'un utilisateur")]
[NUnit.Framework.CategoryAttribute("Authentification")]
public partial class EffectuerLeLoginDUnUtilisateurFeature
{
private TechTalk.SpecFlow.ITestRunner testRunner;
#line 1 "Login.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("fr-CA"), "Effectuer le login d\'un utilisateur", null, ProgrammingLanguage.CSharp, new string[] {
"Authentification"});
testRunner.OnFeatureStart(featureInfo);
}
....
#line 16
testRunner.Given("je suis authentifié avec l\'utilisateur \"BDD01\" et le rôle \"BDD - ADMIN PRINC (POL" +
"ICE)\" et que je possède plusieurs rôles", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Étant donné que ");
.....
Regards
Gaetan
@ggingras Could you reformat the text, that all code is displayed as code? It is really hard to read and understand what is code and what are your comments.
Thank you!
I updated my first post. Thanks
The problem here is, that the Visual Studio Extension and the runtime are currently using different parsers. The runtime has as And- Keywords "Et que", "Et qu'" and "Et" where the Visual Studio Extension has only "Et".
We startet to work on an Visual Studio Integration, that also uses the new parser, but this will probably take still some time to get finished.
Could this issue be prioritized? I have installed SpecFlow for VS 2015 version 2017.1.6 and this bug is still there… I cannot recommend SpecFlow 2.0 to my current client because of this.
Regards,
Karl
Sorry to hear that, but we are only a small team of contributors with a limited amount of spare time available.
From the current description I am not sure what is the expected behavior? Is the method skeleton generated wrong? Is the generated code wrong? Is the VS Integration showing something wrong, but the tests are executed without problems.
It is exactly as described by @ggingras in this issue. When we are using these particular words in a French feature file, Que and Qu', SpecFlow seems to forget them in the generated code and the steps are not correctly binded. The tests results are "No matching step definition found for one or more steps".
If I remove the words that provoke this problem, everything is fine.
I can also tell you that it is the Specflow for Visual Studio 2015 that cause this problem. With the old extension (SpecFlow 1.9) on a VS2012, I don't have this problem even with SpecFlow 2.
Not yet corrected 1 year after ?
@Reefact No. We are not more contributers than in 2017 and currently our whole effort is going into the .NET Core support for SpecFlow.
The best way to get bugs that annoy you fixed in SpecFlow is to fix them :) It's how open source works.