Created
February 12, 2019 02:13
-
-
Save lvsecoto/a68b5feecf1f5e7eba418311009338cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static LifecycleOwner mockLifecycleOwner() { | |
LifecycleOwner owner = mock(LifecycleOwner.class); | |
LifecycleRegistry lifecycle = new LifecycleRegistry(owner); | |
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME); | |
when(owner.getLifecycle()).thenReturn(lifecycle); | |
return owner; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("unchecked") | |
private static <T> Observer<T> mockObserver() { | |
return (Observer<T>) Mockito.mock(Observer.class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Rule | |
public TestRule rule = new InstantTaskExecutorRule(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LiveData Test | |
dependencies { | |
// Test helpers for LiveData | |
androidTestImplementation "android.arch.core:core-testing:$lifecycle_version" | |
} | |
// Mockito | |
dependencies { | |
def mockito_version = "2.23.4" | |
testImplementation "org.mockito:mockito-core:$mockito_version" | |
androidTestImplementation "org.mockito:mockito-android:$mockito_version" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment