Testing & QA Strategy
RideEase utilizes a multi-layered testing strategy to ensure application stability, data integrity, and a seamless user experience. The strategy encompasses local unit tests for business logic and instrumented tests for UI/UX verification.
Testing Overview
The RideEase testing framework is divided into two primary categories:
- Unit Tests (JUnit): Focus on validating the core logic within ViewModels and Utility classes. These tests run on the JVM and do not require an Android device.
- Instrumented Tests (Espresso): Focus on end-to-end user flows and UI component behavior. These tests run on physical devices or emulators to interact with the Android OS.
Unit Testing with JUnit
Unit tests in RideEase target the "Business Logic" layer, primarily focusing on AuthViewModel, UserDetailsViewModel, and AuthUtils.
Logic Validation
Viewmodels contain critical validation logic for user inputs. Testing ensures that edge cases (e.g., incorrect phone formats or mismatched passwords) are handled before reaching the Firebase backend.
Key areas for Unit Testing:
- Email Validation: Ensuring standard patterns for email addresses are enforced.
- Phone Formatting: Verifying the
COUNTRY_CODE_PATTERNandPHONE_NUMBER_PATTERNlogic. - User Type Logic: Ensuring the distinction between "Rider" and "Driver" roles is maintained during sign-up and sign-in.
Usage Example: Testing Validation Logic
// Example of logic that is unit-tested in AuthViewModel
public void testPhoneValidation() {
String validPhone = "9876543210";
String invalidPhone = "123";
assertTrue(PHONE_NUMBER_PATTERN.matcher(validPhone).matches());
assertFalse(PHONE_NUMBER_PATTERN.matcher(invalidPhone).matches());
}
Instrumented Testing with Espresso
Instrumented tests verify that the UI components correctly reflect the application state and respond to user interactions. These tests utilize the androidx.test libraries.
UI & Flow Testing
Espresso is used to automate user interactions within activities like LoginActivity and SignupActivity.
Common Test Scenarios:
- Login Flow: Entering credentials, clicking the "Login" button, and verifying the transition to the
MainActivity. - Form Errors: Triggering
TextInputLayouterrors by submitting empty fields and verifying the error message text. - Loading States: Ensuring the
LottieAnimationView(loading spinner) becomes visible during asynchronous Firebase operations. - Navigation: Verifying that the
SplashActivitycorrectly routes the user based on their authentication status.
Usage Example: Activity Instrumentation
@Test
public void loginWithEmptyFields_showsError() {
// Launch LoginActivity
ActivityScenario.launch(LoginActivity.class);
// Click login button without entering data
onView(withId(R.id.loginButton)).perform(click());
// Check if error is displayed on the email layout
onView(withId(R.id.emailLayout))
.check(matches(hasDescendant(withText("Enter your email"))));
}
QA Strategy & Test Scenarios
Beyond automated scripts, the following QA scenarios are used to manually and programmatically verify the app's robustness:
1. Authentication Scenarios
| Scenario | Expected Behavior |
| :--- | :--- |
| New User Sign-up | User document created in Firestore with detailsSubmitted: false. |
| Profile Completion | Phone number and Full Name stored; user redirected to MainActivity. |
| User Type Mismatch | Rider attempting to log in as Driver should receive "Wrong category selected" error. |
| Verification Check | Unverified email users must be blocked from accessing the main app. |
2. Session Management
- Persistence: Verify that
SplashActivityskips the login screen ifisLoggedInis true inSharedPreferencesand a Firebase session is active. - Manual Exit: Verify the
onBackPresseddouble-tap logic inMainActivityto prevent accidental app closure.
3. Data Integrity
- Firestore Sync: Verify that
AuthUtils.checkUserDetailscorrectly identifies whether a user needs to complete their profile based on thedetailsSubmittedflag in Firestore. - Regex Enforcement: Ensure country codes (e.g., +91, +1) are strictly enforced in
UserDetailsActivity.
Running Tests
To execute the test suite:
- Unit Tests: Right-click the
app/src/testdirectory and select Run 'All Tests'. - Instrumented Tests: Ensure a device/emulator is connected. Right-click the
app/src/androidTestdirectory and select Run 'All Tests'.