From b0ee65ea5894ad4b0b358a7a3dd61f354833da78 Mon Sep 17 00:00:00 2001 From: Akshay Komar Date: Sun, 5 Jan 2025 00:49:18 +0530 Subject: [PATCH] Refactor Nearby Location Tests to Improve Assertion Logic -Refactored testSearchCloseToCurrentLocationWhenFar: Simplified assertion by using assertFalse(!isClose) for better readability and logical clarity. -Added testSearchCloseToCurrentLocationWhenClose: Created a new test case to validate behavior when the search is close to the current location, ensuring assertTrue(isClose) for correctness. -Improved Coverage: These changes enhance the test coverage and reliability of the searchCloseToCurrentLocation function. --- .../nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt index cfd2a818d..80e9a53f9 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt @@ -306,7 +306,7 @@ class NearbyParentFragmentPresenterTest { // 111.19 km real distance, return false if 148306.444306 > currentLocationSearchRadius NearbyController.currentLocationSearchRadius = 148306.0 val isClose = nearbyPresenter.searchCloseToCurrentLocation() - assertFalse(isClose!!.equals(false)) + assertFalse(!isClose) } /** @@ -318,7 +318,7 @@ class NearbyParentFragmentPresenterTest { // 111.19 km real distance, return false if 148253.333 > currentLocationSearchRadius NearbyController.currentLocationSearchRadius = 148307.0 val isClose = nearbyPresenter.searchCloseToCurrentLocation() - assertTrue(isClose!!) + assertTrue(isClose) } fun expectMapAndListUpdate() {