From b25a32413c96bff5ad36786e32f490cd772e70ef Mon Sep 17 00:00:00 2001 From: Luis Vidal Date: Thu, 16 Jun 2016 15:48:41 -0700 Subject: Weather API test: Wait for a bit before Mockito verifies if method was called Sometimes the runnable posted to runOnServiceThread() might run a bit faster than the calls made to the mocked weather provider, which causes Mockito to throw an exception. Add a timeout to instruct Mockito to wait for a bit before it verifies if the method was actually called. Also removed an unused variable in CMWeatherManagerTest TICKET: CYNGNOS-3043 Change-Id: I53b6541aeb571a6c83d1c26b6723d74c3661e8cc --- .../tests/weather/unit/CMWeatherManagerTest.java | 1 - .../tests/weather/unit/WeatherProviderServiceTest.java | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java index c382d3f..3453c77 100644 --- a/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java +++ b/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java @@ -46,7 +46,6 @@ public class CMWeatherManagerTest extends AndroidTestCase { private static final int REQUEST_ID = 42; private static final String MOCKED_WEATHER_PROVIDER_LABEL = "Mock'd Weather Service"; private ICMWeatherManager.Stub mICMWeatherManagerSpy; - private static final String DESCRIPTOR = "cyanogenmod.weather.ICMWeatherManager"; @Override protected void setUp() throws Exception { diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java index 958dce4..fd1e2ff 100644 --- a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java +++ b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java @@ -45,6 +45,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -88,7 +89,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -117,7 +118,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -211,7 +212,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -227,7 +228,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -243,7 +244,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); -- cgit v1.1