Skip to content

test: 提升单元测试覆盖率至80% - #857

Open
nekoili wants to merge 6 commits into
ikaros-dev:mainfrom
nekoili:feature/coverage-boost
Open

test: 提升单元测试覆盖率至80%#857
nekoili wants to merge 6 commits into
ikaros-dev:mainfrom
nekoili:feature/coverage-boost

Conversation

@nekoili

@nekoili nekoili commented Jul 14, 2026

Copy link
Copy Markdown

问题描述

当前项目整体测试覆盖率较低(约54%),需要提升至80%以上以保证代码质量和可维护性。

目标

逐步为各个模块编写测试用例,提升整体覆盖率至80%以上。

本次变更

infra/utils 模块

新增 7 个工具类测试文件:

  • RandomUtilsTest — 随机数工具类
  • JsonUtilsTest — JSON 解析工具类
  • PathUtilsTest — 路径处理工具类
  • TimeUtilsTest — 时间工具类
  • ByteArrUtilsTest — 字节数组工具
  • SqlUtilsTest — SQL 转义工具
  • AesEncryptUtilsTest — AES 加密工具

共约 75 个测试用例。

工作流

每个测试用例单独编译运行,通过后写下一个;单模块完成后跑全量测试检查覆盖率,针对未覆盖部分补充用例,循环直到达到80%。

Closes #(待补充)

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.97%. Comparing base (633ca04) to head (cffab10).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #857      +/-   ##
============================================
+ Coverage     57.20%   57.97%   +0.77%     
- Complexity     1702     1753      +51     
============================================
  Files           269      269              
  Lines         11241    11241              
  Branches        594      594              
============================================
+ Hits           6430     6517      +87     
+ Misses         4577     4499      -78     
+ Partials        234      225       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

nekoili added 5 commits July 15, 2026 02:22
- AttachmentOperatorTest: operator 包 22 个用例, 覆盖率达 100%
- StaticServiceImplTest: statics 包 6 个用例, 覆盖率 35% → 80%
- DefaultCustomSchemeManagerTest: custom.scheme 包 9 个用例
- DefaultCustomSchemeWatcherManagerTest: 6 个用例
- LogoutSuccessHandlerTest: logout 包 1 个用例
总体: 54% → 55%
…单元测试

subject 核心操作层 14 个用例
- 覆盖 SubjectOperator、SubjectRelationOperator、SubjectSyncOperator
- 删除之前失败的 AttachmentServiceImplMoreTest
新增以下服务的单元测试:
- TotpService: TOTP验证码生成与验证
- DefaultThemeService: 主题查询
- DefaultSettingService: 全局设置查询
- NotifyServiceImpl: 邮件通知发送
- MailServiceImpl: 邮件配置更新
- AttachmentDriverServiceImpl: 附件驱动CRUD与列表
- DefaultCollectionService: 收藏列表与类型查询
- 修正 AesEncryptUtilsTest 方法签名不匹配
- 修复 LuceneSubjectSearchServiceTest API 用法
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant