Test Infrastructure
Ora Browser uses Swift Testing for unit and UI tests. The test suite is organized into:- oraTests: Unit tests for core functionality
- oraUITests: UI automation and integration tests
Running Tests
In Xcode
Run the complete test suite:- Select the ora scheme
- Press ⌘U or choose Product → Test
- Click the diamond icon next to any test function
- Right-click a test and select “Run Test”
Tests run in the Debug configuration by default. You can view test results in the Test Navigator (⌘6).
From Command Line
Run all tests via xcodebuild:Pre-Push Testing
Tests are automatically run before pushing to ensure code quality:lefthook.yml
Writing Tests
Unit Tests
Ora uses Swift Testing framework for writing tests:oraTests/oraTests.swift
Test Structure
Follow this pattern for unit tests:UI Tests
UI tests verify the user interface and interactions:oraUITests/oraUITests.swift
Test Guidelines
When to Write Tests
New features
All new features should include appropriate unit tests covering:
- Happy path functionality
- Edge cases and error handling
- Invalid input scenarios
Bug fixes
When fixing bugs:
- Write a failing test that reproduces the bug
- Fix the bug
- Verify the test passes
Test Requirements
Before submitting a pull request:- All tests pass
- Code builds without warnings
- New functionality includes tests
- Tests are well-documented
- No flaky or intermittent failures
Test Organization
Directory Structure
Test Target Configuration
Tests are configured inproject.yml:
Continuous Integration
Local Validation
Before pushing code, ensure your changes pass local validation:Git Hooks
Git hooks automatically enforce quality checks:Testing Best Practices
Keep Tests Fast
- Unit tests should run in milliseconds
- Avoid network calls in unit tests
- Use mocks for external dependencies
- Keep UI tests focused and minimal
Write Meaningful Tests
Test One Thing at a Time
Use Descriptive Assertions
Debugging Tests
Test Failures
When a test fails:- Read the failure message: Swift Testing provides detailed error context
- Run the test in isolation: Focus on the failing test
- Use breakpoints: Add breakpoints in the test and implementation
- Check test data: Verify test inputs and expected outputs
Debugging in Xcode
Console Output
Add logging to understand test execution:Performance Testing
Measuring Performance
Test launch performance:Performance Baselines
- Run performance tests multiple times
- Xcode will establish a baseline
- Future runs compare against the baseline
- Investigate significant regressions
Troubleshooting
Tests Not Running
- Ensure test target is selected in scheme
- Clean build folder (⇧⌘K)
- Reset test data: Product → Test → Delete Test Data
Flaky Tests
- Add waits for asynchronous operations
- Avoid hardcoded timeouts
- Use XCTest expectations for async code
Build Failures
If tests fail to build:Next Steps
Building
Learn how to build Ora Browser for development
Releases
Understand the release and distribution process
