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

How to add Labels to a new Test Execution? in Cloud #111

Open
jreyes-fy opened this issue May 24, 2024 · 4 comments
Open

How to add Labels to a new Test Execution? in Cloud #111

jreyes-fy opened this issue May 24, 2024 · 4 comments

Comments

@jreyes-fy
Copy link

Running pytest with:
--jira-xray --testplan --cloud

After running command, I get the new Test Execution in my Test Plan. However, is there a way to add the field "Labels" ??

@fundakol
Copy link
Owner

I don't have access to Jira Xray to check how to add a label field, but I assume it should be added as customFields, like in this JSON example (you need to know its ID from your server instance):

{
    "info": {
        "summary": "Execution of automated tests for release v1.3",
        "description": "This execution is automatically created when importing execution results from an external source",
        "user": "admin",
        "startDate": "2014-08-30T11:47:35+01:00",
        "finishDate": "2014-08-30T11:53:00+01:00"
    },
        "tests": [
            {
                "testKey": "DEMO-25",
                "start": "2014-08-30T11:47:35+01:00",
                "finish": "2014-08-30T11:50:56+01:00",
                "comment": "Successful execution",
                "status": "FAIL",
                "customFields": [
                    {
                        "id": 1,
                        "value": "true"
                    },
                    {
                        "id": 2,
                        "value": "13400"
                    },
                    {
                        "id": 3,
                        "value": "Test instance is refreshed"
                    }
                ]
            }
        ]

I can implement this if that's what you need.

@jreyes-fy
Copy link
Author

thanks for your help @fundakol . Based on the xray cloud documentation, I do not see "Labels" in the list of Test Execution custom fields. However, the field "Labels" is part of Execution, as shown in the snapshot attached.
Screenshot 2024-05-28 at 3 31 03 PM
I hope there is a way to add this field.

In the meantime can you add the field "Test Environments"? It is included in Test Execution custom fields.

@jreyes-fy
Copy link
Author

jreyes-fy commented May 29, 2024

@fundakol: This repo https://github.com/mikepenz/xray-action is able to pass Labels to Xray.
It uses two files, testExecution.json and test.json that it combines later to post results. Hope this helps!!

testExecution.json
{
"fields": {
"summary": “Test Execution Summary”,
"description": “Test Execution Description”,
"assignee": { "id": “assignee_id”},
“issuetype": {"id": “issue_type_id”},
"labels": [ “Execution Test Label_1” ]
}
}

test.json

{
"fields": {
"labels": [ "Execution Test Label_1" ]
}
}

@fundakol
Copy link
Owner

Test environments filed is already added (just check the readme), you can set it via environment variable:

$ export XRAY_EXECUTION_TEST_ENVIRONMENTS="Env1 Env2 Env3"
$ export XRAY_EXECUTION_FIX_VERSION="1.0"
$ export XRAY_EXECUTION_REVISION=`git rev-parse HEAD`

$ export XRAY_EXECUTION_SUMMARY="Smoke tests" # New execution only
$ export XRAY_EXECUTION_DESC="This is an automated test execution of the smoke tests" # New execution only

or with the hook:

def pytest_xray_results(results, session):
    results["info"]["testEnvironments"] = [ "iOS", "Android" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants