Robolectric 2.3-测试支持。片段失败,显示“您需要使用Theme.AppCompat主题”

问题描述 投票:1回答:1

我正在编写一个support.Fragment测试,但我不断收到以下异常:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

当我尝试启动片段时(在创建活动期间)引发了异常:

@RunWith(RobolectricTestRunner.class)
public class AuthFragmentTest extends TestCase {   

    private SupportFragment fragment;

    @Before
    public void setUp() throws Exception {
        fragment = new SupportFragment();

        FragmentTestUtil.startFragment(fragment, SupportFragmentActivity.class);
    }
}

这是我正在使用的API级别。

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="19" />

此外,Robolectric被配置为使用与具有/src/test/resources/org.robolectric.Config.properties的应用程序相同的清单

我的应用程序运行没有问题,支持库已正确设置,这只是我似乎无法正确完成的测试。

android robolectric
1个回答
0
投票

对于遇到此问题的人,可以找到潜在的解决方案-here

© www.soinside.com 2019 - 2024. All rights reserved.