Skip to content

Writing Tests

Joscha Götzer edited this page Jul 20, 2018 · 21 revisions

In case you want to practice test-driven development, or ensure your bot still works after consecutive changes (regression bugs are rather common for chatbots), you should write test cases.

Unit Tests

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. @Eldinnie has written an initial POC of a unit test framework for python-telegram-bot, but as the library grew it was not maintained. Perhaps you might be able to help us out here and help in completing the project ;) https://github.com/Eldinnie/ptbtest

Mocking

Placeholder

Integration Tests

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 in a real environment, 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 TgIntegration library should cover everything you need.

Clone this wiki locally