如果我在模拟器上以调试模式 Eclipse 运行我的单元测试,它将运行良好且完整,没有错误。但是,如果我在运行模式下执行它,它会崩溃。这是我的片段代码
public class TextAnswerButton extends Fragment
{
...
@Override
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container, final Bundle savedInstanceState)
{
final View layout = inflater.inflate(R.layout.textanswer, container,
false);
answer = (TextAnswer) getArguments().getSerializable("answer");
final Button button = (Button) layout.findViewById(R.id.button_answer);
button.setText(answer.getAnswerText());
button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
callback.answerQuestion(answer);
}
});
return layout;
}
}
问题是
answer = (TextAnswer) getArguments().getSerializable("answer");
答案在运行模式下将为空。可能导致它为空的时间是什么。它不能足够快地反序列化它吗?
这是我的 Robotium 完整性测试,简单的创建活动并单击按钮。
public void testSelectQuiz() throws Exception {
SOLO.assertCurrentActivity("Expected QuizListActivity", QuestionActivity.class);
SOLO.clickOnButton("One");
//q0.getAnswers().
//SOLO.cli
}