add-telegram-api-tests

Generate Kotlin unit tests for Telegram Bot API actions using Kotest.

247|18|Updated May 26, 2022
One-click install
npx skills add https://github.com/vendelieu/telegram-bot --skill add-telegram-api-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-telegram-api-tests
Source: https://github.com/vendelieu/telegram-bot/tree/main/.cursor/skills/library-dev/add-telegram-api-tests
Command: npx skills add https://github.com/vendelieu/telegram-bot --skill add-telegram-api-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of writing comprehensive tests for the Telegram Bot API, ensuring the library's robustness and correctness.

Core Features & Use Cases

  • Test Class Setup: Provides a clear structure for creating test classes using BotTestContext and Kotest AnnotationSpec.
  • API Call Helpers: Offers convenient methods (action.sendReq, SimpleAction.sendReq) for making API calls within tests.
  • Assertion Methods: Includes built-in assertions for success (.shouldSuccess()) and failure (.shouldFailure()), with options for checking error messages.
  • Rate Limit Handling: Demonstrates how to gracefully handle potential 429 (Too Many Requests) errors.
  • Use Case: When a new Telegram API method like setStickerPositionInSet is added to the library, this Skill guides you through creating the necessary unit tests to verify its functionality.

Quick Start

Create a new test file in the telegram-bot/src/jvmTest/kotlin/eu/vendeli/api/ directory, extending BotTestContext and defining a test function with backticks.

Frequently Asked Questions about add-telegram-api-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests for Telegram Bot API actions in Kotlin?

To write unit tests for Telegram Bot API actions in Kotlin, extend the `BotTestContext` class using Kotest `AnnotationSpec` and define test functions. This setup provides convenient methods for making API calls and asserting success or failure scenarios.

What's the best way to test failure scenarios and rate limits for Telegram Bot API methods?

The best way to test failure scenarios and rate limits is by using built-in assertion methods like `.shouldFailure()` to check error messages. The framework also provides specific guidance for gracefully handling potential 429 Too Many Requests errors.

Do I need Kotest to test Telegram Bot API action logic?

Yes, you need Kotest to test Telegram Bot API action logic. This testing approach requires the Kotest framework, specifically its `AnnotationSpec` feature, to define and run the test functions within the `BotTestContext` environment.

How does the API call simulation work when testing new Telegram API methods?

API call simulation works by using convenient helper methods such as `action.sendReq` and `SimpleAction.sendReq` within your tests. These helpers make the API requests, allowing you to verify functionality and assert expected responses for new methods.

Can I check specific error messages when a Telegram API request fails?

Yes, you can check specific error messages when a Telegram API request fails. The testing framework includes built-in failure assertions with `.shouldFailure()` that provide options for verifying the exact error messages returned by the API actions.