protected void beforeTest(Sandbox sandbox, Spec spec) throws Throwable { SdkEnvironment sdkEnvironment = (SdkEnvironment) sandbox; RoboSpec roboSpec = (RoboSpec) spec; roboSpec.parallelUniverseInterface = getHooksInterface(sdkEnvironment); Class<TestLifecycle> cl = sdkEnvironment.bootstrappedClass(getTestLifecycleClass()); roboSpec.testLifecycle = ReflectionHelpers.newInstance(cl); final Config config = roboSpec.config; final AndroidManifest appManifest = roboSpec.getAppManifest(); roboSpec.parallelUniverseInterface.setSdkConfig((sdkEnvironment).getSdkConfig()); roboSpec.parallelUniverseInterface.resetStaticState(config); SdkConfig sdkConfig = roboSpec.sdkConfig; Class<?> androidBuildVersionClass = (sdkEnvironment).bootstrappedClass(Build.VERSION.class); ReflectionHelpers.setStaticField(androidBuildVersionClass, "SDK_INT", sdkConfig.getApiLevel()); ReflectionHelpers.setStaticField(androidBuildVersionClass, "RELEASE", sdkConfig.getAndroidVersion()); ReflectionHelpers.setStaticField(androidBuildVersionClass, "CODENAME", sdkConfig.getAndroidCodeName()); PackageResourceTable systemResourceTable = sdkEnvironment.getSystemResourceTable(getJarResolver()); PackageResourceTable appResourceTable = getAppResourceTable(appManifest); // This will always be non empty since every class has basic methods like toString. Method randomMethod = getTestClass().getJavaClass().getMethods()[0]; roboSpec.parallelUniverseInterface.setUpApplicationState( randomMethod, roboSpec.testLifecycle, appManifest, config, new RoutingResourceTable(getCompiletimeSdkResourceTable(), appResourceTable), new RoutingResourceTable(systemResourceTable, appResourceTable), new RoutingResourceTable(systemResourceTable)); roboSpec.testLifecycle.beforeTest(null); }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return MyTestLifeCycle.class; }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return TestLifeCycleWithInjection.class; }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return X.class; }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return MyTestLifecycle.class; }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return TestLifecycleWithMockito.class; }
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() { return FullEnvTestLifeCycle.class; }
/** * An instance of the returned class will be created for each test invocation. * * Custom TestRunner subclasses may wish to override this method to provide alternate configuration. * * @return a class which implements {@link TestLifecycle}. This implementation returns a {@link DefaultTestLifecycle}. */ protected Class<? extends TestLifecycle> getTestLifecycleClass() { return DefaultTestLifecycle.class; }
void setUpApplicationState(Method method, TestLifecycle testLifecycle, boolean strictI18n, ResourceLoader systemResourceLoader, AndroidManifest appManifest, Config config);