Files
cobol-java-v3/tests/cobol_testgen/test_java_report.py
T

41 lines
1.6 KiB
Python

"""COBOL vs Java 测试报告:白盒向后兼容 + 黑盒节"""
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
from cobol_testgen.runner import _write_java_test_report, GroupResult
def _summary(assign="W01", matched=1, mismatched=0):
return {"assign": assign, "cobol_count": matched + mismatched,
"java_count": matched + mismatched, "matched": matched,
"mismatched": mismatched, "samples": []}
def test_report_white_only_has_no_black_section(tmp_path):
results = [GroupResult(name="P_main", returncode=0, passed=True)]
reports = [{"label": "main", "rc": 0, "summaries": [_summary()]}]
_write_java_test_report(str(tmp_path), "P", results, reports)
text = (tmp_path / "P_测试报告.md").read_text(encoding="utf-8")
assert "### 2.1 组 `main`" in text
assert "## 2b." not in text
def test_report_with_black_section(tmp_path):
results = [
GroupResult(name="P_main", returncode=0, passed=True),
GroupResult(name="P_black_box_g1", returncode=0, passed=True),
]
reports = [
{"label": "main", "rc": 0, "summaries": [_summary()]},
{"label": "g1", "section": "black_box", "rc": 0,
"summaries": [_summary(assign="W02", mismatched=1)]},
]
_write_java_test_report(str(tmp_path), "P", results, reports)
text = (tmp_path / "P_测试报告.md").read_text(encoding="utf-8")
assert "### 2.1 组 `main`" in text
assert "## 2b. 黑盒组 Java 执行与出力比对" in text
assert "### 2b.1 黑盒组 `g1`" in text