|
|
# 司法案件系统化测试_实践分享
|
|
|
|
|
|
## 项目背景
|
|
|
```html
|
|
|
司法案件:
|
|
|
利用数据中的案号和前序案号构成的边关系,构造出数据之间的无向关系图,组成一个司法案件的完整数据。
|
|
|
```
|
|
|
|
|
|
| 数据id | 当前案号 | 前序案号 |
|
|
|
|----|----|----|
|
|
|
| 1 | A | B |
|
|
|
| 2 | A | G |
|
|
|
| 3 | A | F |
|
|
|
| 4 | B | C |
|
|
|
| 5 | C | D |
|
|
|
| 6 | E | F |
|
|
|
| 7 | E | G |
|
|
|
|
|
|
案号关系无向关系图
|
|
|

|
|
|
|
|
|
## 数据流程
|
|
|
```html
|
|
|
数据无向图关系处理
|
|
|
related_case_code_base(图关系主表)
|
|
|
related_case_code_pair(图关系的边存储主表)
|
|
|
related_case_code_pair_black(图关系的黑名单)
|
|
|
related_case_code_uuid(图关系的id)
|
|
|
处理结果的使用
|
|
|
judicial_program_docs(司法案件的具体底层数据)
|
|
|
judicial_program_docs_party(司法案件的具体底层数据的当人事)
|
|
|
judicial_program(司法案件的审理程序)
|
|
|
judicial_case(司法案件主表)
|
|
|
```
|
|
|
|
|
|
## 测试效果
|
|
|
测试通过:
|
|
|

|
|
|
测试不通过:
|
|
|

