Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
The LuCI Mobile testing strategy encompasses automated and manual verification layers to ensure the reliability of the Flutter-based OpenWrt management client. This strategy validates core application logic, API communication with LuCI RPC, and cross-platform UI consistency.
Sources: CONTRIBUTING.md:179-204, README.md:14-43
Static Analysis and Linting
The project enforces code quality through strict static analysis. The analysis_options.yaml file defines a phased approach for adopting lint rules, prioritizing resource management and security.
- Critical Rules: Focus on memory safety by enforcing the closure of sinks and cancellation of subscriptions.
- Error Handling: Requires addressing unawaited futures and avoiding generic error catching to improve stability.
- Automation: The CI/CD pipeline runs
flutter analyze --fatal-infosto prevent code with warnings or info-level issues from being merged.
Sources: analysis_options.yaml:31-64, CONTRIBUTING.md:68-71
Automated Testing Levels
The repository utilizes multiple automated test types to verify different scopes of the application.
Unit Testing
Unit tests target individual functions and classes. These tests use meaningful names and mock external dependencies to isolate the logic being verified.
Sources: CONTRIBUTING.md:181-186
Integration Testing
Integration tests verify complex workflows and external communication. These tests focus on:
- API communication with the router's LuCI RPC interface.
- Authentication flows and credential storage.
- Error handling under various network conditions.
Sources: CONTRIBUTING.md:188-193
Platform-Specific Testing
The project includes support for native platform tests, such as XCTest for iOS, to validate native integrations if required.
Sources: ios/RunnerTests/RunnerTests.swift:5-11
Testing with Mock Data
The application includes a comprehensive set of mock data to facilitate testing without a physical router. These JSON files represent typical LuCI RPC responses for system, network, and firewall configurations.
| Mock File | Content Description |
|---|---|
uci_system.json | System hostname, timezone, and NTP server configurations. |
uci_firewall.json | Firewall zones, defaults, and traffic rules. |
dhcp_leases.json | Active DHCP lease list with MAC and IP mappings. |
interface_dump.json | Network interface status (wan, lan, guest). |
Sources: pubspec.yaml:81-83, assets/mock/uci_system.json:1-26, assets/mock/uci_firewall.json:1-55
Manual Testing and Environment Setup
Manual verification is required for UI/UX validation and real-world network scenarios. Contributors are encouraged to test on different devices and router configurations.
- Device Testing: Running the app on physical Android or iOS devices.
- Router Testing: Connecting to an OpenWrt router with
rpcd-mod-luciandrpcd-mod-iwinfoinstalled. - Scenario Testing: Verifying the "apply-with-rollback" protocol and handling self-signed HTTPS certificates.
The following flowchart describes the typical developer testing workflow:
Test Execution Commands
Developers utilize the Flutter CLI to execute the test suite.
# Run all automated tests
flutter test
# Run a specific test file
flutter test test/widget_test.dart
# Run tests with a coverage report
flutter test --coverage
# Perform static analysis
flutter analyze
Sources: CONTRIBUTING.md:113-120, CONTRIBUTING.md:198-204
Summary
The LuCI Mobile testing strategy combines strict static analysis, multi-level automated testing, and robust mock data to maintain a high-quality codebase. By integrating these checks into the CI/CD pipeline and local development workflows, the project ensures that router management features remain secure and reliable across diverse OpenWrt environments.