测试覆盖率总览
更新时间:2026-09-16
一、全局统计
| 指标 | 数值 |
|---|---|
| Go 测试文件 | 56 个 |
| Go 测试函数 | 916 个 |
| 前端测试文件 | 12 个 |
| 前端测试用例 | 155 个 |
| 集成测试 | 10 个(docker-compose 隔离环境) |
| CI 流水线 | .github/workflows/ci.yml(go test + integration-test) |
二、模块覆盖率明细
Go 后端
| 模块 | 总覆盖率 | 包级明细 |
|---|---|---|
| shared/pkg | 85.1% | abstraction 62.9% · auth 70.3% · middleware 100% · errors 100% · httputil 95.5% · imageutil 100% · repository 66.7% |
| studio | 84.8% | studio 84.8% |
| work | 84.4% | work 84.4% |
| msg-danmaku | 77.8% | danmaku 88.7% · message 67.0% |
| ai | 73.9% | ai 71.4% · subtitle 76.4% |
| live | 74.1% | live 74.1% |
| search | 72.6% | analytics 93.2% · hot 81.4% · profile 87.5% · search 28.1% |
| core | 71.8% | admin 78.9% · comment 19.8% · events 100% · favorite 21.6% · moderation 22.4% · social 17.8% · support 63.4% · user 62.2% · video 55.9% |
| bili-proxy | 80.0% | bilibili 87.5% · importer 12.7% · proxy 80.0% |
前端
| 模块 | 文件数 | 用例数 | 覆盖内容 |
|---|---|---|---|
| web/user utils | 7 | 57 | videoCard · safeStorage · liveMeetingStatus · clipboard · drafts · currentUser · auth |
| web/user store | 2 | 51 | user store · teriteri store(WS 全分支) |
| web/user component | 1 | 5 | LoginRegister |
| web/admin store | 1 | 11 | admin store login/logout/permissions |
| web/admin utils | 1 | 10 | auth |
三、覆盖率梯队
| 梯队 | 包 | 覆盖率 |
|---|---|---|
| ≥90% | middleware, errors, imageutil, analytics, events, httputil | 95~100% |
| 70~89% | admin, studio, work, hot, profile, danmaku, bilibili, ai, subtitle, live, proxy, auth, user, support | 70~89% |
| 50~69% | video, abstraction, repository, message | 55~67% |
| <50% | search, favorite, moderation, social, comment, importer | 12~28% |
四、低覆盖原因分析
| 包 | 覆盖率 | 原因 |
|---|---|---|
| search/search | 28.1% | 16 个 admin 端 handler(hotIncrement/hotKeyword/hotRank 等)未测试 |
| core/social | 17.8% | interaction_repository.go DB CRUD 路径多 |
| core/comment | 19.8% | comment_repository.go 多表 JOIN 查询 |
| core/favorite | 21.6% | favorite_handler.go 路由多但逻辑薄 |
| core/moderation | 22.4% | moderation_repository.go DB 层未 mock |
| bili-proxy/importer | 12.7% | 文件 I/O + 批量导入逻辑 |
| ai/ai | 71.4% | FetchStoredSummary 被 MinioStorageService 具体类型限制 |
五、测试基础设施
| 组件 | 路径 |
|---|---|
| Go 测试框架 | testing + testify/assert + go-sqlmock |
| 前端测试框架 | vitest + @vue/test-utils + happy-dom |
| 集成测试 | tests/integration/docker-compose.test.yml(PG 25432/Redis 26379/NATS 24222) |
| CI | .github/workflows/ci.yml |
| Makefile | make test / make test-integration / make coverage |
六、提交历史
| Commit | 内容 | 规模 |
|---|---|---|
ddb4415e | 搭建完整测试框架 | 58 文件,4309 行 |
a97a98a8 | 第一轮覆盖率提升 | 14 文件,3489 行 |
e94dc76b | 第二轮覆盖率提升 | 6 文件,3732 行 |
647f881b | 第三轮覆盖率提升 + 修复测试 bug | 32 文件,4808 行 |
ad8952e9 | 基建优化(air/Makefile/docker-compose) | 19 文件,475 行 |
dd40f32c | 前端测试补齐 utils/store | 8 文件,1049 行 |