Skip to main content
The Test Authoring Agent is a Requestly-integrated AI agent that authors executable Post-response test scripts directly from real API request and response data. It removes repetitive, error-prone manual work and helps engineers and QA teams validate API behavior faster with consistent coverage. Simply describe what you want to validate in plain English. The agent analyzes your latest API response and produces ready-to-run test cases for your current request.
Note: The Test Authoring Agent is available only on Pro plans and above.

Getting Started with AI Test Cases Generator

1

Send Your API Request

The Test Authoring Agent requires an actual API response to understand structure, values, and risk areas.Test Authoring Agent Send Request Firsttogeneratetestsfromitsresponse 1
  1. Open any request in the API Client
  2. Click the Send button to execute the request
  3. Wait for the response to be received
2

Once you have a response

Once the response is available:
  1. Navigate to the Scripts section
  2. Open the Post-response tab
  3. Click Generate Tests
This enables the Update with AI button.Test Authoring Agent AI Test Generatordialog
3

Enter Natural Language Instructions

Describe what the tests should validate using plain English. The agent understands API context, response payloads, and common testing patterns.Test Authoring Agent GeneratetestcasesExample instructions
  • “Generate test cases”
  • “Test that status is 200 and success is true”
  • “Ensure the response has id, name, and email fields”
  • “Validate pagination fields like page, limit, and total”
  • “Check that items array is not empty”
  • “Verify all timestamps are valid ISO 8601 dates”
  • “Add schema validation for the response”
  • “Test missing required fields”
Click Generate to continue.
4

Review the Output

The Test Authoring Agent presents the generated output in a git-style diff view:
  • Green lines show new tests that will be added
  • Red lines show tests that will be removed
  • Unchanged lines remain neutral
This human-in-the-loop review ensures full control before any script changes are applied.Test Authoring Agent Reviewthe Output(2)
5

Accept, Edit, or Discard

After reviewing the diff, you can:
  • Accept to replace the full Post-response script with the generated tests
  • Edit prompt to refine your prompt and regenerate tests
  • Close to discard all changes and keep the existing script
Accepted tests are saved immediately and are ready to run.

What the Test Authoring Agent Creates

The agent authors structured, runnable API test cases using:
  • rq.test blocks for clear test intent
  • Chai-based assertions via rq.response and rq.expect
  • Field-level, schema-level, and behavior-based validations
All generated tests are compatible with the Collection Runner and CI workflows.

What the Test Authoring Agent Creates

The agent creates comprehensive test scripts using Requestly’s rq.test and rq.expect APIs with Chai.js assertions.

Example Generated Tests

For a user API endpoint returning:
{
  "status": 200,
  "success": true,
  "data": {
    "id": 123,
    "name": "John Doe",
    "email": "[email protected]",
    "role": "admin"
  }
}
With instruction: “Test that status is 200, success is true, and user object has required fields” The AI generates:
rq.test("Status code is 200", () => {
  rq.response.to.have.status(200);
});

rq.test("Response is valid JSON", () => {
  rq.response.to.have.jsonBody();
});

rq.test("Success field is true", () => {
  rq.response.to.have.jsonBody("success", true);
});

rq.test("User data object has required fields (id, name, email, role)", () => {
  rq.response.to.have.jsonBody("data.id");
  rq.response.to.have.jsonBody("data.name");
  rq.response.to.have.jsonBody("data.email");
  rq.response.to.have.jsonBody("data.role");
});

Advanced Test Scenarios

The AI Test Generator can handle complex scenarios:

Schema Validation

Instruction: “Validate the entire response structure against a schema” Generates schema validation tests that ensure the response conforms to the expected data structure.
rq.test("Response has valid schema", () => {
  rq.response.to.have.jsonSchema({
    type: "object",
    required: ["status", "success", "data"],
    properties: {
      status: { type: "number" },
      success: { type: "boolean" },
      data: { type: "object" }
    }
  });
});

Tips for Better AI-Generated Tests

  1. Be Specific: Clearly state what you want to test. Instead of “test the response,” say “test that status is 200 and email is a valid email address”
  2. Reference Field Names: Mention specific fields you want validated. The AI understands JSON paths like “user.email” or “data.items[0].status”
  3. Use Examples: Phrases like “similar to POST requests” or “like production data” help the AI understand context
  4. Combine Multiple Concerns: You can ask for multiple validations in one instruction: “Validate status is 200, success is true, and items array is not empty”
  5. Iterative Refinement: Use the “Edit Instruction” feature to progressively enhance your tests

Current Limitations

  • AI Test Generator currently generates Post-response scripts only
  • Requires an actual API response to analyze.
  • Best results when the response has a well-structured JSON format

Combining AI-Generated and Manual Tests

You don’t need to rely entirely on AI-generated tests. You can:
  1. Start with AI: Let the AI generate basic validation tests
  2. Add Custom Logic: Manually add additional test cases or pre-request scripts
  3. Refine Iteratively: Use the Edit Instruction feature to improve generated tests over time
  4. Mix Approaches: Combine AI-generated assertions with custom JavaScript logic

Running and Debugging Tests

After accepting the AI-generated tests, you can:
  • Run Tests: Click the Send button again to execute the request and run all tests
  • View Results: Check the test results in the Test Results panel
  • Debug: Use console.log() in the script to debug test execution
  • Modify: Edit the generated code directly if you need fine-grained control
See Writing Tests for more information about executing and debugging tests.
  • Writing Tests - Learn about manual test writing and all available assertion methods
  • Scripts - Understand Pre-request and Post-response scripts
  • Collection Runner - Run multiple requests and tests in sequence
  • RQ API Reference - Full documentation of the rq object and its methods