Search code examples
pythonunit-testingtelegramtelegram-botpython-telegram-bot

How to create unit test for a Python Telegram Bot


I've built this Telegram Bot in Python, with python-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.


Solution

  • Have you looked to unit tests that are present in python-telegram-bot library? I think it is a good place to start.

    For example, in this file (historical version) you can see how to test a dialog with bot that uses ConversationHandler.