Skip to content

No output written to JUnit XML files #12189

Open
@briceparmentier

Description

@briceparmentier

Hello here!

I'm posting this following another older topic I found about someone having the same issue: #6945, but this was related to a way older version of Pytest than the one I'm running here.
I don't have anything getting written into the captured log of the JUnit XML files running Pytest. Only errors output.

I'm currently running pytest version 8.1.1, and whatever the configuration I try, I'm not getting any output from the tests into my JUnit XML files...
Here is the environment:

(venv) PS C:\workdir\test-env-python> pip list
Package         Version
--------------- -------
colorama        0.4.6
iniconfig       2.0.0
packaging       24.0
pip             24.0
pluggy          1.4.0
pytest          8.1.1
pytest-metadata 3.1.1
win32-setctime  1.1.0

I tried creating a brand new project using only pytest:
./conftest.py

import time

def pytest_configure(config):
    time_str: str = time.strftime('%Y_%m_%d_%Hh%Mm%Ss', time.localtime())
    config.option.xmlpath = f"./_reports/junit/{time_str}.xml"

./feature1/test_feature1.py

def test_feature1():
    print("test feature 1")

Running it with the command pytest -s -o junit_logging=all.

I only get the following XML file:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
    <testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.014" timestamp="2024-04-03T15:37:00.828439" hostname="DCHHHLZ3">
        <testcase classname="feature1.test_feature1" name="test_feature1" time="0.000">
            <system-out>--------------------------------- Captured Log ---------------------------------

--------------------------------- Captured Out ---------------------------------

</system-out>
            <system-err>--------------------------------- Captured Err ---------------------------------

</system-err>
        </testcase>
    </testsuite>
</testsuites>

I also tried removing the conftest.py file and runnign the command pytest -s --junitxml=/path/to/junit.xml", but it didn't change anything...

Any idea?
Am I missing anything?
Thanks a lot in advance.

Brice

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: junitxmlrelated to the junitxml builtin plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions