Add Android unit and UI tests with test dependencies
This commit is contained in:
@@ -10,6 +10,7 @@ Android client for the BikeSetup backend. Built with Kotlin, Jetpack Compose, an
|
||||
- **DI**: Koin
|
||||
- **Networking**: Ktor client (OkHttp engine) with automatic cookie jar for session auth
|
||||
- **Serialization**: Kotlinx Serialization
|
||||
- **Testing**: JUnit, MockK, coroutine test utilities, Robolectric, Compose UI test APIs
|
||||
|
||||
## Project Structure
|
||||
|
||||
@@ -58,6 +59,11 @@ com.bikeloam.app/
|
||||
./gradlew installDebug
|
||||
```
|
||||
|
||||
6. Run JVM unit tests:
|
||||
```bash
|
||||
./gradlew testDebugUnitTest
|
||||
```
|
||||
|
||||
## API Configuration
|
||||
|
||||
The debug build points to `http://10.0.2.2:3000` (emulator localhost). For a physical device, update `BASE_URL` in `app/build.gradle.kts` to your machine's LAN IP (e.g., `http://192.168.1.x:3000`).
|
||||
@@ -75,6 +81,30 @@ buildConfigField("String", "BASE_URL", "\"http://YOUR_IP:3000\"")
|
||||
- **Ride Reviews**: Submit post-ride reviews with 1–10 sliders and issue checkboxes.
|
||||
- **AI Recommendations**: Fetches setup recommendations from `/api/ai/recommend`.
|
||||
|
||||
## Tests
|
||||
|
||||
Unit tests live under `app/src/test/java/com/bikeloam/app/` and cover the repository, all ViewModels, network layer, and Compose screens:
|
||||
|
||||
- `BikeRepositoryTest`
|
||||
- `NetworkClientTest`
|
||||
- `SplashViewModelTest`
|
||||
- `LoginViewModelTest`
|
||||
- `RegisterViewModelTest`
|
||||
- `HomeViewModelTest`
|
||||
- `BuildListViewModelTest`
|
||||
- `CreateBuildViewModelTest`
|
||||
- `BuildDetailViewModelTest`
|
||||
- `ReviewViewModelTest`
|
||||
- `RecommendationViewModelTest`
|
||||
- `LoginScreenTest` (Compose UI – Robolectric)
|
||||
- `HomeScreenTest` (Compose UI – Robolectric)
|
||||
|
||||
Use `MainDispatcherRule` for coroutine dispatcher replacement in ViewModel tests. Run the full JVM suite with:
|
||||
|
||||
```bash
|
||||
./gradlew testDebugUnitTest
|
||||
```
|
||||
|
||||
## Architecture Notes
|
||||
|
||||
- **Session cookies** are handled automatically by Ktor's `HttpCookies` plugin.
|
||||
|
||||
Reference in New Issue
Block a user