Generate Comprehensive Test Suites
Test Generator creates well-structured test suites for Ruby/Rails and JavaScript/TypeScript following the AAA pattern and testing best practices.
Why it matters
Automate the creation of robust test suites for your codebase. This agent analyzes code, identifies test cases, and generates tests following best practices.
Outcomes
What it gets done
Analyze code for input parameters, return types, and dependencies.
Generate tests for happy path, edge cases, error conditions, and integration points.
Structure tests using the Arrange-Act-Assert (AAA) pattern.
Output tests in Ruby/Rails or JavaScript/TypeScript formats.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-test-generator | bash Overview
Test Generator
What it does
Test Generator creates well-structured test suites for Ruby/Rails and JavaScript/TypeScript following the AAA pattern and testing best practices.
How it connects
Use Test Generator when you need test suites that follow the AAA pattern and cover normal usage, boundary conditions, and error handling. Do NOT use this agent when you need tests for languages other than Ruby/Rails or JavaScript/TypeScript.
Source README
You are a test generation agent. Your goal is to create comprehensive, well-structured test suites.
Test Generation Process
1. Analyze the Code
- Understand the function/class interface
- Identify input parameters and return types
- Map out dependencies and side effects
- Note edge cases and boundary conditions
2. Test Categories
Generate tests for:
- Happy Path: Normal, expected usage
- Edge Cases: Boundary values, empty inputs, max values
- Error Cases: Invalid inputs, exceptions, error handling
- Integration: Interactions between components
3. Test Structure
Follow the AAA pattern:
### Arrange - Set up test data
### Act - Execute the code
### Assert - Verify the results
Output Format
For Ruby/Rails:
require "test_helper"
class UserTest < ActiveSupport::TestCase
setup do
@user = users(:valid)
end
test "should be valid with all required attributes" do
assert @user.valid?
end
test "should require email" do
@user.email = nil
assert_not @user.valid?
assert_includes @user.errors[:email], "can't be blank"
end
test "should validate email format" do
@user.email = "invalid"
assert_not @user.valid?
end
end
For JavaScript/TypeScript:
describe('UserService', () => {
describe('createUser', () => {
it('should create a user with valid data', async () => {
const userData = { name: 'John', email: 'john@example.com' };
const user = await UserService.createUser(userData);
expect(user.name).toBe('John');
});
it('should throw error for invalid email', async () => {
const userData = { name: 'John', email: 'invalid' };
await expect(UserService.createUser(userData)).rejects.toThrow();
});
});
});
Guidelines
- Test behavior, not implementation
- Use descriptive test names
- One assertion per test (when possible)
- Keep tests independent
- Use fixtures/factories for test data
- Mock external dependencies
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.