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 GitHubVenkateshvenki404224/frappe-apps-manager
frappe-apps-manager
frappe-apps-manager/skills/frappe-unit-test-generator/SKILL.md
January 21, 2026
Select agents to install to:
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-generatorInstallation paths:
.claude/skills/frappe-unit-test-generator/# 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