We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
对已有的service层添加单元/整合测试,以避免后续修改/重构破坏现有功能。
service
最终目的是在不发送http/db/cache请求的情况下对service进行测试,且确保tests不会因为网络/上游问题导致失败。
The text was updated successfully, but these errors were encountered:
@Billyzou0741326 估计不用写了,解耦困难,我一导入 bot 就是瞬间爆炸,加上你也没空,可以关闭这个issue了
bot
#346 已经关闭
Sorry, something went wrong.
如果要单元测试,不能存在 bot = Bot() 这样奇怪的操作,更不能把实例化后的东西相互导入,这种耦合无异于内容耦合. 毕竟我刚刚试试了,如果我要测试 参数分发器 是否正常工作,但是我单元测试时因为下面代码必然导致报错。 https://github.com/luoshuijs/TGPaimonBot/blob/2c068a4ed32282c6ad2c39df9739cfcff3366054/core/builtins/dispatcher.py#L61-L68 所以,为了解决内容耦合,我就尝试不把实例化 bot 暴露在公共中,如果要传递给 plugin , 我们只需在安装插件时传递本身, https://github.com/luoshuijs/TGPaimonBot/blob/421a20d3c660929f1f3b8bad6aaaaafb16897ba9/core/application.py#L112 需要声明 _Plugin 都需要这个玩意 https://github.com/luoshuijs/TGPaimonBot/blob/421a20d3c660929f1f3b8bad6aaaaafb16897ba9/core/plugin/_plugin.py#L71 而且在 init 后尝试注入 https://github.com/luoshuijs/TGPaimonBot/blob/421a20d3c660929f1f3b8bad6aaaaafb16897ba9/core/manager.py#L205 这样,还能解决不使用 context 或导入 bot 就能获取 job_queue 的问题 https://github.com/luoshuijs/TGPaimonBot/blob/421a20d3c660929f1f3b8bad6aaaaafb16897ba9/core/baseplugin.py#L48-L60
bot = Bot()
plugin
_Plugin
context
job_queue
No branches or pull requests
请确保您已阅读以上注意事项,并勾选下方的确认框。
需要添加的功能内容
对已有的
service
层添加单元/整合测试,以避免后续修改/重构破坏现有功能。最终目的是在不发送http/db/cache请求的情况下对
service
进行测试,且确保tests不会因为网络/上游问题导致失败。The text was updated successfully, but these errors were encountered: