Unit tests for enrolment upload and improvements to enrolment tests #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here I've implemented unit tests for the ClientAndroidInterface class. These tests cover the enrolment upload process, creation and modification of insurees, as well as creation of new families. We used Robolectric to simulate an Android environment and access the application context, and Mockito to mock dependencies such as SQLHandler, Global, Activity, Resources, and StorageManager.
The tests focus on verifying that methods handle data correctly, update the database as expected, and manage UI elements like ProgressDialog.
Type of change
Chore(CI/CD)
Checklists
Unit Tests added and passed:
Upload Enrolments:
testUploadEnrolment_ShouldProcessSuccessfully – PASSED ✅
testUploadEnrolment_ShouldHandleEnrolError – PASSED ✅
Enrol:
testEnrol_ShouldProcessSuccessfully – PASSED ✅
SaveInsuree – Create:
testCreateNewInsuree_ShouldInsertInDatabase – PASSED ✅
SaveInsuree – Modify:
testModifyInsuree_ShouldUpdateInDatabase – PASSED ✅
SaveInsuree – New Family:
testCreateNewFamily_ShouldInsertInDatabase – PASSED ✅
Certain methods or attributes in ClientAndroidInterface were adjusted from private to protected to allow mocking with Mockito.
Network calls are not tested directly; tests focus on local data handling and UI behavior.
Helpers like buildFamilyArray, buildInsureeArray, buildPolicyArray, buildPremiumArray, buildInsureeJson, and buildInsureeMap are used to provide mock data for the tests.