Skip to content

Instantly share code, notes, and snippets.

@CDRussell
Created August 24, 2015 08:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CDRussell/b8f39b8fbb0df63b10f3 to your computer and use it in GitHub Desktop.
Save CDRussell/b8f39b8fbb0df63b10f3 to your computer and use it in GitHub Desktop.
Base class to be used for all Robolectric unit tests.
package test;
import android.app.Application;
import com.tescobank.mobile.BuildConfig;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
/**
* Base class to be used for all Robolectric unit tests.
*
* It is only necessary to extend this class for classes which touch Android; pure JUnit tests don't need to extend this.
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public abstract class RobolectricUnitTest {
public Application getApplication() {
return RuntimeEnvironment.application;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment