Testing Documentation
Complete guide to the automated testing system and how to extend it
The automated testing system is designed to catch errors before they reach production, ensure system stability, and provide confidence when making changes to the codebase.
Backend Tests
Verify entities, database operations, and backend functions
Integration Tests
Check that different parts of the system work together correctly
E2E Tests
Simulate complete user flows from start to finish
BackendBackend Tests
- All Entities Accessibility: Verifies that all critical entities (Project, Feedback, Payment, etc.) are accessible and can be queried
- Project Status Workflow: Checks that all project statuses are working correctly including new states like waiting_requester_validation
- Critical Functions Availability: Ensures all essential backend functions are available
IntegrationIntegration Tests
- Notification System: Tests notification creation, retrieval, and deletion
- Project-Feedback Relationship: Verifies that projects and feedback are properly linked
E2EEnd-to-End Tests
- Complete Project Lifecycle: Simulates the entire project flow from creation to completion
- Discovery Call Workflow: Tests the complete discovery call flow including expert and requester confirmations
Adding a Backend Test
try {
const testStart = Date.now();
// Your test logic here
const result = await base44.asServiceRole.entities.YourEntity.list();
allTests.push({
category: 'Backend',
name: 'Your Test Name',
status: 'passed',
message: 'Test passed successfully',
details: 'Any relevant details',
duration: Date.now() - testStart
});
passed++;
} catch (error) {
allTests.push({
category: 'Backend',
name: 'Your Test Name',
status: 'failed',
message: 'Test failed',
error: error.message
});
failed++;
}Adding an E2E Test
try {
const testStart = Date.now();
const steps = [];
// Step 1: Setup
const testData = await base44.asServiceRole.entities.Entity.create({...});
steps.push('✓ Setup complete');
// Step 2: Action
await someAction(testData.id);
steps.push('✓ Action performed');
// Step 3: Verify
const result = await base44.asServiceRole.entities.Entity.get(testData.id);
steps.push('✓ Verification passed');
// Cleanup
await base44.asServiceRole.entities.Entity.delete(testData.id);
allTests.push({
category: 'E2E',
name: 'Your E2E Test',
status: 'passed',
message: 'Flow completed successfully',
details: steps.join('\n'),
duration: Date.now() - testStart
});
passed++;
} catch (error) {
// Handle failure...
}Large Language Models (LLMs) like me can significantly accelerate test development and maintenance:
Automatic Test Generation
When you add a new feature, describe it to an LLM and it can generate comprehensive test cases covering edge cases you might not have considered
Test Maintenance
When code changes, LLMs can analyze the changes and automatically update affected tests, ensuring they remain relevant
Coverage Analysis
LLMs can review your codebase and identify areas with low test coverage, then suggest specific tests to fill those gaps
Bug Regression Tests
When a bug is found, describe it to an LLM and it will generate a test that reproduces the bug, ensuring it never happens again
Workflow Example
- You: "I just added a feature that allows experts to negotiate project prices"
- LLM: Analyzes the feature and generates 5-10 test scenarios
- LLM: Creates test code for each scenario (happy path, edge cases, errors)
- You: Review and approve the tests
- LLM: Integrates tests into the test suite
- Tests run automatically on every deployment
- Test After Every Bug Fix: When you fix a bug, immediately write a test that would have caught it
- Test Critical Paths First: Focus on flows that would cause the most damage if broken (payment, project creation, expert workflow)
- Keep Tests Independent: Each test should be able to run independently and clean up after itself
- Run Tests Regularly: Run the full test suite at least daily, and critical tests before every deployment
- Document Test Intent: Make test names and messages clear so anyone can understand what's being tested
