Hi,
I am adding an android testcase for the UI. I have been following the tuto for the Spinner Test.
Unfortunately I have a nullpointerexception on a object medtSalePercent.setText("10"); which has been initialised.
here the code :
There is no exception on medtPriceValue.setText("50");.
but there is one on the screen for medtSalePercent.setText("10");
Why is that ?
Thanks
I am adding an android testcase for the UI. I have been following the tuto for the Spinner Test.
Unfortunately I have a nullpointerexception on a object medtSalePercent.setText("10"); which has been initialised.
here the code :
Code:
import jle.base.WorkActivity;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;
import android.widget.TextView;
public class WorkActivityTest extends ActivityInstrumentationTestCase2<WorkActivity> {
// The Application object for the application under test
private WorkActivity mActivity;
private EditText medtPriceValue;
private EditText medtSalePercent;
//private TextView medtResult;
public WorkActivityTest() {
super("jle.base", WorkActivity.class);
// TODO Auto-generated constructor stub
}
/*
* Sets up the test environment before each test.
* @see android.test.ActivityInstrumentationTestCase2#setUp()
*/
@Override
protected void setUp() throws Exception {
/*
* Call the super constructor (required by JUnit)
*/
super.setUp();
setActivityInitialTouchMode(false);
mActivity = this.getActivity();
medtPriceValue = (EditText)mActivity.findViewById(jle.base.R.id.edtPriceValue);
medtSalePercent= (EditText)mActivity.findViewById(jle.base.R.id.edtSaleDiscount);
/* medtResult= (TextView)mActivity.findViewById(jle.base.R.id.txvSalePrice);*/
}
public void testPriceValueUI() {
mActivity.runOnUiThread(
new Runnable() {
public void run() {
medtPriceValue.requestFocus();
medtPriceValue.setText("50");
medtSalePercent.setText("10");
/*medtSalePercent.requestFocus();
medtSalePercent.setText("10");*/
}
}
);
}
public void testStateDestroy() {
// Halt the Activity by calling Activity.finish() on it
mActivity.finish();
}
}
There is no exception on medtPriceValue.setText("50");.
but there is one on the screen for medtSalePercent.setText("10");
Why is that ?
Thanks