-
Notifications
You must be signed in to change notification settings - Fork 0
Writing Tests
In case you want to practice test-driven development, or ensure your bot still works after consecutive changes, you should write test cases.
This page needs contribution! For now, see test_updater.py
as a reference.
Unit tests are performed on a logically encapsulated component of the system. The definition of unit tests in contrast to integration tests is that they have no external dependencies.
Placeholder
In contrast to unit tests, integration tests may test the system in its eventual environment together with service integrations, such as the Bot API.
In order to test your bot the same way your users will, you can make use of a userbot library that will send messages to your bot and evaluate whether it responds in the way it should. The best choices for Python are Telethon and Pyrogram.
Once you have picked a userbot library and set it up, it is time to build an abstraction around the test capabilities you want to use. Common examples include methods such as send_message_await_response
and click_button
, as these functionalities don't come included with the libraries.
Ideally, we would be able to give you a fully functional integration test framework, but no open source solutions exist so far.
- Wiki of
python-telegram-bot
© Copyright 2015-2025 – Licensed by Creative Commons
- Architecture Overview
- Builder Pattern for
Application
- Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary
callback_data
- Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests