-
Notifications
You must be signed in to change notification settings - Fork 0
Question Generation
The application can automatically generate test cases from uploaded documents using AI or a rule-based fallback.
| Mode | Description | Requirement |
|---|---|---|
| AI-Powered | Uses an Azure OpenAI (or OpenAI-compatible) LLM to understand document context and produce high-quality, diverse questions | Azure OpenAI endpoint and API key |
| Rule-Based | Extracts key sentences from document chunks and wraps them in question starters | None — always available as fallback |
- Document chunks are collected and concatenated (truncated to ~12 000 characters to stay within model context limits)
- A structured prompt asks the model to generate N questions covering:
- Direct factual questions (What/When/Where)
- Conceptual understanding (How/Why)
- Comparison and contrast
- Application and troubleshooting
- Edge cases
- Each question includes:
- Question text
- Expected answer — a concise, accurate answer from the documents
- Expected intent — the user's goal
- Expected entities — key terms or concepts
- Questions are returned as a typed list and imported as test cases
Enable AI generation in the Setup Wizard (Step 1) or in the global/per-agent settings:
{
"QuestionGeneration": {
"Endpoint": "https://your-resource.openai.azure.com/",
"ApiKey": "<env-var>",
"Model": "gpt-4o-mini"
}
}Environment variables:
QUESTIONGENERATION__ENDPOINT=https://your-resource.openai.azure.com/
QUESTIONGENERATION__APIKEY=<api-key>
QUESTIONGENERATION__MODEL=gpt-4o-mini
| Model | Cost per generation batch (5–10 questions) |
|---|---|
| gpt-4o-mini | ~$0.001–$0.002 |
| gpt-4o | ~$0.02–$0.04 |
When no AI endpoint is configured, the rule-based generator:
- Randomly samples document chunks
- Extracts sentences meeting minimum length thresholds
- Wraps each sentence in one of several question starters:
- "What can you tell me about…"
- "Can you explain…"
- "Tell me about…"
- "How does…"
- etc.
- Sets the source sentence as the expected answer reference
This produces functional (but less contextually rich) test cases without requiring any API access.
- Upload documents in Step 2
- In Step 3, set the number of questions (5–50)
- Click Generate Questions
- Review, select, or deselect individual questions
- Add custom questions manually with the Add Custom button
- Proceed to Step 4 to create the test suite
- Navigate to Documents
- Click Generate Questions on a document
- Select questions and add to an existing test suite
Use the generate command to create test cases from a local file entirely from the terminal:
# Preview generated questions without saving
testrunner generate --document ./docs/product-manual.txt --count 10
# Generate and save directly into a suite
testrunner generate --document ./docs/product-manual.txt --suite "Regression Tests" --count 20See CLI Reference for the full option reference.
For each generated question you can:
- ✅ Select/deselect it for inclusion
- ✏️ Edit the question text or expected answer before saving
- ➕ Add a custom question at any time
- 🔄 Regenerate a completely new set
The question-generation system prompt can now be customised directly in the UI — no code changes required.
- Navigate to Settings → AI Question Gen
- Scroll to the System Prompt field
- Click Load default to edit to load the built-in prompt into the textarea
- Edit as needed and click Save
- Leave the field empty to revert to the built-in default at any time (click Revert to built-in)
The global prompt applies to all question-generation calls unless a per-agent override is set.
- Navigate to Agents → create or edit an agent
- In the Question Generation section, uncheck Use global question generation settings
- Use the System Prompt Override field — click Load default to edit to start from the built-in template
- Save the agent
Prompt resolution order:
Agent-level system prompt
│ (if set)
└── Global system prompt (Settings → AI Question Gen)
│ (if set)
└── Built-in hardcoded default
To adjust question type distribution, add to the prompt:
Generate questions with this distribution:
- 40% factual recall
- 30% conceptual understanding
- 20% application/troubleshooting
- 10% edge cases
To include domain-specific context:
Domain: Customer support for a SaaS product
Focus on subscription management, billing, and onboarding workflows.
The {domainContext} placeholder in the built-in prompt is automatically replaced at generation time with the agent or suite name — you do not need to add it manually.
| Issue | Likely Cause | Fix |
|---|---|---|
| "Failed to parse response" | Wrong model deployment name | Check model name matches the deployment in Azure |
| 401 Unauthorized | Invalid API key | Regenerate key in Azure portal |
| 429 Rate limit | Too many requests | Wait a few seconds and retry |
| No questions generated | Document too short | Upload a longer document (≥ 500 words recommended) |
| Poor question quality | Generic prompt | Add domain context in Setup Wizard agent name |
- Document Processing — upload and chunk documents
- Setup Wizard — integrated generation during wizard
- Test Suites and Cases — using generated questions as test cases