Skip to content
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

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

Merged

Conversation

betapl3b
Copy link
Contributor

@betapl3b betapl3b commented Sep 30, 2022

Context

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
Copy link
Collaborator

skhomuti commented Oct 6, 2022

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
Copy link
Contributor Author

betapl3b commented Oct 7, 2022

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
Copy link

rs16w commented Dec 9, 2022

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

Copy link
Contributor

@delatrie delatrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @betapl3b !

Thank you for your PR! You did great! This is a nice feature to have.
Even more, the plan is to obsolete all other filters and to replace them with more generic label-based filtering mechanism. The details are in this issue: #725.

I have some suggestions. Please, see my review comments.

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.

allure-pytest/src/plugin.py Outdated Show resolved Hide resolved
allure-pytest/src/plugin.py Outdated Show resolved Hide resolved
@delatrie delatrie changed the title Add --allure-labels command line option to filter test cases by custom labels Add --allure-labels command line option to filter test cases by custom labels (implements #725) Jan 23, 2023
@betapl3b
Copy link
Contributor Author

betapl3b commented Jan 25, 2023

@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!

@delatrie delatrie changed the title Add --allure-labels command line option to filter test cases by custom labels (implements #725) Add --allure-label command line option to filter test cases by custom labels (implements #725) Jan 26, 2023
@delatrie delatrie linked an issue Jan 26, 2023 that may be closed by this pull request
Copy link
Contributor

@delatrie delatrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go!

@delatrie delatrie merged commit efbebf7 into allure-framework:master Jan 26, 2023
beckerGil pushed a commit to beckerGil/allure-python that referenced this pull request Apr 10, 2023
…om labels (implements allure-framework#725) (allure-framework#690)

Co-authored-by: Sergey Khomutinin <31664571+skhomuti@users.noreply.github.com>
@betapl3b betapl3b deleted the pytest-run-with-allure-labels branch February 16, 2024 12:54
IvanBuruyane pushed a commit to IvanBuruyane/allure-python that referenced this pull request Mar 19, 2024
…om labels (implements allure-framework#725) (allure-framework#690)

Co-authored-by: Sergey Khomutinin <31664571+skhomuti@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label-based test selection for allure-pytest
4 participants