Search in sources :

Example 1 with ShadowInfo

use of org.robolectric.internal.bytecode.ShadowInfo in project robolectric by robolectric.

the class SandboxTestRunner method createClassLoaderConfig.

/**
 * Create an {@link InstrumentationConfiguration} suitable for the provided {@link
 * FrameworkMethod}.
 *
 * <p>Custom TestRunner subclasses may wish to override this method to provide alternate
 * configuration.
 *
 * @param method the test method that's about to run
 * @return an {@link InstrumentationConfiguration}
 */
@Nonnull
protected InstrumentationConfiguration createClassLoaderConfig(FrameworkMethod method) {
    InstrumentationConfiguration.Builder builder = InstrumentationConfiguration.newBuilder().doNotAcquirePackage("java.").doNotAcquirePackage("jdk.internal.").doNotAcquirePackage("sun.").doNotAcquirePackage("org.robolectric.annotation.").doNotAcquirePackage("org.robolectric.internal.").doNotAcquirePackage("org.robolectric.pluginapi.").doNotAcquirePackage("org.robolectric.util.").doNotAcquirePackage("org.junit");
    String customPackages = System.getProperty("org.robolectric.packagesToNotAcquire", "");
    for (String pkg : customPackages.split(",")) {
        if (!pkg.isEmpty()) {
            builder.doNotAcquirePackage(pkg);
        }
    }
    String customClassesRegex = System.getProperty("org.robolectric.classesToNotInstrumentRegex", "");
    if (!customClassesRegex.isEmpty()) {
        builder.setDoNotInstrumentClassRegex(customClassesRegex);
    }
    for (Class<?> shadowClass : getExtraShadows(method)) {
        ShadowInfo shadowInfo = ShadowMap.obtainShadowInfo(shadowClass);
        builder.addInstrumentedClass(shadowInfo.shadowedClassName);
    }
    addInstrumentedPackages(method, builder);
    return builder.build();
}
Also used : InstrumentationConfiguration(org.robolectric.internal.bytecode.InstrumentationConfiguration) ShadowInfo(org.robolectric.internal.bytecode.ShadowInfo) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)1 InstrumentationConfiguration (org.robolectric.internal.bytecode.InstrumentationConfiguration)1 ShadowInfo (org.robolectric.internal.bytecode.ShadowInfo)1