Class SandboxTestRunner

java.lang.Object
org.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
org.robolectric.internal.SandboxTestRunner
All Implemented Interfaces:
org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

public class SandboxTestRunner extends org.junit.runners.BlockJUnit4ClassRunner
Sandbox test runner that runs each test in a sandboxed class loader environment. Typically this runner should not be directly accessed, use org.robolectric.RobolectricTestRunner instead.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.robolectric.internal.bytecode.ClassHandlerBuilder
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SandboxTestRunner(Class<?> klass, org.robolectric.util.inject.Injector injector)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
    afterTest(org.junit.runners.model.FrameworkMethod method, Method bootstrappedMethod)
     
    protected void
    beforeTest(org.robolectric.internal.bytecode.Sandbox sandbox, org.junit.runners.model.FrameworkMethod method, Method bootstrappedMethod)
     
    protected org.junit.runners.model.Statement
    classBlock(org.junit.runner.notification.RunNotifier notifier)
     
    protected void
    configureSandbox(org.robolectric.internal.bytecode.Sandbox sandbox, org.junit.runners.model.FrameworkMethod method)
     
    protected org.robolectric.internal.bytecode.ClassHandler
    createClassHandler(org.robolectric.internal.bytecode.ShadowMap shadowMap, org.robolectric.internal.bytecode.Sandbox sandbox)
     
    protected org.robolectric.internal.bytecode.InstrumentationConfiguration
    createClassLoaderConfig(org.junit.runners.model.FrameworkMethod method)
    Create an InstrumentationConfiguration suitable for the provided FrameworkMethod.
    protected static org.robolectric.util.inject.Injector.Builder
     
    protected void
    finallyAfterTest(org.junit.runners.model.FrameworkMethod method)
     
    protected Collection<org.robolectric.internal.bytecode.Interceptor>
     
    protected Class<?>[]
    getExtraShadows(org.junit.runners.model.FrameworkMethod method)
     
    getHelperTestRunner(Class<?> bootstrappedTestClass)
     
    protected org.robolectric.internal.bytecode.Interceptors
     
    protected org.robolectric.internal.bytecode.Sandbox
    getSandbox(org.junit.runners.model.FrameworkMethod method)
     
    protected org.junit.runners.model.Statement
    methodBlock(org.junit.runners.model.FrameworkMethod method)
     
    protected org.junit.runners.model.Statement
    withPotentialTimeout(org.junit.runners.model.FrameworkMethod method, Object test, org.junit.runners.model.Statement next)
    Disables JUnit's normal timeout mode strategy.

    Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner

    collectInitializationErrors, computeTestMethods, createTest, createTest, describeChild, getChildren, getTestRules, isIgnored, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores

    Methods inherited from class org.junit.runners.ParentRunner

    childrenInvoker, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation

    Methods inherited from class org.junit.runner.Runner

    testCount

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • classHandlerBuilder

      protected final org.robolectric.internal.bytecode.ClassHandlerBuilder classHandlerBuilder
  • Constructor Details

    • SandboxTestRunner

      public SandboxTestRunner(Class<?> klass) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
    • SandboxTestRunner

      public SandboxTestRunner(Class<?> klass, org.robolectric.util.inject.Injector injector) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
  • Method Details

    • defaultInjector

      protected static org.robolectric.util.inject.Injector.Builder defaultInjector()
    • findInterceptors

      @Nonnull protected Collection<org.robolectric.internal.bytecode.Interceptor> findInterceptors()
    • getInterceptors

      @Nonnull protected org.robolectric.internal.bytecode.Interceptors getInterceptors()
    • classBlock

      protected org.junit.runners.model.Statement classBlock(org.junit.runner.notification.RunNotifier notifier)
      Overrides:
      classBlock in class org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
    • afterClass

      protected void afterClass()
    • getSandbox

      @Nonnull protected org.robolectric.internal.bytecode.Sandbox getSandbox(org.junit.runners.model.FrameworkMethod method)
    • createClassLoaderConfig

      @Nonnull protected org.robolectric.internal.bytecode.InstrumentationConfiguration createClassLoaderConfig(org.junit.runners.model.FrameworkMethod method)
      Create an InstrumentationConfiguration suitable for the provided FrameworkMethod.

      Custom TestRunner subclasses may wish to override this method to provide alternate configuration.

      Parameters:
      method - the test method that's about to run
      Returns:
      an InstrumentationConfiguration
    • configureSandbox

      protected void configureSandbox(org.robolectric.internal.bytecode.Sandbox sandbox, org.junit.runners.model.FrameworkMethod method)
    • methodBlock

      protected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method)
      Overrides:
      methodBlock in class org.junit.runners.BlockJUnit4ClassRunner
    • beforeTest

      protected void beforeTest(org.robolectric.internal.bytecode.Sandbox sandbox, org.junit.runners.model.FrameworkMethod method, Method bootstrappedMethod) throws Throwable
      Throws:
      Throwable
    • afterTest

      protected void afterTest(org.junit.runners.model.FrameworkMethod method, Method bootstrappedMethod)
    • finallyAfterTest

      protected void finallyAfterTest(org.junit.runners.model.FrameworkMethod method)
    • getHelperTestRunner

      protected SandboxTestRunner.HelperTestRunner getHelperTestRunner(Class<?> bootstrappedTestClass) throws org.junit.runners.model.InitializationError
      Throws:
      org.junit.runners.model.InitializationError
    • getExtraShadows

      @Nonnull protected Class<?>[] getExtraShadows(org.junit.runners.model.FrameworkMethod method)
    • createClassHandler

      @Nonnull protected org.robolectric.internal.bytecode.ClassHandler createClassHandler(org.robolectric.internal.bytecode.ShadowMap shadowMap, org.robolectric.internal.bytecode.Sandbox sandbox)
    • withPotentialTimeout

      protected org.junit.runners.model.Statement withPotentialTimeout(org.junit.runners.model.FrameworkMethod method, Object test, org.junit.runners.model.Statement next)
      Disables JUnit's normal timeout mode strategy.
      Overrides:
      withPotentialTimeout in class org.junit.runners.BlockJUnit4ClassRunner
      See Also: