Skip to content

Testing Workflow

Comprehensive testing strategies using AI assistance for unit tests, integration tests, end-to-end tests, performance testing, and test automation across different frameworks and languages.

  • Rawi configured with a suitable provider
  • Testing framework setup (Jest, Mocha, Pytest, etc.)
  • Project codebase to test
  • Basic understanding of testing principles

Plan comprehensive testing approach:

Terminal window
# Generate test strategy
rawi ask --act test-engineer "Create a comprehensive testing strategy for a Node.js e-commerce API including unit, integration, and e2e tests"
# Test case generation
rawi ask --file src/components/UserProfile.tsx --act test-engineer "Generate comprehensive test cases for this React component"
# Test pyramid analysis
rawi ask --batch "src/**/*.js" --act test-engineer "Analyze codebase and recommend optimal test pyramid strategy"

Create comprehensive unit tests:

Terminal window
# Generate JavaScript/TypeScript unit tests
rawi ask --file src/utils/validation.js --act test-engineer "Create comprehensive Jest unit tests with edge cases and mocks"
# Generate Python unit tests
rawi ask --file src/models.py --act test-engineer "Create pytest unit tests with fixtures and parameterization"
# Generate React component tests
rawi ask --file src/components/Button.tsx --act test-engineer "Create React Testing Library tests with accessibility checks"

Generate and execute testing commands:

Terminal window
# Run specific test suites
rawi exec "run all unit tests for authentication module"
rawi exec "run integration tests with coverage report"
rawi exec "execute end-to-end tests in headless mode"
# Test setup and configuration
rawi exec "install Jest and testing dependencies for React project"
rawi exec "configure Cypress for e2e testing"
rawi exec "set up test database for integration tests"
# Test execution with different configurations
rawi exec "run tests in watch mode for development"
rawi exec "run tests with verbose output and coverage"
rawi exec "execute tests in CI environment with XML output"

Create integration test suites:

Terminal window
# API integration tests
rawi ask --file src/routes/users.js --act test-engineer "Create supertest integration tests for these API endpoints"
# Database integration tests
rawi ask --file src/models/User.js --act test-engineer "Create database integration tests with test data setup and cleanup"
# Service integration tests
rawi ask --file src/services/emailService.js --act test-engineer "Create integration tests with external service mocking"

Create comprehensive e2e test suites:

Terminal window
# Playwright e2e tests
rawi ask --act test-engineer "Create Playwright e2e tests for user authentication flow including login, registration, and password reset"
# Cypress e2e tests
rawi ask --act test-engineer "Create Cypress e2e tests for e-commerce checkout flow with payment processing"
# Selenium tests
rawi ask --act test-engineer "Create Selenium WebDriver tests for cross-browser compatibility testing"
  • Follow AAA pattern (Arrange, Act, Assert)
  • Use descriptive test names
  • Keep tests independent and isolated
  • Use proper test data management
  • Implement proper setup and teardown
  • Aim for high code coverage (80%+)
  • Focus on critical business logic
  • Test edge cases and error conditions
  • Include positive and negative scenarios
  • Test performance requirements
  • Keep tests simple and focused
  • Update tests with code changes
  • Remove obsolete tests
  • Refactor duplicate test code
  • Document complex test scenarios
  • Optimize test execution time
  • Use parallel execution when possible
  • Minimize external dependencies
  • Use efficient test data
  • Monitor test suite performance
.github/workflows/comprehensive-testing.yml
name: Comprehensive Testing
on:
push:
branches: [main, develop]
pull_request:
jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16, 18, 20]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test:unit
- run: npm run test:coverage
integration-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run test:integration
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test
e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npx playwright install
- run: npm run build
- run: npm run test:e2e
performance-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run test:performance
- name: Upload performance results
uses: actions/upload-artifact@v3
with:
name: performance-results
path: performance-results/
security-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm audit
- run: npm run test:security