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

Feature: Is it possible to have a configurable option to detect duplicate test scenario in the project? #265

Open
ajithcoder opened this issue Jan 8, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@ajithcoder
Copy link

ajithcoder commented Jan 8, 2025

The problem

During report generation, duplicate test scenarios in the project create problems as the unique id is being allocated with respect to the test scenario name.Is it possible to have a config option to not allow duplicate test scenario names.

@ajithcoder ajithcoder added the enhancement New feature or request label Jan 8, 2025
@vitalets
Copy link
Owner

vitalets commented Jan 8, 2025

Could you provide an example?

I've tried the following feature with duplicate "Check title" scenario:

Feature: Playwright Home Page

  Scenario: Check title
    Given I am on Playwright home page

  Scenario: Check title
    Given I am on Playwright home page

There is error in the output:

> npx bddgen && npx playwright test

Error: duplicate test title "Playwright Home Page › Check title", first declared in features/homepage.feature.spec.js:6

   at features/homepage.feature.spec.js:12

  10 |   });
  11 |
> 12 |   test('Check title', async ({ Given, page, When, Then }) => { 

@ajithcoder
Copy link
Author

Thanks for the response.

Context for this case:

In our case,we are generating a junit report which will be exported to testrail after the run. The test-ids will be assigned uniquely depending on the test scenario name. If duplicates are present in the junit report, export will be failed.

Our Observation

When same test scenario is present in two different feature files, the duplication check is not working. There can be cases where this would be acceptable. But having a config option to determine if the duplication is allowed or not will be cool.

Thanks
Ajith

@vitalets
Copy link
Owner

vitalets commented Jan 9, 2025

I've made two features with the same scenario:
feature 1:

Feature: feature 1

  Scenario: Check title
    Given a step

feature 2:

Feature: feature 2

  Scenario: Check title
    Given a step

Running with junit reporter:

export default defineConfig({
  // ...
  reporter: [
    cucumberReporter('junit', {
      outputFile: 'cucumber-report/report.xml',
    }),
  ],

The report:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite failures="0" skipped="0" name="cucumber-js" time="1.96" tests="2">
  <testcase classname="feature 1" name="feature 1 › Check title" time="0.981">
    <system-out><![CDATA[Given a step..............................................................passed]]></system-out>
  </testcase>
  <testcase classname="feature 2" name="feature 2 › Check title" time="0.979">
    <system-out><![CDATA[Given a step..............................................................passed]]></system-out>
  </testcase>
</testsuite>

Each test case has name attribute, that is concatenation of feature name + scenario name, e.g. feature 1 › Check title.
Do you have duplicate feature names?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants