enhance(tests): 改进测试用例记录与覆盖率报告
- 在 ApiCase 中添加失败原因记录,提升测试结果的可读性 - 更新 CoverageReport 结构,增加总用例、通过用例和失败用例计数 - 优化 PrintCoverage 方法,支持详细输出未通过接口及其失败原因 - 更新 Swagger 生成逻辑,包含失败原因字段,增强调试信息 - 改进 SQL 错误计数逻辑,确保在测试模式下准确记录 SQL 错误
This commit is contained in:
+10
-6
@@ -24,6 +24,7 @@ type swaggerTestCase struct {
|
||||
Response map[string]interface{} `json:"response,omitempty"`
|
||||
Expect interface{} `json:"expect,omitempty"`
|
||||
VerifyError string `json:"verifyError,omitempty"`
|
||||
FailReason string `json:"failReason,omitempty"`
|
||||
}
|
||||
|
||||
type paramSpec struct {
|
||||
@@ -359,10 +360,11 @@ func (that *TestApp) GenerateSwagger(title, version, outputDir string) error {
|
||||
|
||||
var cases []swaggerTestCase
|
||||
for _, r := range recs {
|
||||
tc := swaggerTestCase{
|
||||
Name: r.CaseName, Note: r.Note, Method: r.Method, Passed: r.Passed,
|
||||
Response: r.ResponseBody, Expect: r.ExpectResult, VerifyError: r.VerifyError,
|
||||
}
|
||||
tc := swaggerTestCase{
|
||||
Name: r.CaseName, Note: r.Note, Method: r.Method, Passed: r.Passed,
|
||||
Response: r.ResponseBody, Expect: r.ExpectResult, VerifyError: r.VerifyError,
|
||||
FailReason: r.FailReason,
|
||||
}
|
||||
if r.Query != nil {
|
||||
tc.Query = r.Query
|
||||
}
|
||||
@@ -714,7 +716,8 @@ function cases(e){
|
||||
h+='<div class="cs"><div class="csh" onclick="accordion(this)"><span class="ar'+(i===0?' o':'')+'">▶</span><span class="dot '+(c.passed?'ok':'er')+'"></span>'+esc(c.name)+'<span class="ml">'+c.method+'</span></div>';
|
||||
h+='<div class="csb'+(i===0?' o':'')+'"><div style="padding:8px 10px">';
|
||||
if(c.note)h+='<div style="color:#aaa;font-size:12px;margin-bottom:8px;line-height:1.5">备注: '+esc(c.note)+'</div>';
|
||||
if(c.verifyError)h+='<div class="verify-err"><span class="verify-label">Verify 校验失败</span>'+esc(c.verifyError)+'</div>';
|
||||
if(!c.passed&&c.failReason)h+='<div class="verify-err"><span class="verify-label">失败原因</span>'+esc(c.failReason)+'</div>';
|
||||
else if(c.verifyError)h+='<div class="verify-err"><span class="verify-label">Verify 校验失败</span>'+esc(c.verifyError)+'</div>';
|
||||
const curlId='cc'+i;const respId='cr'+i;
|
||||
h+='<div class="row-hd" style="margin-bottom:4px"><span class="sec-title">cURL</span><button class="cp-sm" onclick="event.stopPropagation();copyEl(\''+curlId+'\')">复制</button></div>';
|
||||
h+='<div class="curl" id="'+curlId+'">'+esc(caseCurl(e,c))+'</div>';
|
||||
@@ -880,7 +883,8 @@ function updateCasePanel(e,i){
|
||||
const c=e.cases[i];
|
||||
let h='<div style="padding:8px 10px">';
|
||||
if(c.note)h+='<div style="color:#aaa;font-size:12px;margin-bottom:8px;line-height:1.5">备注: '+esc(c.note)+'</div>';
|
||||
if(c.verifyError)h+='<div class="verify-err"><span class="verify-label">Verify 校验失败</span>'+esc(c.verifyError)+'</div>';
|
||||
if(!c.passed&&c.failReason)h+='<div class="verify-err"><span class="verify-label">失败原因</span>'+esc(c.failReason)+'</div>';
|
||||
else if(c.verifyError)h+='<div class="verify-err"><span class="verify-label">Verify 校验失败</span>'+esc(c.verifyError)+'</div>';
|
||||
h+='<div class="row-hd" style="margin-bottom:4px"><span class="sec-title">cURL</span><span class="'+(c.passed?'tg tg-ok':'tg tg-err')+'" style="margin-left:6px">'+(c.passed?'通过':'失败')+'</span><button class="cp-sm" onclick="copyEl(\'c-curl\')" style="margin-left:auto">复制</button></div>';
|
||||
h+='<div class="curl" id="c-curl">'+esc(caseCurl(e,c))+'</div>';
|
||||
const hasDetail=c.expect&&c.expect.result!==undefined;
|
||||
|
||||
Reference in New Issue
Block a user