examples/config-tests-per-prompt/README.md
This example demonstrates how to run specific tests only with specific prompts using the test-level prompts field.
By default, promptfoo runs each test against all prompts (a cartesian product). The prompts field on test cases lets you break this pattern and associate specific tests with specific prompts.
npx promptfoo@latest init --example config-tests-per-prompt
npx promptfoo@latest eval
Math:* matches Math:Basic, Math:AdvancedThe example uses the echo provider for demonstration. In production, replace with your preferred LLM provider.
prompts:
- id: factual
label: Factual Assistant
raw: 'You are factual. Answer: {{question}}'
- id: creative
label: Creative Writer
raw: 'Be creative. Answer: {{question}}'
tests:
- vars:
question: 'What is 2+2?'
prompts:
- Factual Assistant # Only runs with this prompt
assert:
- type: contains
value: '4'
See the Filtering Tests by Prompt documentation for more details.