|
|
|
|
|
|
##
|
|
|
```
|
|
|
(collie) [collie@bdp-kapp-sifa-06201 jdt]$ cd /home/collie/project-collie-app/app_justizache/utils/jdt
|
|
|
(collie) [collie@bdp-kapp-sifa-06201 jdt]$ python jdt.py run -c 1.yaml -p product_fzx -t 100103,200102,200103,200202,200402
|
|
|
2022-12-15 14:52:50.243 | SUCCESS | suite:run:88 - 测试用例 100103 PASS
|
|
|
2022-12-15 14:52:56.355 | SUCCESS | suite:run:88 - 测试用例 200102 PASS
|
|
|
2022-12-15 14:53:02.624 | SUCCESS | suite:run:88 - 测试用例 200103 PASS
|
|
|
2022-12-15 14:53:09.202 | SUCCESS | suite:run:88 - 测试用例 200202 PASS
|
|
|
2022-12-15 14:53:15.565 | SUCCESS | suite:run:88 - 测试用例 200402 PASS
|
|
|
```
|
|
|
|
|
|
(collie) [collie@bdp-kapp-sifa-06201 jdt]$ cd /home/collie/project-collie-app/app_justizache/utils/jdt
|
|
|
(collie) [collie@bdp-kapp-sifa-06201 jdt]$ python jdt.py run -c 1.yaml -p product_fzx -t 200102
|
|
|
```json lines
|
|
|
{ suite.py:83
|
|
|
'断言': 1,
|
|
|
'运行结果': [{'use_flag': 10, 'std_sc_code': '(2022)沪0004民初0001号', 'std_sp_code': '(2022)沪0001民初0001号'}, {'use_flag': 0, 'std_sc_code': '(2022)沪0004民初0001号', 'std_sp_code': '(2022)沪0003民初0001号'}],
|
|
|
'预期结果': [{'use_flag': 0, 'std_sc_code': '(2022)沪0004民初0001号', 'std_sp_code': '(2022)沪0003民初0002号'}, {'use_flag': 10, 'std_sc_code': '(2022)沪0004民初0001号', 'std_sp_code': '(2022)沪0001民初0001号'}],
|
|
|
'差异': {'values_changed': {"root[0]['std_sp_code']": {'new_value': '(2022)沪0003民初0001号', 'old_value': '(2022)沪0003民初0002号'}}}
|
|
|
}
|
|
|
{ suite.py:83
|
|
|
'断言': 6,
|
|
|
'运行结果': [{'use_flag': 0, 'uuid_count': 1, 'pid_count': 2}, {'use_flag': 10, 'uuid_count': 1, 'pid_count': 1}],
|
|
|
'预期结果': [{'use_flag': 0, 'uuid_count': 1, 'pid_count': 1}, {'use_flag': 10, 'uuid_count': 1, 'pid_count': 1}],
|
|
|
'差异': {'values_changed': {"root[0]['pid_count']": {'new_value': 2, 'old_value': 1}}}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## 使用
|
|
|
```html
|
|
|
http://tech.pingansec.com/granite/project-collie-app/-/blob/master/app_justizache/utils/jdt/%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E4%B8%8A%E7%BA%BF%E6%B5%8B%E8%AF%95.md
|
|
|
|
|
|
__product_fzx:
|
|
|
vars:
|
|
|
prefix: ""
|
|
|
test_input_path: "test" # 测试数据临时文件
|
|
|
suite:
|
|
|
path: "/home/collie/project-collie-app/app_justizache/utils/jdt/suite"
|
|
|
case:
|
|
|
- 200401
|
|
|
runner:
|
|
|
- exec: /home/collie/product/app_justizache/bdp_case_test/deploy/bdp_case_test.sh
|
|
|
args:
|
|
|
- __TEST_CASE_INPUT__ # 具体的一个测试文件 /home/collie/project-collie-app/app_justizache/utils/jdt/test/100103_1671087164.json
|
|
|
- __TEST_CASE__ # 测试用例的代码 200101
|
|
|
- fzx # 数据库的前缀
|
|
|
db_config_test:
|
|
|
host: "10.8.6.102"
|
|
|
port: 3810
|
|
|
user: "root"
|
|
|
password: "root123"
|
|
|
db: "fzx_test_case"
|
|
|
```
|
|
|
|
|
|
## 系统化测试的环境构成
|
|
|
```html
|
|
|
http://tech.pingansec.com/granite/project-collie-app/-/blob/master/app_justizache/utils/jdt/suite/200101/precondition_data.xlsx
|
|
|
```
|
|
|
|
|
|
## 系统化测试的输入
|
|
|
```html
|
|
|
http://tech.pingansec.com/granite/project-collie-app/-/blob/master/app_justizache/utils/jdt/suite/200101/input.json
|
|
|
```
|
|
|
|
|
|
## 系统化测试的断言组成
|
|
|
```
|
|
|
desc: >
|
|
|
|
|
|
assertion:
|
|
|
- name: 1
|
|
|
sql: "select count(1) num from related_case_code_pair where use_flag=0"
|
|
|
result:
|
|
|
- {"num": 1000 }
|
|
|
desc:
|
|
|
- name: 2
|
|
|
sql: "select count(1) num from related_case_code_pair_black where use_flag=0"
|
|
|
result:
|
|
|
- {"num": 2 }
|
|
|
desc:
|
|
|
- sql: "select count(distinct judicial_uuid) as uuid_count from related_case_code_uuid"
|
|
|
name: 2
|
|
|
result:
|
|
|
- { "uuid_count": 1 }
|
|
|
desc:
|
|
|
- sql: "select use_flag,count(distinct judicial_uuid) as uuid_count from judicial_case group by use_flag"
|
|
|
name: 3
|
|
|
result:
|
|
|
- { "use_flag": 0 ,"uuid_count": 1 }
|
|
|
desc:
|
|
|
- sql: "select use_flag,count(distinct judicial_uuid) as uuid_count,count(distinct program_id) as pid_count from judicial_program group by use_flag"
|
|
|
name: 4
|
|
|
result:
|
|
|
- { "use_flag": 0 , "uuid_count": 1, "pid_count": 1 }
|
|
|
desc:
|
|
|
- sql: "select use_flag,count(distinct judicial_uuid) as uuid_count,count(distinct program_id) as pid_count from judicial_program_docs group by use_flag"
|
|
|
name: 5
|
|
|
result:
|
|
|
- { "use_flag": 0 ,"uuid_count": 1, "pid_count": 1 }
|
|
|
- { "use_flag":10 ,"uuid_count": 1, "pid_count": 1 }
|
|
|
desc:
|
|
|
- sql: "select use_flag,count(distinct judicial_uuid) as uuid_count,count(distinct program_id) as pid_count from judicial_program_docs_party group by use_flag"
|
|
|
name: 6
|
|
|
result:
|
|
|
- { "use_flag": 0 ,"uuid_count": 1, "pid_count": 1 }
|
|
|
- { "use_flag":10 ,"uuid_count": 1, "pid_count": 1 }
|
|
|
desc:
|
|
|
```
|
|
|
|
|
|
|
|
|
## 系统化测试的测试用例分析
|
|
|
```
|
|
|
关联关系的测试:
|
|
|
https://pingansec.yuque.com/wbbfi2/tzung4/pb7cat
|
|
|
数据具体内容的测试:
|
|
|
https://pingansec.yuque.com/wbbfi2/tzung4/hzkzdl5knxmkscvq
|
|
|
```
|
|
|
|
|
|
|
|
|
|