如何测试片段,Robolectric?片段、测试、Robolectric

2023-09-12 11:05:05 作者:动感光波~biubiu

我知道有一个 Robolectric.shadowOf(片段)方法和 ShadowFragment 类,认为他们AREN'牛逼上市的文档,但我不能使它工作。

I know there is a Robolectric.shadowOf(Fragment) method and a ShadowFragment class, thought they aren't listed on the docs, but I can't make it work.

myFragment = new MyFragment();
myFragment.onCreateView(LayoutInflater.from(activity), (ViewGroup) activity.findViewById(R.id.container), null);
myFragment.onAttach(activity);
myFragment.onActivityCreated(null); 

我正与API级13(蜂窝)。

I'm working with API level 13 (Honeycomb).

感谢。

推荐答案

编辑#3 :Robolectric 2.4具有的