question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature request] use tags for example tables for scenarios with more example tables

See original GitHub issue

When I have a scenario with more example tables with different tags:

Scenario Outline: Test example
  Given Step with <param1>
  When Step with <param2>
  Then Result is <result>

@smoke
Examples:
| param1 | param2 | result |
| foo    | bar    | foobar |
| 1      | 2      | 3      |

@regression
Examples:
| param1 | param2 | result |
| abc    | def    | abcdef |
| z      | y      | z      |

I would like to run only those examples that are tagged with specific tag, for example @smoke. This is possible with pure cucumber-js, do they use different tag-expressions? According to cucumber documentation: Tags can be placed above the following Gherkin elements:

  • Feature
  • Scenario
  • Scenario Outline
  • Examples

I tried to run cucumber-js and it worked, but when running cypress with cypress-cucumber-preprocessor, I get an error: We could not detect any tests in the above file. Write some tests and re-run.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:19
  • Comments:56 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
rkrisztiancommented, Aug 6, 2021

@RitikaGhosh15 , @dankopetrovic , PR https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/pull/609 opened.

@jime2003 , I think the env problem should be a separate issue report to keep things focused.

2reactions
rkrisztiancommented, Aug 6, 2021

@dankopetrovic , OK, I tried https://github.com/TheBrainFamily/cypress-cucumber-example, although it seems a bit too old. Regardless, after updating the preprocessor to the latest version, I tried to check if we can tag examples individually there and filter for those tags:

  • CYPRESS_TAGS='@tagS and @tagE2' npm run test => Worked.
  • npx cypress run -e TAGS='@tagS and @tagE2' => Worked.

What did not work:

$ DEBUG=true npx cypress-tags run -e TAGS='@tagS and @tagE2'
Using cypress.json configuration:
Spec files:  {cypress/integration/**/*.{feature,cypress/integration/features}}
Ignored files:  *.js
DEBUG: Found glob [ '{cypress/integration/**/*.{feature,cypress/integration/features}}' ]
DEBUG: Found tag expression [ '@tagS and @tagE2' ]
No matching tags found

=> I think the problem is with the cypress-tags script, which seems to fail to find tagged examples (it works for TAGS='@tagS), but your reported errors are different from mine. While I think it makes sense to look into the cypress-tags script and see why I got this error (which I will try), I think it would be still useful to see an example project that lets me reproduce the exact same issue you guys reported, just to be sure we are dealing with the same error.

Edit: I found the problem:

      let testFiles = !Array.isArray(cypressConf.testFiles)
        ? cypressConf.testFiles.split(",")
        : cypressConf.testFiles;

This is just plain wrong when cypressConf.testFiles is set to **/*.{feature,features}. After doing a workaround, I still get a similar error:

No matching tags found

And that is because the tag filtering script does not take examples into account. This one should be an easy fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Cucumber Tagging with Multiple Examples tables in a ...
userdate.feature - amended the Scenario Outline for the example. Scenario Outline: BR001 test Given something When happen Then result "".
Read more >
Data Tables in Cucumber - Tools QA
Data Tables in Cucumber. In this example, we will pass the test data using the data table and handle it using Raw() method....
Read more >
How to structure a long list of examples with SpecFlow?
Tables are a good solution, and most Given-When-Then tools support listing tables of examples with scenario outlines. Scenario outlines use placeholders ...
Read more >
Writing Features - Gherkin Language - Behat
You can use tags to group features and scenarios together, independent of your ... It is replaced with a real value from the...
Read more >
Cucumber - Data Tables - Tutorialspoint
Example · Create a feature file, named as dataTable.feature inside the package dataTable (see section scenario outline for more detailed steps). · Write...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found