Generates Karate .feature files and JUnit 5 Runner classes from user stories or test case descriptions. Creates files in examples/<domain>/ following BDD, Gherkin, clean code, and SOLID principles.
Load this skill when the user provides:
read_file on src/test/java/examples/users/users.feature and UsersRunner.java to match code style exactly.github/skills/karate-feature-generator/templates/feature.template.md and runner.template.mdsrc/test/java/examples/<domain>/<domain>.featuresrc/test/java/examples/<domain>/<Domain>Runner.java| HU element | Karate element |
|---|---|
| Acceptance criteria (happy path) | Scenario with @smoke tag |
| Validation / error rule | Scenario with @error-path tag |
| Data variations | Scenario Outline + Examples table |
| Preconditions | Background steps |
| Domain entity fields | * def <domain>Model schema in Background |
GET /<domain>GET /<domain>/{id}POST /<domain>PUT /<domain>/{id}PATCH /<domain>/{id}DELETE /<domain>/{id}ALLOWED matchers:
'#number' → any number
'#string' → any string
'#boolean' → any boolean
'#null' → null value
'#notnull' → not null
'#ignore' → skip this field
'#array' → any array
'#[n]' → array of exactly n items
'#regex ...' → regex match
FORBIDDEN in .feature files:
× Hardcoded API keys
× Java code or imports
× Implementation details in step text
× Raw assertEquals — always use 'match'
× Business logic (calculations, conditions)
× Comments in code (# inline comments, // or /* */ in Java) — self-documenting
code is preferred; scenario names and tag names must be expressive enough
Background:
* url baseUrl # from karate-config.js
* header Authorization = 'Bearer ' + apiKey # if auth needed
* def <domain>Model = { id: '#number', <field>: '#string', ... }
Define the model schema in Background using fuzzy matchers. Reference it in assertions:
# Definition
* def petModel = { id: '#number', name: '#string', species: '#string', age: '#number' }
# Usage — validate list items
And match each response contains petModel
# Usage — validate single item
And match response contains petModel
@error-path
Scenario: Get non-existent <domain> returns 404
Given path '/<domain>/99999'
When method get
Then status 404
@edge-case
Scenario Outline: Create <domain> with invalid <field> returns 400
* def request_body = { <field>: '<value>' }
Given path '/<domain>'
And request request_body
When method post
Then status 400
Examples:
| field | value |
| name | |
| email | notanemail |
| Principle | Application |
|---|---|
| S — Single Responsibility | One .feature per domain/resource |
| O — Open/Closed | Extend via new Scenario, never modify existing passing scenarios |
| L — Liskov | Shared schemas reusable across any scenario via def |
| I — Interface Segregation | Background exposes only what that feature needs |
| D — Dependency Inversion | Config values via karate-config.js, never hardcoded |
pet, order)examples/<domain>/<domain>.featureexamples.<domain>@smoke for critical, @regression for full coverageBackground has no steps that only one scenario needs