@@ -0,0 +1,1902 @@
+/*%0A * Copyright 2021 Google LLC%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     https://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.android.gnd;%0A%0Aimport androidx.arch.core.executor.testing.InstantTaskExecutorRule;%0Aimport dagger.hilt.android.testing.HiltAndroidRule;%0Aimport dagger.hilt.android.testing.HiltTestApplication;%0Aimport javax.annotation.OverridingMethodsMustInvokeSuper;%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.junit.MockitoJUnit;%0Aimport org.mockito.junit.MockitoRule;%0Aimport org.robolectric.RobolectricTestRunner;%0Aimport org.robolectric.annotation.Config;%0A%0A/**%0A * Injects Hilt dependencies during setUp and uses %7B@link RobolectricTestRunner%7D for%0A * instrumentation.%0A */%0A@Config(application = HiltTestApplication.class)%0A@RunWith(RobolectricTestRunner.class)%0Apublic abstract class HiltTestWithRobolectricRunner %7B%0A%0A  // Required for injecting hilt dependencies using @Inject annotation.%0A  @Rule public HiltAndroidRule hiltRule = new HiltAndroidRule(this);%0A%0A  // Background executor executes tasks synchronously. Needed for Room database operations.%0A  @Rule public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule();%0A%0A  // Allows creating mocks using @Mock annotation.%0A  @Rule public MockitoRule rule = MockitoJUnit.rule();%0A%0A  @Before%0A  @OverridingMethodsMustInvokeSuper%0A  public void setUp() %7B%0A    hiltRule.inject();%0A  %7D%0A%7D%0A

Create HiltTestWithRobolectricRunner to contain boiler-plate code for unit tests