cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Cucumber option "name" does not interpret regex as I expect. #2314

Closed MajinKLS closed 3 years ago

MajinKLS commented 3 years ago

Hello to all the community.

My name is Carlos and I'm working in Selenium automation solution using Java, TestNg, Selenium and Cucumber.

I have my own framework wich is suposed to run all testcases passed throught Java's cucumber.options property using the "--name" command. This property is filled automatically in runtime after getting all scenarios names from my test managment repository. My scenario names have identifiers like "PROJECT-TestCaseID" and I want to do an exact match, so I convert them to "^PROJECT\-TestCaseID".

I tested this regex with some online interpeters and it worked like a charm but in my framework it matches similar ID's, not the exact one. I tested also adding a "$" anchor to the end of the ID but it does not work. Finally seems to work fine adding a non scaped minus sign at the end of the ID, for example "^PROJECT\-TestCaseID-", but I don't understand why this works and I was unable to find any answers.

Can anybody help me to find an answer? Best regards.

PD: I'm not an expert on regex and everytime I need to work with them it give me headache.

mpkorstanje commented 3 years ago

The cucumber.options property was very fragile and has been removed from the more recent versions of Cucumber. This means you are using an older version of Cucumber. This this an open source project ran by people in their spare time. So we don't take bug reports for older versions.

I couldn't reproduce the problem with the latest version. So try reproducing your problem with the cucumber-java-skeleton first. You can find the replacements for cucumber.options in this list.

If you can still reproduce the problem please feel free to create a new bug report, but do follow the instructions in the template.