diff --git a/lib/interfaces/gherkin.js b/lib/interfaces/gherkin.js index 0dc654acd..f471f5ab6 100644 --- a/lib/interfaces/gherkin.js +++ b/lib/interfaces/gherkin.js @@ -119,7 +119,14 @@ module.exports = (text, file) => { }); } const tags = child.scenario.tags.map(t => t.name).concat(examples.tags.map(t => t.name)); - const title = `${child.scenario.name} ${JSON.stringify(current)} ${tags.join(' ')}`.trim(); + let title = `${child.scenario.name} ${JSON.stringify(current)} ${tags.join(' ')}`.trim(); + + for (const [key, value] of Object.entries(current)) { + if (title.includes(`<${key}>`)) { + title = title.replace(JSON.stringify(current), '').replace(`<${key}>`, value); + } + } + const test = new Test(title, async () => runSteps(addExampleInTable(exampleSteps, current))); test.tags = suite.tags.concat(tags); test.file = file; diff --git a/test/bdd/features/faker.feature b/test/bdd/features/faker.feature index cebb57e0e..b69fc5f02 100644 --- a/test/bdd/features/faker.feature +++ b/test/bdd/features/faker.feature @@ -1,7 +1,7 @@ @bdd Feature: Faker examples - Scenario Outline: faker data genetation + Scenario Outline: faker data generation Given I sold the "" car to "" for "" When customer "" paid "" for car "" in "" Then "" returned "" in change to "" diff --git a/test/data/sandbox/features/IncludeExamplesInDataTable.feature b/test/data/sandbox/features/IncludeExamplesInDataTable.feature index 8b9338f37..7992dd97a 100644 --- a/test/data/sandbox/features/IncludeExamplesInDataTable.feature +++ b/test/data/sandbox/features/IncludeExamplesInDataTable.feature @@ -1,7 +1,7 @@ Feature: Include Examples in dataTtable placeholder @IncludeExamplesIndataTtable - Scenario Outline: order a product with discount + Scenario Outline: order a product with discount - - Given I have this product in my cart | data | value | | name | | diff --git a/test/data/sandbox/features/examples.feature b/test/data/sandbox/features/examples.feature index 4321244ff..bef164898 100644 --- a/test/data/sandbox/features/examples.feature +++ b/test/data/sandbox/features/examples.feature @@ -16,4 +16,4 @@ Feature: Checkout examples process | 20 | 20.0 | | 21 | 18.9 | | 30 | 27.0 | - | 50 | 45.0 | \ No newline at end of file + | 50 | 45.0 | diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index d9d301a5f..15de73f4e 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -99,6 +99,18 @@ describe('BDD Gherkin', () => { }); }); + it('should show data from examples in test title', (done) => { + exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Include Examples in dataTtable placeholder"', (err, stdout, stderr) => { //eslint-disable-line + stdout.should.include('order a product with discount - iPhone 5 - 10 @IncludeExamplesIndataTtable'); + stdout.should.include('name | Nuclear Bomb '); + stdout.should.include('price | 20 '); + stdout.should.include('name | iPhone 5 '); + stdout.should.include('price | 10 '); + assert(!err); + done(); + }); + }); + it('should run feature with tables', (done) => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout products"', (err, stdout, stderr) => { //eslint-disable-line stdout.should.include('Given I have products in my cart');