简体   繁体   English

如何为 Python Telegram Bot 创建单元测试

[英]How to create unit test for a Python Telegram Bot

I've built this Telegram Bot in Python, with python-telegram-bot .我用 Python 用python-telegram-bot构建了这个 Telegram Bot。 It's not so complex, but I want to do some regression tests to check if everything works fine after a new feature or a change, and more generally to test specific features to find bugs/edge cases.它并不那么复杂,但我想做一些回归测试以检查在新功能或更改后一切是否正常,更一般地测试特定功能以查找错误/边缘情况。

How can I achieve this?我怎样才能做到这一点?
For now, I'm doing this manually, clicking bot's keyboard and typing some text.现在,我正在手动执行此操作,单击机器人的键盘并输入一些文本。

Have you looked to unit tests that are present in python-telegram-bot library?您是否查看过python-telegram-bot库中存在的单元测试 I think it is a good place to start.我认为这是一个很好的起点。

For example, in this file you can see how to test a dialog with bot that uses ConversationHandler .例如, 在此文件中,您可以看到如何使用使用ConversationHandler机器人测试ConversationHandler

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM