android - 如何从 Robolectric 测试 Action Bar 的 Action Items?

标签 android unit-testing robolectric

真快,在当前的 Robolectric 中有没有办法验证操作栏上操作项的存在可见性? (我知道这基本上是为 UI 配置细节编写单元测试,但如果它很简单,我愿意这样做。)

最佳答案

据我所知,在早期版本的 Robolectric 中无法访问 ActionBar。尝试从 Activity 获取它返回 null。

自 Robolectirc 2.2 http://robolectric.blogspot.com/2013/10/robolectric-22-released.html你可以访问 ActionBar。

关于android - 如何从 Robolectric 测试 Action Bar 的 Action Items?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14142097/

相关文章:

Android SoundPool声音播放时断时续

Android 谷歌地图我的位置权限

C++ Google Test 将测试夹具构造函数定义放在哪里

java - 为什么在使用 Robolectric 的 Android 单元测试中调用 HtmlCompat 时会出现 ExceptionInInitializerError?

unit-testing - 在多个文件上使用 Power Mock 运行 Robolectric 测试时出现 ClassCastException 异常

java - 如何将 Assets 文件夹中的本地 JSON 文件解析为 ListView?

android - Android 版 Google Analytics v2 中丢失异常堆栈跟踪?

javascript - 如何导入 `isOneline`函数?

python - 完整性错误: column user_id is not unique in django tastypie test unit

android - appcompat-v7 :22. 2.0 的 Robolectric 问题