Skip to main content

create json report with unittest

Project description

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文件

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

json_test_runner-1.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file json_test_runner-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for json_test_runner-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d0bb195305ce4e0bac54e581b0bd63f3e1283bfea589965bacfc5aaf0c74a43
MD5 86e2ecb6b424eaaa5b88ba7eae6e7649
BLAKE2b-256 a13437d751246134794c0747dd09f5d7e49f2f4ba67ff3e9d2ffacd57bc282a3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page