This branch is dedicated to comprehensive testing of the Nimbus Android weather application.
The Nimbus project employs a robust testing strategy using:
| Framework | Purpose |
|---|---|
| JUnit4 | Core testing framework |
| Mockito | Mocking dependencies |
| Parameterized | Testing multiple scenarios efficiently |
Tests are neatly organized in the app/src/test directory, following the same package structure as
the main codebase for easy navigation and maintenance.
Tests for utility classes ensuring core functionality works as expected
- ⏰ DateTimeUtil: Time zone handling, date formatting and parsing
- 🌡️ Temperature Conversion: Celsius, Fahrenheit, and Kelvin conversions
- 💨 Wind Speed Conversion: Conversions between different units
- 🔄 Pressure Conversion: Atmospheric pressure unit handling
Tests ensuring UI logic and state management work correctly
- 🏠 HomeViewModel: Weather display and user interactions
- 📅 DailyWeatherViewModel: Forecast data presentation
- 🔄 State Management: LiveData updates and UI state transitions
- 🖱️ Event Handling: User input processing
Tests for data layer components
- ☁️ TomorrowIoRepository: Weather data retrieval and management
- 💾 Caching Mechanisms: Local data storage strategies
- 🔄 Data Transformation: Converting raw data to domain models
Tests for API integration and data fetching
- 📊 Response Parsing: Converting JSON to model objects
- ❌ Error Handling: Network failure scenarios
- 📨 Request Formatting: API request construction
Tests for user settings management
- 💾 Settings Persistence: Storage of user preferences
- 🔄 Preference Management: Retrieval and updates
Android instrumentation tests for background operations
- ⏱️ WorkManager Integration: Scheduled task execution
- 🔙 Background Processing: Operations when app is not in foreground
- 💉 Dependency Injection: Component wiring with workers
Run all unit tests:
./gradlew testRun a specific test class:
./gradlew testDebugUnitTest --tests com.optlab.nimbus.utility.DateTimeUtilTestRun instrumentation tests:
./gradlew connectedAndroidTestGenerate detailed test coverage reports:
./gradlew testDebugUnitTestCoverageReports will be available at: app/build/reports/coverage/
| # | Guideline |
|---|---|
| 1 | Each test should focus on a single functionality |
| 2 | Use descriptive naming conventions that indicate what's being tested |
| 3 | Follow the AAA pattern: Arrange-Act-Assert |
| 4 | Mock dependencies to isolate the unit being tested |
| 5 | Use parameterized tests for multiple inputs with the same logic |