allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
725 stars 237 forks source link

Add `--allure-label` command line option to filter test cases by custom labels (implements #725) #690

Closed betapl3b closed 1 year ago

betapl3b commented 2 years ago

Context

[//]: # ( Describe the problem or feature in addition to a link to the issues ) This PR is adding --allure-labels cmdline option for pytest plugin. It filters test cases by any custom labels.

Usage examples: pytest --allure-labels label_name=value1,value2 pytest --allure-labels label_name=value1,value2 --allure-labels other_label_name=value3,value4 pytest --allure-labels=layer=ui pytest --allure-labels "other_label_name=value 1 with spaces,value 2 with spaces"

Checklist

skhomuti commented 2 years ago

The current filter options like epic feature story or something, are a labels too, probably we need to come up with the best design for filters and deprecate previous filter variants.

betapl3b commented 2 years ago

The current filter options like epic feature story or something, are a labels too, probably we need to come up with the best design for filters and deprecate previous filter variants.

Yes. I am aware of it. I just wanted to provide solution that allows user to filter tests by any label. Since TestOps users are allowed to use any string as custom field key (which is basically label), they might want to filter pytest runs by them as well. Current implementation does not allow to do so.

This thing seems to be working fine although it has some different syntax. It allows to specify several different labels with multiple values as it appends every argument to allure_label pytest option. And obviously this --allure-label implementation can replace epic feature story options completely.

rs16w commented 1 year ago

probably we need to come up with the best design for filters and deprecate previous filter variants.

Hello, How we can specify selected tests through custom labels now? I see methods just through default epic feature story

betapl3b commented 1 year ago

@delatrie

I also want to discuss the name. Maybe we should name the parameter as --allure-label (i.e., in singular)? A thing that follows the parameter is a value (or multiple values) for a single label only, so it sounds a little bit more precise to me.

Speaking about naming, I think it depends on definition of label. When I named it allure-labels I was thinking about key-value pairs. Something like feature=some_feature,other_feature are two labels. If we consider label as just single key so we think of it like: feature is label and some_feature and other_feature are just values for this label then you are right.

I think your option is closer to the way regular allure user thinks of labels and it increases readability, so I decided to rename it.

Thank you for your effort!