Логотип Generate Tests From Business Logic

Generate Tests From Business Logic

Спільнота
meirm
generate-tests-from-business-logic

Generates scenario tests, rule tests, edge case tests, state transition tests, and billing tests from trusted business logic. Use when creating test suites from BL, ensuring BL coverage, or turning requirements into verifiable tests.

Огляд

Видавецьmeirm
Репозиторійreverse-engineering-skill
Назва навичкиgenerate-tests-from-business-logic
Зірки
46
Форки
7
Файли в пакеті
Лише інструкції
ЛіцензіяMIT
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Усе необхідне — в інструкціях

    Усе потрібне моделі міститься в інструкціях — жодних додаткових файлів для синхронізації.

  • Відкритий вихідний код

    Видавець на GitHub: meirm. Перед установленням перегляньте вихідні файли навички.

Встановлення

Установіть навичку ШІ Generate Tests From Business Logic у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки на GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до розділу «Плагіни» → «Навички».
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/meirm/reverse-engineering-skill/tree/main/skills/generate-tests-from-business-logic
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Додати навичку → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/meirm/reverse-engineering-skill.git /tmp/reverse-engineering-skill
mkdir -p .claude/skills
cp -r /tmp/reverse-engineering-skill/skills/generate-tests-from-business-logic .claude/skills/generate-tests-from-business-logic
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Generate Tests From Business Logic в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Generate Tests From Business Logic, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для певного постачальника, тому навичка Generate Tests From Business Logic не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож поки навичка не потрібна, токени на її інструкції не витрачаються.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Generating Tests from Business Logic

Project-agnostic. Use BDD/project_config.yaml for terminology and code paths when present; write tests in the project's test framework and structure (see tailor-bdd-skills-for-project).

Purpose

Transform trusted business logic into a comprehensive test suite that continuously verifies implementation against business behavior. This is the BL enforcement skill.

Prerequisites

  • Refined business logic document (use refine-business-logic-for-implementation first)
  • Understanding of the project's testing framework (pytest, behave, etc.)
  • Knowledge of the project structure

Instructions

Step 1: Parse the Business Logic

Read the refined BL document and identify:

bash
cat path/to/refined_bl_document.md

Extract:

  • All business rules (validation, billing, workflows)
  • State machine definitions (states and transitions)
  • Decision tables
  • Invariants
  • Error handling rules
  • Billing/credit rules

Step 2: Classify Test Types

Organize tests into these categories:

A. Rule Tests - Verify individual business rules B. Scenario Tests - Verify end-to-end workflows C. State Transition Tests - Verify state machine correctness D. Edge Case Tests - Verify boundary conditions E. Billing Tests - Verify credit operations F. Regression Tests - Verify past bugs don't recur

Step 3: Generate Rule Coverage Tests

For each decision rule, generate three tests:

markdown
For every decision rule:
  - One happy path test (rule should succeed)
  - One negative path test (rule should fail)
  - One edge/boundary test (boundary condition)

Example:

markdown
BL Rule: "Request is rejected if identifier is invalid"

Generated Tests:
1. test_request_accepted_with_valid_identifier() - Happy path
2. test_request_rejected_with_invalid_identifier_format() - Negative path
3. test_request_rejected_with_empty_identifier() - Edge case (empty)
4. test_request_rejected_with_too_short_identifier() - Edge case (boundary)

Step 4: Generate State Transition Tests

For each state transition in the state machine:

markdown
For every valid transition:
  - Test that transition is allowed

For every forbidden transition:
  - Test that transition is blocked
  - Test that appropriate error is raised

For every terminal state:
  - Test that no further transitions are possible

Example:

markdown
BL States: PENDING → VALIDATED → SUBMITTED → PROCESSING → COMPLETED

Generated Tests:
1. test_pending_to_validated_on_valid_input() - Valid transition
2. test_cannot_transition_from_completed_to_processing() - Forbidden transition
3. test_query_in_completed_state_is_terminal() - Terminal state check

Step 5: Generate Billing/Credit Tests

For every charge/refund rule:

markdown
For every charge rule:
  - Test that charge occurs at the right time
  - Test that charge amount is correct
  - Test that charge does NOT occur when conditions not met

For every refund rule:
  - Test refund conditions
  - Test refund amount matches original charge

For partial success:
  - Test billing semantics
  - Test duplicate request semantics

Example:

markdown
BL Rule: "Balance deducted before [external] submission"

Generated Tests:
1. test_balance_deducted_on_submission() - Verify deduction
2. test_balance_not_deducted_if_validation_fails() - Verify no deduction
3. test_balance_not_deducted_if_insufficient() - Verify no deduction
4. test_deduction_amount_matches_cost() - Verify amount

