karate-api-testing
Skill2 starsChanged 4 months agoMITView on GitHub
API testing with Karate DSL: REST, GraphQL, gRPC, mocking, parallel execution, CI/CD integration, and data-driven tests.
- Reads credentials
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- allure-reportsSkill
- android-nativeSkill
- appian-lowcodeSkill
- appium-mobileSkill
- behave-bddSkill
- BiDiWave Cross-BrowserSkill
- BiDiWave Network InterceptionSkill
- CDPWave DebuggingSkill
- CDPWave TestingSkill
- db2-oracleSkill
- ebook-writerSkill
- flask-apiSkill
- flet-desktopSkill
- google-crawling-indexingSkill
- google-ranking-appearanceSkill
- google-seo-fundamentalsSkill
- google-seo-monitoringSkill
- jinja2-templatesSkill
- jmeter-load-testingSkill
- k6-load-testingSkill
- octane-almSkill
- paramiko-sshSkill
- postman-api-automationSkill
- prestashop-moduleSkill
- prompt-engineering-best-practicesSkill
- pytest-advancedSkill
- robot-frameworkSkill
- salesforce-devSkill
- sonarqube-quality-gatesSkill
- sql-serverSkill
- Skill NameSkill
- testcontainersSkill
- wave-ecosystem-guideSkill
- WaveXis AccessibilitySkill
- WaveXis CI/CD IntegrationSkill
- wavexis-cli-automationSkill
- wavexis-mcp-agent-integrationSkill
- WaveXis Network TestingSkill
- WaveXis Performance AuditSkill
- WaveXis Session RecordingSkill
- WaveXis Web ScrapingSkill
- webdriverioSkill
- wordpress-themesSkill
- xctest-iosSkill
The file
Files
Karate API Testing
Invoke when user asks about Karate DSL, API testing with Karate, or BDD-style API automation.
Core Principles
- DSL first: Tests are readable by non-developers.
- Zero Java required: JSON/YAML-like syntax, no compilation needed.
- Built-in: assertions, JSON/XML parsing, parallel execution, mocking.
Feature File Structure
Feature: User API
Background:
* url 'https://api.example.com'
* def token = call read('classpath:auth.js')
* header Authorization = 'Bearer ' + token
Scenario: Create and retrieve user
Given path 'users'
And request { name: 'Alice', email: 'alice@test.com' }
When method post
Then status 201
And match response ==
"""
{
id: '#number',
name: 'Alice',
email: 'alice@test.com',
createdAt: '#ignore'
}
"""
And def userId = response.id
Given path 'users', userId
When method get
Then status 200
And match response.name == 'Alice'Key Syntax Patterns
Match Operators
Then match response.name == 'Alice' # Exact
Then match response.id == '#number' # Type check
Then match response.tags == '#[]' # Array
Then match response.tags == '#[2] #' # Array of 2+ items
Then match response.status == '#present' # Non-null
Then match response.meta == '#notpresent' # AbsentDynamic Data
# JavaScript function
* def generateEmail =
"""
function() {
var uuid = java.util.UUID.randomUUID().toString();
return 'test-' + uuid + '@example.com';
}
"""
* def email = generateEmail()Data-Driven Tests
Scenario Outline: Login with <scenario>
Given path 'auth/login'
And request { email: '<email>', password: '<password>' }
When method post
Then status <status>
Examples:
| scenario | email | password | status |
| valid | alice@test.com | correct | 200 |
| wrong_pw | alice@test.com | wrong | 401 |
| missing | | | 400 |Reusable Helpers
# karate-config.js
function fn() {
var env = karate.env || 'dev';
var config = {
baseUrl: 'https:/' + '/'+ env + '.api.example.com',
timeout: 30000,
};
if (env === 'prod') {
config.token = karate.read('classpath:secrets/prod-token.txt');
}
return config;
}# common.feature
@ignore
Feature: Common Steps
Scenario: Authenticate
Given path 'auth/token'
And request { client_id: '#(clientId)', client_secret: '#(clientSecret)' }
When method post
Then status 200
And def accessToken = response.access_tokenGraphQL Testing
Feature: GraphQL Users
Scenario: Query users
Given path 'graphql'
And request
"""
{
query: "{ users(limit: 5) { id name } }"
}
"""
When method post
Then status 200
And match $.data.users == '#[_ > 0]'Mocking with Karate Netty
# Start mock server
java -jar karate.jar -m mock.feature -p 8080# mock.feature
Feature: Mock API
Scenario: pathMatches('/users') && methodIs('get')
* def response = read('classpath:fixtures/users.json')
* def status = 200CI/CD Integration
<!-- pom.xml -->
<plugin>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<goals><goal>test</goal></goals>
</execution>
</executions>
</plugin># Run all
mvn test -Dtest=KarateTest
# Run tagged
mvn test -Dkarate.options="--tags @smoke"Reporting
- Karate HTML report:
target/karate-reports/karate-summary.html - Cucumber JSON: add
cucumber-reportdependency - Allure: add
allure-cucumberadapter
Anti-Patterns
| Anti-Pattern | Fix |
| Inline large payloads | Use read('classpath:json/user.json') |
| Hardcoded IDs | Generate UUIDs or use fixtures |
| One mega-feature | Split by domain: users.feature, orders.feature |
| Ignoring response structure | Use #present / #notpresent selectively |
Example: End-to-End Flow
Feature: Order Flow
Background:
* url baseUrl
* call read('classpath:auth.feature')
Scenario: Place order end-to-end
# Create product
Given path 'products'
And request { name: 'Widget', price: 19.99 }
When method post
Then status 201
And def productId = response.id
# Add to cart
Given path 'cart'
And request { productId: '#(productId)', qty: 2 }
When method post
Then status 200
# Checkout
Given path 'orders'
And request { items: [{ productId: '#(productId)', qty: 2 }], payment: 'card' }
When method post
Then status 201
And match response.total == 39.98
And match response.status == 'confirmed'Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

