-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
CucumberOptions: Tags and name do not work well together #976
Comments
I found in method detectFilter in FilterFormater.java, IllegalArgumentException will be thrown when filterClasses >1, does only single type be expected? tags, or lines, either names, private Filter detectFilter(List filters) {
Set<Class> filterClasses = new HashSet<Class>();
for (Object filter : filters) {
filterClasses.add(filter.getClass());
}
if (filterClasses.size() > 1) {
throw new IllegalArgumentException("Inconsistent filters: " + filters + ". Only one type [line,name,tag] can be used at once.");
}
Class<?> typeOfFilter = filters.get(0).getClass();
if (String.class.isAssignableFrom(typeOfFilter)) {
return new TagFilter(filters);
} else if (Number.class.isAssignableFrom(typeOfFilter)) {
return new LineFilter(filters);
} else if (Pattern.class.isAssignableFrom(typeOfFilter)) {
return new PatternFilter(filters);
} else {
throw new RuntimeException("Could not create filter method for unknown filter of type: " + typeOfFilter);
}
} |
Specifying tags, specifying (scenario) name, and specifying feature path and line are three different way of specifying which scenarios to execute. You can only use one of them at the time. |
Thanks @brasmusson, I expect to add these kinds of filter to work together as it's a real requirement. |
Then you would also have to design a way to specify how they should be combined. "Run all scenarios that matches this tag expression plus the scenarios that matches this name expression" is very different from "Run all scenarios that matches this tag expression if they also matches this name expression". It is not possible to change the FilterFormatter to a custom one. |
Thanks, I expect "tags and names", but someone might prefer "tags or names", so the default FilterFormatter keeps a single filter.... |
This sounds like an unusual requirement, but I don't see the harm in adding it. If you can send us a pull request we'll consider it. |
With #1035 (the upgrade to use Gherkin4), this will be changed (there the FilterFormatter which is a Gherkin2 thing, will not exist). Currently the approach is to use a filter chain similar to in Cucumber-Ruby, so for a pickle to be executed it need to be accepted by the line filters (if any), the tag filters (if any), and the name filters (if any). That is both name and tags can be used at the same time - with an and semantic. |
Sounds great! I think we can close this issue if Gherkin4 has this feature. |
Now when #1035 has been merged, the 2.0.0-SNAPSHOT version from the master branch (with the groupId io.cucumber), support tags, names and lines (lines on the feature paths) at the same time - with an and semantic. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
If I only set tags in cucumberOptions, it can filter which scenarios match the tags will be executed.
If I only set name in cucumberOptions, it also can filter which scenarios match the name will be executed.
if I only set feature path and scenario lines, it also can filter which scenario match the line will be executed
if I both set tags and name (or scenario line), nothing will be executed with output "Test Ignored", I expected it can filter by both tags and scenario name.
Here is my cucumber options.
The text was updated successfully, but these errors were encountered: