How to append logs of Pytest into Allure Report

随声附和 提交于 2021-02-19 05:04:31

问题


How can i get to show all the logs of pytest into Allure. and what are stdout and stderr used for ?

Please check the Highlighted Code which i am referring to


回答1:


The stdout and stderr are used to display output produced by tests to those steams. To get them (and log) populated in Allure report your test or application executed by test have to produce output to corresponding streams.

import logging
import sys

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

def test_001():
    logger.info('Logged INFO message')
    logger.warning('Logged WARNING message')
    logger.error('Logged ERROR message')
    print('Message outputted to stdout')
    print('Message outputted to stderr', file=sys.stderr)
    assert 1 == 1

Output from test above:



来源:https://stackoverflow.com/questions/53591282/how-to-append-logs-of-pytest-into-allure-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!