Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Fix ConnectivityReceiver tests #69

Merged

Conversation

ataulm
Copy link
Contributor

@ataulm ataulm commented Oct 7, 2015

Fixes ConnectivityReceiverShould#notifyTheMerlinServiceOnValidConnectivityIntents:

Wanted but not invoked:
merlinService.onConnectivityChanged(<any>);
-> at com.novoda.merlin.receiver.ConnectivityReceiverShould.notifyTheMerlinServiceOnValidConnectivityIntents(ConnectivityReceiverShould.java:65)
Actually, there were zero interactions with this mock.

- this is intended to show no interaction with merlin service
- it does this, but for the wrong reason (intent == null)
@@ -57,10 +64,10 @@ public void notNotifyTheMerlinServiceOnNonConnectivityIntents() throws Exception

@Test
public void notifyTheMerlinServiceOnValidConnectivityIntents() throws Exception {
Intent intent = new Intent();
intent.setAction(ConnectivityManager.CONNECTIVITY_ACTION);
Intent mock = mock(Intent.class);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a valid candidate for mocking - both the context and the intent are being called from outside of our system (outside of our class)


verifyZeroInteractions(merlinService);
}

@Test
public void notifyTheMerlinServiceOnValidConnectivityIntents() throws Exception {
Intent intent = new Intent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really confused as to how this was null?

@ouchadam
Copy link
Contributor

ouchadam commented Oct 8, 2015

not a blocker for me

ouchadam added a commit that referenced this pull request Oct 8, 2015
@ouchadam ouchadam merged commit 50b37a8 into migrate-to-android-unit-test Oct 8, 2015
@ouchadam ouchadam deleted the fix_connectivity_receiver_test branch October 8, 2015 10:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants