Giter Site home page Giter Site logo

cucumber-rs / gherkin Goto Github PK

View Code? Open in Web Editor NEW
66.0 5.0 19.0 294 KB

Pure Rust implementation of Gherkin language (`.feature` file) for Cucumber testing framework.

License: Apache License 2.0

Rust 95.84% Gherkin 4.16%
rust cucumber gherkin bdd cucumber-rust gherkin-rust

gherkin's People

Contributors

ahmedcharles avatar bbqsrc avatar bbros-dev avatar berhorshadowbuckle avatar dependabot[bot] avatar ilslv avatar lux01 avatar mgeisler avatar mladedav avatar mraof avatar nfedyashev avatar tyranron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gherkin's Issues

[Spec] Upstream alignment status: Happy-path specifications and data

This issue tracks the status of Gherkin-Rust implementation in terms of the specifications and data used in the upstream project.

The purpose of this issue is to track status. Please open a new issue if you wish to record or discuss a particular feature or its implementation.

Each item should be checked off once the specification and data and exactly match. NA items should be checked off once there is a spec/test confirming that no output is produced.
Any partial matches should be noted but not checked off.

In order to determine a match or not we rely on the Cucumber Compatibility Kit (CCK). The CCK allows certain fields to be different from the golden master, such as: SourceReference fields used in support code messages, Duration and Timestamp fields id fields.

To update the status of Cucumber-Rust compared to golden-master:

  • Requirements:
    • Install node.js >15.0 or from NodeSource
    • Install npm
    • git clone https://github.com/cucumber/cucumber ~/src/cucumber
    • git clone https://github.com/bbqsrc/gherkin-rust ~/src/cucumber-rust
pushd ~/src/cucumber/fake-cucumber
  npm install -g fake-cucumber
popd
pushd ~/src/cucumber/compatibility-kit
  make clean
  make
popd

The upstream data is here:

The specifications and data in Gherkin-Rust are circa 27-Feb 2021, commit 109f9a3.

Please open a pull request if you notice any specification or data has changed and uncheck the relevant item(s) in this list:.

[Spec] Upstream alignment status: Unhappy-path specifications and data

This issue tracks the status of Gherkin-Rust implementation in terms of the specifications and data used in the upstream project.

The purpose of this issue is to track status. Please open a new issue if you wish to record or discuss a feature and its implementation.

Each item should be checked off once the specification and data and exactly match. NA items should be checked off once there is a spec/test confirming that no output is produced.
Any partial matches should be noted but not checked off.

In order to determine a match or not we rely on the Cucumber Compatibility Kit (CCK). The CCK allows certain fields to be different from the golden master, such as: SourceReference fields used in support code messages, Duration and Timestamp fields id fields.

The upstream data is here:

The specifications and data in Gherkin-Rust are circa 27-Feb 2021, commit 109f9a3.

Please open a pull request if you notice any specification or data has changed.

