Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steps are marked Unresolved step when the feature file has an explicit language specified with the #language: comment #27

Closed
nemesv opened this issue Mar 1, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@nemesv
Copy link
Contributor

nemesv commented Mar 1, 2021

Example feature file

#language: de
Funktionalität: Calculator

@mytag
Szenario: Add two numbers
	Angenommen the first number is 15
	Und the second number is 70
	Wenn the two numbers are added
	Dann the result should be 120

Bindings:

  [Given(@"the first number is (\d+)")]
  public void GivenTheFirstNumberIs(int number)
  {
  }

  [Given("the second number is (.*)")]
  public void GivenTheSecondNumberIs(int number)
  {
  }

  [When("the two numbers are added")]
  public void WhenTheTwoNumbersAreAdded()
  {
  }

  [Then("the result should be (.*)")]
  public void ThenTheResultShouldBe(int result)
  {
  }

All the steps are marked as Unresolved but from SpecFlow point of view everything is working and the Scenario is green:

image

@nemesv nemesv added the bug Something isn't working label Mar 1, 2021
@nemesv
Copy link
Contributor Author

nemesv commented Mar 1, 2021

This is won't be an easy fix:

  • currently we use the project language (specified in the specflow.json) to translate the keywords in the GetStepKind but we would need the "effective" language of the feature file
  • the GherkinLexer knows what is the actual language because it is handling the #language: magic comment but this information cannot be exposed easily from the lexer
  • the GherkinParser should be the place to get feature file language and and store this information somewhere in the AST (or it can already lookup the StepKind and store it on the GherkinStep element)

@Socolin
Copy link
Collaborator

Socolin commented Mar 1, 2021

  • currently we use the project language (specified in the specflow.json) to translate the keywords in the GetStepKind but we would need the "effective" language of the feature file
  • We can check the comment at the top of the file while building SpecflowStepsUsagesCache. Then there is a refactor that need to be done anyway to stop depending on GetStepKind when building this cache since it's not optimized at all (few lines of of code run multiple time for nothing)
  • Then we can use this new cache in GetStepKind() to retrieve the lang.

Also it may be worth checking if we can cache the StepKind inside the GherkinStep (nullable field fill while building SpecflowStepsUsagesCache). I don't know if this can lead to some future bug, maybe ask this on the jetbrains channel

Since it's already highlighting the file as expected I don't know if there is need to change GherkinLexer / GherkinParser

@Socolin
Copy link
Collaborator

Socolin commented Mar 2, 2021

After checking it seems that a new GherkinFile is created each time (I tough is was cached but I was confused with IPsiSourceFile, so we could set the language at the creation as you suggest in the GherkinParser in ParseFile()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants