Skip to main content
coding intermediate

Write Comprehensive Integration Tests

Generate thorough integration tests for your applications with this detailed AI prompt. Perfect for testing APIs, databases, and system interactions.

Works with: chatgptclaudegemini

Prompt Template

Act as a senior software testing engineer and write comprehensive integration tests for the following system. Your tests should verify that different components work together correctly and handle real-world scenarios. **System Details:** - Application type: [APPLICATION_TYPE] - Technology stack: [TECH_STACK] - Components to test: [COMPONENTS] - Integration points: [INTEGRATION_POINTS] **Requirements:** 1. Create test cases that verify end-to-end functionality 2. Include both positive and negative test scenarios 3. Test data flow between components 4. Verify error handling and edge cases 5. Include setup and teardown procedures 6. Add assertions that validate expected behavior 7. Consider performance and reliability aspects **Test Structure:** For each test, provide: - Test name and description - Prerequisites and test data setup - Step-by-step test execution - Expected results and assertions - Cleanup procedures **Additional Context:** - Testing framework: [TESTING_FRAMEWORK] - Environment: [ENVIRONMENT] - Specific scenarios to cover: [SPECIFIC_SCENARIOS] Focus on realistic, maintainable tests that would catch integration issues in production. Include code examples where appropriate and explain the reasoning behind each test case.

Variables to Customize

[APPLICATION_TYPE]

The type of application being tested

Example: E-commerce REST API with microservices architecture

[TECH_STACK]

Programming languages and frameworks used

Example: Node.js, Express, PostgreSQL, Redis, Docker

[COMPONENTS]

Specific components or modules to test

Example: User service, Payment service, Inventory service, Notification service

[INTEGRATION_POINTS]

Where different systems or components interact

Example: Database connections, external payment APIs, message queues, file uploads

[TESTING_FRAMEWORK]

The testing framework or tools to use

Example: Jest with Supertest for API testing

[ENVIRONMENT]

Testing environment details

Example: Docker containers with test database and mock external services

[SPECIFIC_SCENARIOS]

Particular use cases or edge cases to focus on

Example: Payment failures, concurrent user orders, inventory depletion scenarios

Example Output

## Integration Tests for E-commerce Payment Flow ### Test 1: Complete Order Processing **Description:** Verify end-to-end order creation, payment processing, and inventory update ```javascript describe('Order Processing Integration', () => { beforeEach(async () => { await setupTestDatabase(); await seedTestData(); }); test('should process complete order successfully', async () => { const orderData = { userId: 'test-user-123', items: [{ productId: 'prod-456', quantity: 2 }], paymentMethod: 'credit_card' }; const response = await request(app) .post('/api/orders') .send(orderData) .expect(201); // Verify order creation expect(response.body.orderId).toBeDefined(); expect(response.body.status).toBe('confirmed'); // Verify inventory reduction const inventory = await getInventory('prod-456'); expect(inventory.quantity).toBe(8); // 10 - 2 // Verify payment record const payment = await getPayment(response.body.paymentId); expect(payment.status).toBe('completed'); }); afterEach(async () => { await cleanupTestDatabase(); }); }); ``` ### Test 2: Payment Failure Handling **Description:** Ensure order rollback when payment fails This test verifies that when payment processing fails, inventory is restored and order status is updated appropriately.

Pro Tips for Best Results

  • Start with happy path scenarios before adding edge cases and error conditions
  • Use test databases or containers to ensure tests don't affect production data
  • Mock external services that are unreliable or expensive to call during testing
  • Include realistic test data that mirrors production scenarios
  • Add timing assertions for performance-critical integration points

Tags

Want 500+ Expert Prompts?

Get the Premium Prompt Pack — organized, tested, and ready to use.

Get it for $29

Related Prompts You Might Like