feat(tests): 增强测试框架的 SQL 日志记录与覆盖率报告
- 在 ApiCase 中添加 SQL 日志记录功能,失败时输出日志以便于调试 - 更新 TestApp 以支持测试模式下的 SQL 日志缓冲,成功与失败的测试均可记录日志 - 改进 PrintCoverage 方法,优化覆盖率报告的输出逻辑,支持部分运行的接口显示 - 增加 Note 备注功能,提升测试用例的可读性与文档化效果 - 更新相关文档,详细说明新功能的使用场景与示例
This commit is contained in:
@@ -316,6 +316,14 @@ func (c *ApiCase) execute(method, desc string, expectStatus int, expectArgs ...i
|
||||
}
|
||||
}
|
||||
|
||||
if !passed {
|
||||
if sqlLog := c.api.app.Db.FlushTestLog(); sqlLog != "" {
|
||||
t.Logf("SQL 日志:\n%s", sqlLog)
|
||||
}
|
||||
} else {
|
||||
c.api.app.Db.FlushTestLog()
|
||||
}
|
||||
|
||||
record := TestRecord{
|
||||
Path: c.api.path,
|
||||
Desc: desc,
|
||||
|
||||
Reference in New Issue
Block a user