1

can I run junit test on Android device and see the application running the test in the device at the same time?

If it is posible, can i take screenshots of the tests ??

I create the testcase, and works. Like this..

public TestCase(Class activityClass) {
    super("com.xxxx.xxxxx", xxxxxx.class);
    // TODO Auto-generated constructor stub
}

@Override
protected void setUp() throws Exception {
    super.setUp();
    LoginActivity mainActivity = getActivity();
    result = (EditText) mainActivity.findViewById(R.id.edit_xxx);
    result.setText("holahola");

    Button btn = (Button) mainActivity.findViewById(R.id.btn_xxx);
    btn.performClick();
}
4

1 回答 1

1

can I run junit test on Android device and see the application running the test in the device at the same time?

Yes, though they run fairly quickly.

If it is posible, can i take screenshots of the tests ?

You are welcome to ask the content View of your activity to draw itself to a Bitmap-backed Canvas, and this should work just fine from a unit test: How to take a screenshot and share it programmatically

于 2013-05-28T10:42:46.420 回答