Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append logs of Pytest into Allure Report

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 https://i.stack.imgur.com/1AePZ.png

like image 394
Mahesh_Kokare Avatar asked Dec 03 '18 09:12

Mahesh_Kokare


People also ask

What is allure report in Python?

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have been tested in a neat web report form, but allows everyone participating in the development process to extract maximum of useful information from everyday execution of tests.

What are allure reports?

Allure is a reporting framework that represents brief reports in a clear form. This report template is available after you install ReadyAPI. It exports reports in the Allure results format. To transform them to an actual report, you need to use the Allure framework.


1 Answers

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:

enter image description here

like image 125
shurkam Avatar answered Oct 01 '22 04:10

shurkam