Back to Skills

frappe-unit-test-generator

verified

Generate comprehensive unit tests for Frappe DocTypes, controllers, and API methods. Use when creating test files, writing test cases, or setting up test infrastructure for Frappe/ERPNext applications.

View on GitHub

Marketplace

frappe-marketplace

Venkateshvenki404224/frappe-apps-manager

Plugin

frappe-apps-manager

Repository

Venkateshvenki404224/frappe-apps-manager
6stars

frappe-apps-manager/skills/frappe-unit-test-generator/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/Venkateshvenki404224/frappe-apps-manager/blob/main/frappe-apps-manager/skills/frappe-unit-test-generator/SKILL.md -a claude-code --skill frappe-unit-test-generator

Installation paths:

Claude
.claude/skills/frappe-unit-test-generator/
Powered by add-skill CLI

Instructions

# Frappe Unit Test Generator

Generate production-ready unit tests for Frappe applications following patterns from ERPNext and Frappe core.

## When to Use This Skill

Claude should invoke this skill when:
- User wants to write unit tests for DocTypes
- User needs to test controller methods
- User requests API endpoint tests
- User wants to test business logic or validations
- User mentions testing, test cases, or test files
- User wants to set up test fixtures or test data
- User needs to test permissions or workflows

## Capabilities

### 1. DocType Test File Structure

Generate complete test files following Frappe's unittest framework.

**Basic Test Structure** (from ERPNext Item):
```python
# Pattern from: erpnext/stock/doctype/item/test_item.py
import frappe
import unittest
from frappe.tests.utils import FrappeTestCase

class TestItem(FrappeTestCase):
    def setUp(self):
        """Set up test fixtures before each test"""
        frappe.set_user("Administrator")
        self.test_item = self._create_test_item()

    def tearDown(self):
        """Clean up after each test"""
        frappe.db.rollback()

    def test_item_creation(self):
        """Test basic item creation"""
        item = frappe.get_doc({
            "doctype": "Item",
            "item_code": "_Test Item",
            "item_name": "Test Item",
            "item_group": "Products",
            "stock_uom": "Nos"
        })
        item.insert()

        self.assertEqual(item.item_code, "_Test Item")
        self.assertEqual(item.item_group, "Products")

        # Verify item was created
        self.assertTrue(frappe.db.exists("Item", "_Test Item"))

    def _create_test_item(self):
        """Helper method to create test item"""
        if frappe.db.exists("Item", "_Test Item"):
            return frappe.get_doc("Item", "_Test Item")

        item = frappe.get_doc({
            "doctype": "Item",
            "item_code": "_Test Item",
            "item_name": "Test Item",
            "item_g

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
16650 chars