Step 6: Generate Scenario Tests

For each workflow, generate end-to-end scenarios:

markdown
Scenario Format (Given/When/Then):
  Given: Initial state and conditions
  When: Action is taken
  Then: Expected outcome

Example:

markdown
BL Workflow: Query submission and processing

Generated Scenario:
Scenario: Successful query processing
  Given a tenant with sufficient credits
  And a valid MSISDN
  When the user submits a geolocation query
  Then the query is created with status PENDING
  And credits are deducted
  And the query is submitted to the provider
  And the query status becomes SUBMITTED

Step 7: Generate Edge Case Tests

Test boundary conditions and unusual inputs:

markdown
Common edge cases to test:
  - Empty/null values
  - Minimum and maximum values
  - Concurrent operations
  - Race conditions
  - Resource exhaustion
  - Network failures
  - Timeout scenarios

Example:

markdown
Generated Edge Case Tests:
1. test_query_with_maximum_length_msisdn() - Boundary test
2. test_concurrent_query_submission_same_msisdn() - Race condition
3. test_query_when_provider_timeout() - Timeout scenario
4. test_query_submission_with_zero_credits() - Boundary condition

Step 8: Output Test Files

Generate test files in the appropriate format:

For pytest (Python):

python
# tests/test_<domain>_bl.py

import pytest
# Import project models (e.g. Request, Account, Ledger)

class TestRequestSubmissionBL:
    """Tests for [Request/Operation] Submission Business Logic"""

    def test_request_accepted_with_valid_input(self):
        # Given
        account = create_account(balance=100)  # project-specific factory
        valid_input = "..."

        # When
        response = api_client.post('/api/requests/', {...})

        # Then
        assert response.status_code == 201
        assert Request.objects.filter(...).exists()

    def test_request_rejected_with_invalid_input(self):
        # ... implementation

For behave (BDD):

gherkin
# features/<domain>_bl.feature

Feature: [Operation] Submission Business Logic

  Scenario: Valid request is accepted
    Given an account with sufficient balance
    And valid input
    When the user submits the [operation]
    Then the request should be created
    And balance should be deducted (if applicable)

  Scenario: Invalid input is rejected
    Given an account with sufficient balance
    And invalid input format
    When the user submits the [operation]
    Then the request should be rejected
    And no balance should be deducted

Step 9: Create Test Coverage Matrix

Document which BL rules are covered by which tests:

markdown
## Test Coverage Matrix

| BL Rule | Test Type | Test Name | Coverage |
|---------|-----------|-----------|----------|
| Balance deducted on submission | Billing | test_balance_deducted_on_submission | ✅ |
| Invalid input rejected | Rule | test_request_rejected_with_invalid_input | ✅ |
| PENDING → VALIDATED on valid input | State Transition | test_pending_to_validated_on_valid_input | ✅ |

Step 10: Save Generated Tests

bash
# Create test directory structure
mkdir -p tests/bl
mkdir -p features/bl

# Save generated tests
cat > tests/test_<domain>_bl.py
cat > features/<domain>_bl.feature

Test Generation Templates

Rule Test Template

python
def test_{rule_name}_{expected_outcome}():
    """
    BL Rule: {rule_description}

    Expected: {expected_behavior}
    """
    # Given
    {setup_conditions}

    # When
    {action_taken}

    # Then
    {expected_result}

State Transition Test Template

python
def test_{from_state}_to_{to_state}_{condition}():
    """
    BL Transition: {from_state} → {to_state}

    Condition: {trigger_condition}
    """
    # Given
    entity = create_entity_with_state("{from_state}")

    # When
    entity.{trigger_action}()

    # Then
    assert entity.state == "{to_state}"

Billing Test Template

python
def test_{billing_event}_credits_{expected_action}():
    """
    BL Billing Rule: {billing_rule}

    Expected: {credits_action} (deducted/not_deducted/refunded)
    """
    # Given
    initial_credits = {amount}
    tenant = create_tenant_with_credits(initial_credits)

    # When
    {billing_event_action}

    # Then
    final_credits = tenant.credits
    assert final_credits == {expected_credits}

Test Coverage Checklist

For each BL rule, verify coverage of:

  • Happy path (successful execution)
  • Negative path (error conditions)
  • Edge cases (boundaries, unusual inputs)
  • State transitions (valid and invalid)
  • Billing operations (charges and refunds)
  • Concurrent operations (race conditions)
  • Idempotency (duplicate operations)
  • Timeout scenarios
  • Error recovery (fallback, retry)

Examples

Example 1: Generating Tests for Credit Logic

User request:

Generate tests from the credit deduction business logic

You would:

  1. Read the refined BL for credit rules
  2. Extract rules:
    • "Credits deducted before provider submission"
    • "Query rejected if insufficient credits"
    • "No refund for failed queries"
  3. Generate tests:
    python
    def test_credits_deducted_on_query_submission():
        """Verify credits are deducted when query is submitted"""
        pass
    
    def test_query_rejected_if_insufficient_credits():
        """Verify query is rejected when tenant lacks credits"""
        pass
    
    def test_no_refund_for_failed_queries():
        """Verify no credit refund when provider returns error"""
        pass
    
    def test_credits_deducted_prevents_negative_balance():
        """Verify credits cannot go negative due to race condition"""
        pass
    
    def test_concurrent_queries_with_exact_balance():
        """Verify concurrent queries respect balance limits"""
        pass
  4. Create test file: tests/test_credit_bl.py
  5. Generate coverage matrix

Example 2: Generating Tests for Provider Fallback

User request:

Create tests for the provider fallback logic

You would:

  1. Parse fallback BL rules
  2. Generate state transition tests:
    python
    def test_fallback_to_secondary_on_primary_timeout():
        """Verify fallback occurs when primary times out"""
        pass
    
    def test_no_fallback_on_invalid_target_error():
        """Verify no fallback for INVALID_TARGET from primary"""
        pass
    
    def test_fallback_occurs_once_per_query():
        """Verify fallback happens only once, not multiple times"""
        pass
    
    def test_query_stalled_after_all_providers_fail():
        """Verify STALLED status after all providers exhausted"""
        pass
  3. Generate edge case tests:
    python
    def test_both_primary_and_secondary_timeout():
        """Verify STALLED when both providers timeout"""
        pass
    
    def test_primary_returns_500_error():
        """Verify fallback for 500 error"""
        pass
    
    def test_fallback_with_different_cost_provider():
        """Verify correct cost used for fallback provider"""
        pass

Output Artifacts

The skill generates:

  1. Test files in appropriate format (pytest, behave, etc.)
  2. Test coverage matrix mapping BL rules to tests
  3. Coverage statistics showing percentage of BL rules tested
  4. Test documentation explaining test organization and naming conventions

Поширені запитання

Що робить навичка ШІ Generate Tests From Business Logic?

Generates scenario tests, rule tests, edge case tests, state transition tests, and billing tests from trusted business logic. Use when creating test suites from BL, ensuring BL coverage, or turning requirements into verifiable tests.

Навіщо використовувати Generate Tests From Business Logic у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Generate Tests From Business Logic — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Generate Tests From Business Logic у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/meirm/reverse-engineering-skill/tree/main/skills/generate-tests-from-business-logic. TypingMind прочитає файл SKILL.md і встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Generate Tests From Business Logic?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Generate Tests From Business Logic?

Зі скількома забажаєте. У TypingMind ви можете використовувати Generate Tests From Business Logic із будь-якою моделлю, яка підтримує навички, зокрема з GPT, Claude, Gemini, Grok, DeepSeek, Mistral чи Llama. Для цього ви використовуєте власні ключі API.

Чи безкоштовна навичка ШІ Generate Tests From Business Logic?

Так. На GitHub цю навичку публікує meirm за ліцензією MIT. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це набір інструкцій для повторного використання, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти, які вона може викликати, — код, який десь виконується й повертає результат. Натомість навичка ШІ дає моделі знання й пояснює порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі
Логотип openclaw

Channel Message Flows

openclaw
ОрганізаціяПопулярне

Використовуйте під час збору доказів проходження повідомлень каналом QA Lab.

82.2K
391K
Інструкції
Відкрити
Логотип openclaw

Claw Score

openclaw
ОрганізаціяПопулярне

Перевіряйте або оновлюйте документи зі зведеною оцінкою зрілості OpenClaw на основі кореневої таксономії, оцінок зрілості та артефактів із доказами QA, не використовуючи дані maintainer discrawl або звіти про інвентаризацію в репозиторії.

82.2K
391K
Файлів: 51
Відкрити
Логотип openclaw

Clawdtributor

openclaw
ОрганізаціяПопулярне

PR від Clawtributor тут, за минулий тиждень або інший період: знаходьте посилання на розмови, повторно перевіряйте GitHub і ранжуйте за впливом.

82.2K
391K
Інструкції
Відкрити
Логотип openclaw

Control Ui E2e

openclaw
ОрганізаціяПопулярне

Використовуйте під час проєктування, тестування, виправлення або розширення графічного інтерфейсу OpenClaw Control UI, зокрема для галерей стрес-тестування інтерфейсу зі зворотним зв’язком, наскрізних перевірок за допомогою Vitest + Playwright, сценаріїв Gateway із заглушками…

82.2K
391K
Файлів: 1
Відкрити

Створіть власний робочий простір зі ШІ вже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