添加数据绑定后,Android Robolectric Unit测试失败

时间:2017-08-02 07:52:30

标签: android unit-testing data-binding robolectric

我有Robolectric单元测试这样的活动:

Robolectric.buildActivity(BookActivity.class).withIntent(disputeIntent).create().get()

它工作正常,直到我改为使用数据绑定通胀来自:

setContentView(this, R.layout.activity_book)

DataBindingUtil.setContentView(this, R.layout.activity_book);

我也试过这种设置内容视图的方式:

bindingView = ActivityBookBinding.inflate(getLayoutInflater());
setContentView(bindingView.getRoot());

但在这两种情况下我都收到此错误:

android.view.InflateException: XML file build/intermediates/res/merged/Dev/debug/layout/activity_book.xml line #-1 (sorry, not yet implemented): Error inflating class layout

at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at com.package.name.BaseActivity.setContentView(BaseActivity.java:56)
at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:276)
at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:261)
at com.package.name.BookActivity.onCreate(BookActivity.java:172)

请帮忙! 提前致谢

0 个答案:

没有答案