मैं निम्नलिखित परीक्षण केस के साथ सरल यूआई का परीक्षण करने का प्रयास कर रहा हूं, मुख्य विचार यूआई पाठ (उपयोगकर्ता इनपुट की नकल करने के लिए) में परीक्षण करना है और फिर सक्रिय रूप से किसी ईवेंट पर क्लिक करना है ।एंड्रॉइड व्यू में यूआई तत्वों के साथ परीक्षण
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRoot.checkThread(ViewRoot.java:2802)
at android.view.ViewRoot.playSoundEffect(ViewRoot.java:2581)
at android.view.View.playSoundEffect(View.java:8516)
at android.view.View.performClick(View.java:2407)
at com.crocodil.software.stack.test.StackTestCase.testSimpleDefaults(StackTestCase.java:46)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
यह UI तत्व करने के लिए प्रत्येक पहुँच पर होता है और मैं हैंडल या async कार्य का उपयोग करके इसे से बचने के लिए असमर्थ था -
public class StackTestCase
extends ActivityInstrumentationTestCase2<Stack>
{
private StackDemo mActivity;
private EditText eaten;
public StuckTestCase() {
super("com.crocodil.software.stack", Stack.class);
}
public StuckTestCase(Class<Stack> activityClass) {
super("com.crocodil.software.stack", activityClass);
}
protected void setUp() throws Exception {
super.setUp();
mActivity = this.getActivity();
mCount = (Button) mActivity.findViewById(com.crocodil.software.stack.R.id.action);
eaten = (EditText) mActivity.findViewById(com.crocodil.software.stack.R.id.eaten);
}
public void testPreconditions() {
assertNotNull(mStatus);
}
public void testSimpleDefaults(){
double status = Double.valueOf(mStatus.getText().toString());
eaten.setText(2);
mCount.performClick();
assertEquals((status-2),Double.valueOf(mStatus.getText().toString()));
}
}
चल परिणाम अपवाद नहीं है? कोई सुझाव?
मैं ऐसी है कि एक मुद्दा का सामना करना पड़ रहा हूँ, 'waitForIdleSync();' कॉल खुद अनंत लूप में लटका है। इस मुद्दे को डीबग करने से पता चला कि हैंडलर के माध्यम से पोस्ट किया गया 'खाली रुनबल()' संदेश 'MessageQueue' में पकड़ा नहीं जा रहा है। लगता है कि कुछ समय मुद्दा मौजूद है। लेकिन यकीन नहीं है, इस मुद्दे का पता लगाने के लिए कैसे। – ArunJTS