Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

探讨改善单例无法测试的问题 #613

Open
Tracked by #612
greenhat616 opened this issue Nov 22, 2023 · 0 comments
Open
Tracked by #612

探讨改善单例无法测试的问题 #613

greenhat616 opened this issue Nov 22, 2023 · 0 comments
Milestone

Comments

@greenhat616
Copy link
Member

greenhat616 commented Nov 22, 2023

目前的 CacheABlogger 以及移除的 Database 类都是单例懒加载模式,提供 getInstance 的方法。

单例模式下:

  • 无法 Mock 以提供良好的单元测试
    • 因此此前只能通过 黑盒测试 来弥补无法测试的缺陷
  • 通过静态类实现的 懒初始化使得实现 AB 必须彻底重写 Cache 类,甚至还需要 RedisWrapper 类以持有两个连接池

所以需要探讨:通过 IOC 还是什么方法 以解决这个麻烦

@greenhat616 greenhat616 mentioned this issue Nov 22, 2023
16 tasks
@greenhat616 greenhat616 added this to the v1.8.0 milestone Nov 22, 2023
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

No branches or pull requests

1 participant