Skip to content

Properties added with record_testsuite_property are not included in the json report #88

@markus-work

Description

@markus-work

I added a property with this fixture:

@pytest.fixture(autouse=True, scope="session")
def suite_run_id(record_testsuite_property):
    this_suite_run_id = str(uuid.uuid4())
    record_testsuite_property("test_suite_run_id", this_suite_run_id)
    return this_suite_run_id

Pytest was called with:

pytest --log-cli-level info --junitxml=logs/results/test-results.xml --json-report --json-report-file logs/results/test-results.json --json-report-omit log

The property test_suite_run_id does not appear in the json report, but it does appear in the xml report.

However, properties added with record_property are included, as seen with test_case_run_id.

Below I have added the json and xml reports

The json report:

{
    "created": 1676726608.4036124,
    "duration": 19.61397409439087,
    "exitcode": 0,
    "root": "C:\\workspace\\repo_name",
    "environment": {
        "Python": "3.9.13",
        "Platform": "Windows-10-10.0.22000-SP0",
        "Packages": {
            "pytest": "7.2.1",
            "pluggy": "1.0.0"
        },
        "Plugins": {
            "json-report": "1.5.0",
            "metadata": "2.0.4"
        }
    },
    "summary": {
        "passed": 1,
        "total": 1,
        "collected": 1
    },
    "collectors": [
        {
            "nodeid": "",
            "outcome": "passed",
            "result": [
                {
                    "nodeid": "tests.bla.py",
                    "type": "Module"
                }
            ]
        },
        {
            "nodeid": "tests.bla.py",
            "outcome": "passed",
            "result": [
                {
                    "nodeid": "tests.bla.py::blabla",
                    "type": "Function",
                    "lineno": 22
                }
            ]
        }
    ],
    "tests": [
        {
            "nodeid": "tests.bla.py::blabla",
            "lineno": 22,
            "outcome": "passed",
            "keywords": [
                "blabla",
                "tests.bla.py",
                "repo_name"
            ],
            "setup": {
                "duration": 2.7329063,
                "outcome": "passed",
                "stderr": "..."
            },
            "call": {
                "duration": 14.960456299999999,
                "outcome": "passed",
                "stderr": "..."
            },
            "user_properties": [
                {
                    "test_case_run_id": "c2935aa0-bea4-4123-993d-e8d2336e8100"
                }
            ],
            "teardown": {
                "duration": 1.5977405000000005,
                "outcome": "passed"
            }
        }
    ]
}

The corresponding xml report:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
   <testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="19.616" timestamp="2023-02-18T14:23:08.789638" hostname="...">
      <properties>
         <property name="test_suite_run_id" value="c2935aa0-bea4-4123-993d-e8d2336e8100" />
      </properties>
      <testcase classname="tests.bla" name="blabla" time="19.291">
         <properties>
            <property name="test_case_run_id" value="tests.bla.py::blabla|c2935aa0-bea4-4123-993d-e8d2336e8100" />
         </properties>
      </testcase>
   </testsuite>
</testsuites>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions