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

Add option to include contextual information in code fragments #39

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

just95
Copy link

@just95 just95 commented Aug 15, 2022

When a scenario is imported to Testomatio, the corresponding source code from the *.feature file is also uploaded. However, seeing just the scenarios code might not be sufficient or even misleading. Most importantly, there is currently no way to see the steps of a Background section on Testomatio.

This PR adds CLI flags to include the source code of relevant Background sections as well as the names, descriptions and tags of parent features and rules.

$> npx check-cucumber --help
  ...
  --include-features           Add description of feature to scenario code
  --include-rules              Add description of parent rule sections to scenario code
  --include-backgrounds        Add description and steps of relevant background sections to scenario code

For example, when all three CLI flags are set, the tool will now extract the following code fragment for "Scenario 2.2" from example/features/rules.feature:

Feature: A feature with multiple rules
  Description of the feature

  Background:
    Given all rules have something

  Rule: Rule 2
    Description of second rule

    Background:
      Given the second rule has something

    Scenario: Scenario 2.2
      Description of second scenario

      Given I have something
      When I do something
      Then something happens

This PR depends on the support for rules added in #38. The getLocations function added in #38 is also reused to extract the correct source code fragments for features, rules and backgrounds. The main change is the implementation of a new handler for the Background keyword in getSourceCode and the addition of a context variable to keep track of the source code of rules and backgrounds.

just95 added 7 commits August 8, 2022 14:31
Currently the code in Testomatio only shows the scenario's source code.
However, the descriptions of parent features and rules as well as
the steps of background sections may also be relevant to the tester.
Thus, this PR adds command line options to include the source code
of these elemnts in the exported scenatios.
In `getLocations` the child message is destructured already.
Since there is no invocation of `getLocation` on a child node,
the second destructuring is not needed.
A `Rule` cannot be the child of another rule. Thus, the check if
we are `inRule` is not needed. If nested rules were allowed in the
future, more than a single space of indentation would be needed
anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant