This feature is experimental. It may generate erroneous or incorrect tests, and you should review
any tests before executing or checking them in.
Why Generate Tests?
Manually writing test cases can be time-consuming and may miss important scenarios. Testpilot’s test generation capability helps by:- Creating test plans much faster than manual authoring
- Discovering edge cases you might not have considered
- Providing comprehensive coverage of your application
- Standardizing test structure and approach
- Reducing the expertise required to create quality tests
Generating Your First Test
To generate tests, use thetestpilot generate command followed by a prompt that describes what you
want to test:
- Processes your prompt using AI
- Generates a comprehensive test plan in YAML format
- Saves the test plan to a file in the current directory
generated.pilot.yaml file:
- The URL of the application you want to test
- Specific features or flows you want to test
- Any edge cases or scenarios to include
Adding Context for Better Tests
You can provide additional context to improve test generation quality using the--context flag:
- API documentation
- User flow descriptions
- Existing test examples
- Application requirements
- Known edge cases
Customizing Output Location
By default, generated tests are saved to the current directory. You can specify a different output directory:Example: Generated Test Plan
Here’s an example of a test plan generated from a prompt:Modifying Generated Tests
Testpilot generates a starting point for your tests, but you should:- Review the tests: Carefully review all generated test cases
- Edit as needed: Adjust steps to match your application’s actual behavior
- Add specificity: Make vague steps more specific when necessary
- Add assertions: Ensure there are clear verification steps
- Remove irrelevant tests: Delete test cases that don’t apply to your application
Running Generated Tests
After reviewing and adjusting the generated tests, run them with:Effective Test Generation Prompts
For the best results, create detailed, specific prompts: Basic Prompt:Best Practices for Generated Tests
- Be specific in your prompts: The more detail you provide, the better the generated tests
- Include application URLs: Always specify the URL to test in your prompt
- Provide context files: Add relevant documentation to improve generation quality
- Review before running: Always review generated tests before execution
- Customize as needed: Treat generated tests as a starting point, not the final product
- Version control: Save and version your refined test files