with one click
add-telegram-api-tests
// Writes tests for Telegram Bot API actions. Use when adding tests for an API action, testing a new Telegram method, or when the user asks to add tests for the telegram-bot library.
// Writes tests for Telegram Bot API actions. Use when adding tests for an API action, testing a new Telegram method, or when the user asks to add tests for the telegram-bot library.
Adds a new collector to the ktnip KSP processor. Use when implementing a new handler type (e.g. new annotation like @MyHandler), adding a collector for a new activity pattern, or extending the ktnip processor to collect additional annotated functions.
Adds tests for the ktnip KSP processor. Use when adding tests for a new collector, testing processor behavior with new annotations, or verifying KSP code generation for the telegram-bot library.
[Library contributor] Adds a new collector to the ktnip KSP processor. Use when implementing a new handler type (e.g. new annotation like @MyHandler), adding a collector for a new activity pattern, or extending the ktnip processor to collect additional annotated functions.
[Library contributor] Adds tests for the ktnip KSP processor. Use when adding tests for a new collector, testing processor behavior with new annotations, or verifying KSP code generation for the telegram-bot library.
Adds a new parameter resolution strategy to the ktnip KSP processor. Use when handler functions need to receive a new parameter type (e.g. ChatMember, InlineQuery), or when adding support for a new resolvable type in Activity invocation.
Adds a new Telegram Bot API method (action class and top-level functions). Use when implementing a new Telegram API endpoint, adding support for a specific method (e.g. sendVideoNote, getChatMemberCount), or creating a new action for the telegram-bot library.
| name | add-telegram-api-tests |
| description | Writes tests for Telegram Bot API actions. Use when adding tests for an API action, testing a new Telegram method, or when the user asks to add tests for the telegram-bot library. |
bot, TG_ID, CHAT_ID, CHANNEL_ID)@Test suspend fun`method name method test`class MyApiTest : BotTestContext() {
@Test
suspend fun `my method test`() {
// ...
}
}
action.sendReq(to = TG_ID, via = bot) or action.sendReq(CHAT_ID)action.sendReq(via = bot) or action.sendReq()sendReq() uses TG_ID and bot when omitted.shouldSuccess() - asserts ok, isSuccess, getOrNull not null.getOrNull() when success not guaranteed.shouldFailure() - returns Response.Failureresponse.shouldFailure() shouldContainInDescription "ERROR_TEXT"For methods that may hit rate limits (e.g. setMyName):
val result = setMyName("test").sendReq()
result.onFailure { if (it.errorCode == 429) return }
result.shouldSuccess()
telegram-bot/src/jvmTest/kotlin/eu/vendeli/api/botactions/, media/, message/, chat/, etc.Tests load from .env or system env. Required for most tests:
TELEGRAM_ID - your Telegram user IDBOT_TOKEN - bot token from BotFatherOptional:
CHAT_ID - for chat/group testsCHANNEL_ID - for channel testsBOT_TOKEN_2 - rate-limit testingshouldFailure() shouldContainInDescription