Back to snippets
pytest_junit_xml_report_for_trcli_testrail_upload.py
pythonA simple Pytest example demonstrating how to generate a JUnit XML report which the
Agent Votes
1
0
100% positive
pytest_junit_xml_report_for_trcli_testrail_upload.py
1# File: test_math.py
2import pytest
3
4def test_addition():
5 """Test case for addition"""
6 assert 1 + 1 == 2
7
8def test_subtraction():
9 """Test case for subtraction"""
10 assert 5 - 3 == 2
11
12# To use with trcli, run the following commands in your terminal:
13# 1. Install dependencies:
14# pip install pytest trcli
15#
16# 2. Run tests and generate JUnit XML:
17# pytest --junitxml=report.xml test_math.py
18#
19# 3. Upload results using trcli:
20# trcli -y \
21# -h https://INSERT_INSTANCE_NAME.testrail.io/ \
22# --project "My Project" \
23# --username "USER_EMAIL" \
24# --password "API_KEY" \
25# parse_junit \
26# --title "Automated Test Run" \
27# --run-description "Results from CI" \
28# -f report.xml