Skip to main content

JsonTestRunner

执行unittest 用例,输出json结构测试报告供web渲染或保存

输出结构体如下:

{
  "test_list": [
    {
      "style": "Failed",
      "name": "test_json_test_runner1.RunnerTestCase",
      "doc": "",
      "count": 2,
      "Pass": 1,
      "fail": 1,
      "error": 0,
      "cid": "c2",
      "info": [
        {
          "index": "test_json_test_runner1.RunnerTestCase.test_success",
          "name": "test_success",
          "style": "Pass",
          "desc": "",
          "script": "success\n",
          "status": "通过"
        }
      ]
    }
  ],
  "count": 5,
  "Pass": 2,
  "fail": 2,
  "error": 1,
  "passrate": "40.00%",
  "start_time": "2022-09-26 18:09:35",
  "stop_time": "2022-09-26 18:09:36",
  "duration": "0:00:01.003048"
}

安装

pip install json-test-runner

使用

命令行

jtr -c casepath

输出:

E  test_error (test_json_test_runner.RunnerCase)
F  test_failed (test_json_test_runner.RunnerCase)
ok test_pass (test_json_test_runner.RunnerCase)
F  test_failed (test_json_test_runner1.RunnerTestCase)
ok test_success (test_json_test_runner1.RunnerTestCase)

Time Elapsed: 0:00:01.003048
save report file: /work/json-test-runner/test/report.json

引用

from jsontestrunner import Runner

case_path = r'./test'
runner = Runner(case_path).run()  # 执行case
print(runner.stream)  # json结构体
runner.save()  # 保存测试报告为json文件

Metadata

Release files for json-test-runner 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for json-test-runner 1.0.0
File Interpreter ABI Platform Actions
json_test_runner-1.0.0-py3-none-any.whl Python 3 none any Details for json_test_runner-1.0.0-py3-none-any.whl

Release files / json_test_runner-1.0.0-py3-none-any.whl

Download URL json_test_runner-1.0.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d0bb195305ce4e0bac54e581b0bd63f3e1283bfea589965bacfc5aaf0c74a43
BLAKE2b-256 checksum
How to use checksums
a13437d751246134794c0747dd09f5d7e49f2f4ba67ff3e9d2ffacd57bc282a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.10

Security for json-test-runner 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page