Balrog994 / cucumber-test-runner

An Extension for Visual Studio Code to Run and Debug CucumberJS Tests
MIT License
4 stars 6 forks source link

When trying to run a single test, other tests from other feature files are also ran #4

Closed hardymj closed 1 year ago

hardymj commented 1 year ago

Hi,

I have two feature files as an example image

They both contain 2 tests each that currently only print out the name of the test.

image

If I select TestFive to run on its own by pressing the Run Test or Debug Test, it will run TestFive but also TestSeven and TestEight from the other FeatureFile. The only test it does not run is the other test within the same FeatureFile.

image

If I add another simple test to FeatureOne and run a single Test, it will ignore the tests within the same FeatureFile

image

My cucumber.js file is as follows

module.exports = { default: { parallel: 1, retry:0, format: ['html:cucumber-report.html'], paths:['journeys///.feature'], require:['features/support/.js'], publishQuiet: true } }

Balrog994 commented 1 year ago

Hi, thanks for your feedback!

I tracked down your problem to be the same mentioned in #1. More precisely the problem lies in how cucumber-cli handles arguments from the command line and your configuration file.

To solve the problem I suggest creating 2 profiles in your cucumber.js file one called default used by the runner (in the future I'll allow you to select a profile name from the extension) and one named as you prefer to run the test directly from terminal.

The following is an example you can use to change your cucumber.js file:

const common = {
    parallel: 1,
    retry:0,
    format: ["html:cucumber-report.html"],
    require:['features/support/.js'],
    publishQuiet: true
};

module.exports = {
  default: {
    ...common,
  },
  cli: {
    ...common,
    paths: ['journeys|/|.feature'],
  },
};

If it works let me know so I can close the issue.

Thanks

hardymj commented 1 year ago

Hi @Balrog994 , Yes you are correct. I created the profiles as suggested in the cucumber.js file and it does indeed only run one of the tests now within Test Explorer For the command line, I added in the -p cli to the script to run or else it defaults back to default. Thanks