The library for testing bots on aiogram3
Last updated Jun 19, 2026
71
Stars
13
Forks
7
Issues
0
Stars/day
Attention Score
2
Language breakdown
No language data available.
โธ Files
click to expand
README
Aiogram Tests
aiogram_tests is a testing library for bots written on aiogram
๐ Simple examples
Simple handler test
Simple bot:
from aiogram import Bot, Dispatcher, types
from aiogram.fsm.context import FSMContext
Please, keep your bot tokens on environments, this code only example
bot = Bot('123456789:AABBCCDDEEFFaabbccddeeff-1234567890')
dp = Dispatcher()
@dp.message() async def echo(message: types.Message, state: FSMContext) -> None: await message.answer(message.text)
if name == 'main': dp.run_polling(bot)
Test cases:
import pytest
from bot import echo
from aiogram_tests import MockedBot from aiogram_tests.handler import MessageHandler from aiogram_tests.types.dataset import MESSAGE
@pytest.mark.asyncio async def test_echo(): request = MockedBot(MessageHandler(echo)) calls = await request.query(message=MESSAGE.as_object(text="Hello, Bot!")) answermessage = calls.sendmesssage.fetchone() assert answer_message.text == "Hello, Bot!"
โถ๏ธ More examples
๐ More in this category