Open RobIngleby opened 5 years ago
I think what you are writing here is how it is supposed to work, that is that they do not support using keywords in any other language than English. At least all examples I have seen have used english keywords with native regexes or method names. If it is supposed to work with native keywords, it would be nice if the examples could be updated
@RobIngleby Could you please post the complete bindings that are generated?
Attached below example of a simple feature file, and the binding generated.- in any case ref. metarevens comment have I completely misunderstood this - that generating the steps files with English keywords is intended functionality?
FEATURE FILE
Egenskab: OpenIndreLinksFraNavBar
Til bruge webstedet
Som bruger
Jeg ville åbner indre links
Baggrund:
Givet Jeg er på hjemmesiden
@IndreUndersiderTests
Abstrakt Scenario: Åben indre undersider
Når jeg klik en '<IndreLink>'
Så skal den rigtigt side åbnes i den sammen tab
Eksempler:
|IndreLink|
|Client Testimonials |
|About me |
|Services |
|Find and contact me |
STEPS FILE
using System;
using TechTalk.SpecFlow;
namespace LiveTests
{
[Binding]
public class OpenIndreLinksFraNavBarSteps
{
[When(@"jeg klik en '(.*)'")]
public void NarJegKlikEn(string p0)
{
// ScenarioContext.Current.Pending();
}
[Then(@"skal den rigtigt side åbnes i den sammen tab")]
public void SaSkalDenRigtigtSideAbnesIDenSammenTab()
{
// ScenarioContext.Current.Pending();
}
}
}
@RobIngleby
Thanks for the example. And I tried to reproduce it, but I still don't understand what you mean. The only english keywords I see are the Given, When and Then attributes on the methods. Do you mean these?
@metareven Yes, nearly all of the examples are in english. We have one example where we show how to use another language (German in this case). It is here: https://github.com/techtalk/SpecFlow-Examples/tree/master/BowlingKata/BowlingKata-German
@SabotageAndi Yes, but I think that in this issue, the problem is that the keywords Given, When and Then are not in Danish. It would be nice if these could be in the language that is specified in the feature files instead of defaulting to english. In the documentation, even the non-english examples end up with these keywords in english.
@metareven So you would like to have the attributes in your language?
Apologies for delay in reply - been unwell. It was indeed that I thought intended functionality was that the keywords in the steps file attributes should be in the same language as the keywords in the feature files. If this is not current intended functionality it would be a very good future enhancement.
Ok, now I understand the question.
The current behaviour is the intended one. There are only the attributes GivenAttribute
, WhenAttribute
and ThenAttribute
in SpecFlow.
Too be honest, until now I never thought of having this attributes also in another language than english.
I think it would be possible to do, but it will be a lot of work. Here are the things I currently have in mind too pull this off:
The first point is the easy one. ;-)
@gasparnagy What do you say to this feature request?
I have also got this request from others. I think we can do this step-by-step. First I would just change the BindingSourceProcessor
(https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/Bindings/Discovery/BindingSourceProcessor.cs#L75) to use assignable-to instead of equals. With this the users could at least define their own derived attributes from Given/When/Then and use it in the code.
Once this is working, we can figure out how the attributes (for the most common languages at least) could be supported (maybe a separate NuGet package).
@gasparnagy Sounds like a plan.
So if someone from the community want to contribute this feature, I am happy to help them.
May I request an update? What is left to do here now? I see that the mentioned changes to discovery were made, is there anything left to do in terms of code generation?
Everything else is missing. So the translated attributes and then an adjusted code generation.
SpecFlow Version:
Used Test Runner
Version number:3.0.225
Project Format of the SpecFlow project
packages.config
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation
NuGet packageSpecFlowSingleFileGenerator
custom toolVisual Studio Version
Enable SpecFlowSingleFileGenerator Custom Tool
option in Visual Studio extension settingsAre the latest Visual Studio updates installed?
<Major>.<Minor>.<Patch>
.NET Framework:
Test Execution Method:
<SpecFlow> Section in app.config or content of specflow.json
Repro Project
Issue Description
Working on a project where I wish to write feature files in Danish, am able to do so by changing specflow.json as above. On generating step definitions from these feature files, they are in English and the feature files will not recognise that step definitions have been generated.
Steps to Reproduce
Create new project NUnit Test Project(.NET Core)
Add NuGet packages: NUnit, NUnit3TestAdapter, SpecFlow, SpecFlow NUnit, SpecFlowNUnit.Runnerer, SpecFlow.Tools.MsBuild,Generation
Change specflow.json as above. In feature files now have access to Danish keywords - e.g. Givet instead of Given
4.. From feature files, choose "Generate Step Definitions" Definition files that are generated use English keywords - i.e. Given not givet, and the feature files will not recognise that step definitions have been generated - all step in the feature file are still in purple.