# Junit-Report
This Python package adds more control to your tests by decorating your functions and pytest fixtures and exporting them as JUnit xml.
**Table of contents**
- [Junit-Report](#junit-report)
- [Installation](#installation)
- [Usage](#usage)
- [OS parameters used for configuration](#os-parameters-used-for-configuration)
## Installation
```bash
pip install junit-report
```
## Usage
```python
import pytest
from junit_report import JunitTestSuite, JunitTestCase, JunitFixtureTestCase
class TestSomeThing:
@pytest.fixture
@JunitFixtureTestCase()
def my_fixture(self):
pass
@JunitTestCase()
def my_first_test_case(self):
pass
@JunitTestCase()
def my_second_test_case(self, name: str):
raise ValueError(f"Invalid name {name}")
@JunitTestSuite()
def test_suite(self, my_fixture):
self.my_first_test_case()
self.my_second_test_case("John")
```
### Output
```xml
<?xml version="1.0" ?>
<?xml version="1.0" ?>
<testsuites disabled="0" errors="0" failures="1" tests="3" time="8.893013000488281e-05">
<testsuite disabled="0" errors="0" failures="1" name="TestSomeThing_test_suite" skipped="0" tests="3" time="8.893013000488281e-05">
<testcase name="my_fixture" time="0.000010" classname="TestSomeThing" class="fixture"/>
<testcase name="my_first_test_case" time="0.000007" classname="TestSomeThing" class="function"/>
<testcase name="my_second_test_case" time="0.000071" classname="TestSomeThing" class="function">
<failure type="ValueError" message="Invalid name John">Traceback ... ValueError(f"Invalid name {name}") ValueError: Invalid name John</failure>
</testcase>
</testsuite>
</testsuites>
```
## OS parameters used for configuration
| Variable | Description |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| JUNIT_REPORT_DIR | Reports directory where the reports will be extracted. If it does not exist - create it. |
| FAIL_ON_MISSING_SUITE | Decide whether the test will throw a SuiteNotExistError exception if a JunitTestCase does not have a suite parent. <br/> Available values: 'True', 'true', 'y', 'Y', '1' |
Python库 | junit-report-0.1.13.tar.gz
版权申诉
194 浏览量
2022-04-10
05:06:10
上传
评论
收藏 8KB GZ 举报
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
最新资源
- 基于vue3.0的大数据分析系统,包含各种echarts和vue3.0新API
- 基于Java 实现WIFI探针的商业大数据分析技术(获得附近的人流量、入店量、驻留时长等信息 )
- Data$distriLecturer.class
- SECS移动解决方案 SECS如何实现扫码功能 SECS安卓APP SECS PDA应用 安卓版本SECS协议应用
- tuxiangsunajisjkN;SDN
- Linux:开源之光的发展历程与未来展望
- C++Qt操作Lotus Domino数据库 Lotus Domino C++连接Lotus Domino C++开发lotus
- Linux 操作系统提供了很多命令来进行系统管理、文件操作、网络设置等各种任务
- MySQL是一种广泛使用的关系型数据库管理系统
- MySQL是一种广泛使用的关系型数据库管理系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