robolectric/robolectric — pull request #1240 by stephanenicolas (2014-08-22 02:22:12+00:00)
Title: Allow weaved byte code to be passed to Robolectric.

This simple change allows to pass transformed/weaved byte code to Robolectric via a custom RobolectricTestRunner :

```java

@Slf4j
public class CustomTestRunner extends RobolectricTestRunner {
private InjectViewProcessor processor = new InjectViewProcessor();

public CustomTestRunner(Class testClass) throws InitializationError {
super(testClass);
}

@Override protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
return new AsmInstrumentingClassLoader(setup, urls) {
@Override protected byte[] getByteCode(String className) throws ClassNotFoundException {
// you can weave bytecode here and pass it to Robolectric
// and/or call super..
}
};
}
}
```

I need this mechanism for https://github.com/stephanenicolas/injectview/