Q:

Robolectric not using ShadowWebView as the super class of a class that extends WebView. MustOverrideException instead

I'm attempting to get Robolectric 2.1 working with my project and getting a MustOverrideException when my subclass of WebView attempts to call setDatabasePath on it's WebSettings. I have a custom Application class that attempts to create an instance of a subclass of WebView in onCreate. As part of that WebView's constructor, it attempts to set the database path.
I would have thought that since getSettings was being called from WebView, that the call would have really hit ShadowWebView which is supposed to return a TestWebSettings object which doesn't throw those exceptions. Instead, it seems to just be calling the normal WebSettings.getSettings and returning something that doesn't have those methods implemented. I've attempted using @Config(shadows = ShadowWebView.class) for my test but with no change. I've attempted to create a custom Shadow of my specialized web view and apply that to the test, but it still calls the regular custom class. Here's the exception I see when I attempt to run my tests:
java.lang.RuntimeException: android.webkit.MustOverrideException: abstract function called: must be overriden!
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:231)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:80)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:47)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: android.webkit.MustOverrideException: abstract function called: must be overriden!
    at android.webkit.WebSettings.setDatabasePath(WebSettings.java:932)
    at com.example.android.jsbridge.ExWebView.init(ExWebView.java:237)
    at com.example.android.jsbridge.ExWebView.<init>(ExWebView.java:187)
    at com.example.android.jsbridge.ExWebView.getInstance(ExWebView.java:192)
    at com.example.android.ExApplication.onCreate(ExApplication.java:88)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)

A:

I liked Jearil's answer, but not having to wait for a new release is even better. I extended ShadowWebView and TestWebSettings to add the method that wasn't implemented.
ExtendedShadowWebView.java
@Implements(value = WebView.class, inheritImplementationMethods = true)
public class ExtendedShadowWebView extends ShadowWebView{
private WebSettings webSettings = new ExtendedTestWebSettings();
  @Implementation
  public WebSettings getSettings() {
    return webSettings;
  }
}

ExtendedTestWebSettings.java
public class ExtendedTestWebSettings extends TestWebSettings {
      @Implementation
      public void setDefaultFontSize(int fontSize) {
           // This was the method I needed, replace with your setDatabasePath
      }
}

MyActivityTest.java
@RunWith(RobolectricTestRunner.class)
@Config(manifest = TestUtility.ANDROID_MANIFEST_XML,shadows=ExtendedShadowWebView.class)
public class MyActivityTest {