Wishlist

  • Rewrite the parser to use nom instead of pest (pest doesn't scale particularly well)
    • Add nice error handling for nom

Message protocol: Cucumber Messages

Cucumber Messages is a message protocol for representing results and other information from Cucumber - Replaces json and junit formatters.

Stability/Performance:

With Cucumber Messages, several messages containing smaller pieces of information are emitted continuously to a stream,
avoiding high memory consumption and enabling real-time processing of results.

Additional functionality (motivation):

The protocol aims to decouple various components of the Cucumber platform so that:

  • Each component only needs to know about a subset of messages
  • Gherkin is decoupled from the Cucumber execution component
    • This is part of a strategy to support other formats such as Markdown and Excel

Using 'background' gives an error 'expected EOI or tag'

Hi,
I'm trying to use background keyword to for repeated authentication steps (after feature tag, or after the rule tag), but it always gives me an error:

Feature: As a REST API consumer 
	I want to retrieve data matching to the ID code
	I supply So I can use this data, for example, to create a report

	Background: Authentication steps
		Given I am authenticated
		And I have a role which allows reading the data

	Rule: I am authenticated
		Scenario: An existing ID code yields the correct data
			Given the ID code FOO
			When I request the data corresponding to the ID code
			Then the response in a JSON format contains the data

$ cargo test --test cucumber
warning: unused import: `steps`
 --> tests/cucumber.rs:4:26
  |
4 | use cucumber::{cucumber, steps, before, after};
  |                          ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running target/debug/deps/cucumber-b90ec94496d41947
[Cucumber v0.6.9]

———— ! Parsing feature failed: —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— features/example.feature:5:2
   --> 5:2
    |
  5 |   Background: Authentication steps␊
    |   ^---
    |
    = expected EOI or tag
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

0 features (1 errored)
0 scenarios (0 passed)
0 steps (0 passed)

error: test failed, to rerun pass '--test cucumber'
Feature: As a REST API consumer 
	I want to retrieve data matching to the ID code
	I supply So I can use this data, for example, to create a report

	Rule: I am authenticated
		Background: Authentication steps
			Given I am authenticated
			And I have a role which allows reading the data

		Scenario: An existing ID code yields the correct data
			Given the ID code FOO
			When I request the data corresponding to the ID code
			Then the response in a JSON format contains the data
$ cargo test --test cucumber
warning: unused import: `steps`
 --> tests/cucumber.rs:4:26
  |
4 | use cucumber::{cucumber, steps, before, after};
  |                          ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running target/debug/deps/cucumber-b90ec94496d41947
[Cucumber v0.6.9]

———— ! Parsing feature failed: —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— features/example.feature:6:3
   --> 6:3
    |
  6 |           Background: Authentication steps␊
    |           ^---
    |
    = expected EOI or tag
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

0 features (1 errored)
0 scenarios (0 passed)
0 steps (0 passed)

error: test failed, to rerun pass '--test cucumber'

Am I doing something in a wrong way, or background usage is not supported yet?

Bug: Smoke2 test failing

Fresh checkout of master, trying to run the tests - one of the smokes is failing:

PS F:\work\RustProjects\gherkin-rust> cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.16s
     Running target\debug\deps\gherkin_rust-9b6b434a8d9b6c63.exe

running 12 tests
test tagexpr::tests::parse_tag_expr1 ... ok
test tagexpr::tests::parse_tag_expr3 ... ok
test tagexpr::tests::parse_tag_expr1b ... ok
test tagexpr::tests::parse_tag_expr2 ... ok
test tagexpr::tests::parse_tag_expr4 ... ok
test tagexpr::tests::parse_tag_expr2b ... ok
test tagexpr::tests::parse_tag_expr5 ... ok
test tagexpr::tests::parse_tag_expr6 ... ok
test tagexpr::tests::parse_tag_expr7 ... ok
test parser::test::smoke2 ... FAILED
test parser::test::smoke ... ok
test tagexpr::tests::parse_tag_expr8 ... ok

failures:

---- parser::test::smoke2 stdout ----
thread 'parser::test::smoke2' panicked at 'assertion failed: gherkin_parser::feature(&s, &env).is_ok()', src\parser.rs:515:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    parser::test::smoke2

test result: FAILED. 11 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

Parsing a .feature file fails only on windows -- "expected hacks"

Hi,

I could use some help figuring out this problem.
We have a few .feature files details simple test cases, instead of using cucumber, I'm using this crate directly so that I could implement the tests as a unit test, so that code coverage tools would give me a coverage report.

Here is the test code: https://github.com/apollographql/rust/blob/63c62f5a29c328e429d463b958a2bbb832b09b89/query-planner/src/lib.rs#L70-L114

This code only fails on windows. That if cfg!(windows) { line was an attempt to resolve the issue, but it didn't matter.
See this test run: https://github.com/apollographql/rust/runs/1028873036?check_suite_focus=true

You can navigate to other runs of the same branch as well.

The error message is unclear as well:

error at 6:12: expected hacks

The only place in this codebase that has the word "hacks" is here, unfortunately, that's too deep in a macro for me to understand what it's supposed to mean.

I noticed that if I remove the if cfg!(windows) condition and always replace \n with \r\n, then I get the same error message on my mac.

Any help would be appreciated, thanks!

Data table parsing fails if no new line at end of table

I've just randomly noticed that having a data table - or, at least, an examples table but I assume it's the same - at the end of the file and not having a newline afterwards means the feature file doesn't parse.

For example:

    Scenario Outline: Look up an unknown username: <Username>
        When I look up the username '<Username>'
        Then the username does not exist

        Examples:
            | Username |
            | unknown  |

If there's a newline at the end, that all works fine. If there's not then I get:

———— ! Parsing feature failed: ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— tests/features/users/lookup_username.feature:10:25
    --> 10:25
     |
  10 |             | unknown  |
     |                         ^---
     |
     = expected table_field or table_row
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

It's a really easy fix in the feature file, but it wasn't obvious what was wrong or why.

Feature/Scenario description can only be 1 line

One of the primary benefits of BDD is that it produces living documentation. This can be particularly effective when the gherkin is post-processed by something like AsciiDoctor to provide URLs, images, mathematical notation, etc in a convenient, easy to read and useful document.

However, unlike other parsers this one appears to crash if the descriptions for Features/Scenarios are more than one line long or have any whitespace

Steps to reproduce-> Use the following Gherkin
Feature: Living Documentation
Living documentation is used by may companies, including those with mission critical objectives such as healthcare. In these cases, the documentation is the source of truth and is central to the businesses operations.

Not being able to document or provide mark up or other useful features limits the viability of what is supposed to be a source of truth.

Scenario: Adequate Description for core operations.
We definitely want to be able to do this.

Given I am writing living documentation
And many levels of management, coworkers and others rely on it
Then I need to have lengthier descriptions for features and scenarios

Scenario Outline inserts are not parsed in Data Tables

Given the following scenario:

    Scenario Outline: Look up a known username: <Username>
        Given a user exists with details:
            | Username | <Username> |
        When I look up the username '<Username>'
        Then the username does exist

        Examples:
            | Username |
            | known    |

The insert <Username> from the Examples table works correctly in the Scenario name and in the "When" step, but not in the "Given" step. Instead, when parsing the table, I get:

[["Username", "<Username>"]]

Where I would have expected:

[["Username", "known"]]

Using tabs as an indentation breaks feature file parsing

Hi,
when I use tabs as an indentation in feature file, then file is not parsed correctly - feature is found but no scenario and its steps are found (<tab> is a tab character):

Feature: Example feature

<tab>Scenario: An example scenario
<tab><tab>Given I am trying out Cucumber
<tab><tab>When I consider what I am doing
<tab><tab>Then I am interested in ATDD
<tab><tab>And we can implement rules with regex
$ cargo test --test cucumber
    Finished test [unoptimized + debuginfo] target(s) in 0.11s
     Running target/debug/deps/cucumber-8962c0abc6f239cb
[Cucumber v0.7.0]
Feature: Example feature                                                                                                                                                                  features/example.feature:1:1 


[Summary]
1 features
0 scenarios (0 passed)
0 steps (0 passed)

Finished in 0.0 seconds.

when I convert tabs to spaces then everything is working:

$ cargo test --test cucumber
    Finished test [unoptimized + debuginfo] target(s) in 0.11s
     Running target/debug/deps/cucumber-8962c0abc6f239cb
[Cucumber v0.7.0]
Feature: Example feature                                                                                                                                                                  features/example.feature:1:1 

 Scenario: An example scenario                                                                                                                                                            features/example.feature:3:3 
  ✔ Given I am trying out Cucumber                                                                                                                                                        features/example.feature:4:5 
  ✔ When I consider what I am doing                                                                                                                                                       features/example.feature:5:5 
  ✔ Then I am interested in ATDD                                                                                                                                                          features/example.feature:6:5 
  ✔ And we can implement rules with regex                                                                                                                                               features/example.feature:0:167 

[Summary]
1 features
1 scenarios (1 passed)
4 steps (4 passed)

Finished in 0.1 seconds.

I'm using latest cucumber-rust 0.7.0 with gherkin-rust 0.8.1

Inconsistent parsing behavior for unequal cell count in table rows

Parsing the following feature fails with a parsing error like expected:

Feature: Example feature
  Scenario: Just some example scenario
    Given there is a table with some rows
      | 1 | 1 |
      | 1 |

With such a parsing error output:

1 parsing error

gherkin crate parsing error is: "inconsistent table row sizes"

However, the following feature is parsed without any issues and the last column of the last row omitting silently:

Feature: Example feature
  Scenario: Just some example scenario
    Given there is a table with some rows
      | 1 |
      | 1 | 1 |

In case the step is defined the output is like this:

Feature: Example feature
  Scenario: Just some example scenario
   ✔  Given there is a table with some rows
       | 1 |
       | 1 |
[Summary]
1 feature
1 scenario (1 passed)
1 step (1 passed)

I would have expected the second example feature to also fail and especially not omit a part of the table silently.

This was observed with the following crate versions:

  • cucumber = "0.20.1"
  • gherkin = "0.14.0"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.