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

Generating junitxml report with stdout missing #6945

Closed
likair opened this issue Mar 20, 2020 · 8 comments
Closed

Generating junitxml report with stdout missing #6945

likair opened this issue Mar 20, 2020 · 8 comments
Labels
type: regression indicates a problem that was introduced in a release which was working previously

Comments

@likair
Copy link

likair commented Mar 20, 2020

Description

Pytest fails to generate junitxml report with captured stdout after pytest 5.4.0.

pip list

Package            Version
------------------ -------
apipkg             1.5    
atomicwrites       1.3.0  
attrs              19.3.0 
execnet            1.7.1  
filelock           3.0.12 
importlib-metadata 1.5.0  
more-itertools     8.2.0  
packaging          20.3   
pip                20.0.2 
pluggy             0.13.1 
py                 1.8.1  
pyparsing          2.4.6  
pytest             5.4.1  
pytest-forked      1.1.3  
pytest-xdist       1.31.0 
setuptools         46.0.0 
six                1.14.0 
wcwidth            0.1.8  
zipp               3.1.0 

pytest and operating system versions

pytest 5.4.1
Ubuntu 19.10

Example

Content of test_junit.py:

def test_stdout():
    print('Testing...')

Let's run the test: pytest test_junit.py -v --junitxml result.xml

Content of result.xml:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
   <testsuite errors="0" failures="0" hostname="likai-ubuntu" name="pytest" skipped="0" tests="1" time="0.010" timestamp="2020-03-20T19:11:11.630551">
      <testcase classname="capture.test_junit" file="capture/test_junit.py" line="0" name="test_capture" time="0.000" />
   </testsuite>
</testsuites>

If I run the same test with pytest 5.3.5, the result contains stdout:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
   <testsuite errors="0" failures="0" hostname="likai-ubuntu" name="pytest" skipped="0" tests="1" time="0.011" timestamp="2020-03-20T19:17:00.902714">
      <testcase classname="capture.test_junit" file="capture/test_junit.py" line="0" name="test_capture" time="0.000">
         <system-out>Testing...</system-out>
      </testcase>
   </testsuite>
</testsuites>
@likair likair changed the title Generating junitxml report with missing stdout Generating junitxml report with stdout missing Mar 20, 2020
@likair
Copy link
Author

likair commented Mar 20, 2020

Well, here is the change: #6469
By default, no captured output is written.
https://docs.pytest.org/en/latest/reference.html#confval-junit_logging

@blueyed blueyed added the type: regression indicates a problem that was introduced in a release which was working previously label Mar 20, 2020
@bschnurr
Copy link

bschnurr commented Apr 7, 2020

How can we turn on --junit_logging=all by command line?

@bschnurr
Copy link

bschnurr commented Apr 7, 2020

How can we turn on --junit_logging=all by command line?
this worked.

-o junit_logging=all

@alpana17
Copy link

Are you getting system-out now?

@bschnurr
Copy link

yes thank you

@briceparmentier
Copy link

briceparmentier commented Apr 3, 2024

Hello here!

Sorry to revisit an old post, I'm running into the exact same issue but with different version of pytest.

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

@RonnyPfannschmidt
Copy link
Member

please open a new issue with more details, resurrecting 4 year old issues for new support requests is bad

@briceparmentier
Copy link

Sorry, I'm always concerned as on most forums we're asked not te replicate topics ;)
I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

7 participants