5

मैं अपने ऐप पर आरईएसटी सेवा कॉल करने के लिए एंड्रॉइड वसंत RestTemplate का उपयोग कर रहा हूं। मैंने एंड्रॉइड इंस्ट्रुमेंटेशन टेस्ट जोड़ा जिसमें आरईएसटी सेवा कॉल का मज़ाक उड़ाया गया। सभी अपने परीक्षण ठीक चल रहे हैं, जबकि एंड्रॉयड स्टूडियो से चल रहा है, लेकिन परीक्षण जबकिएंड्रॉइडटेस्ट कमांड लाइन से चलते समय असफल: ऐप: कनेक्टेड डेबग एंड्रॉइडटेस्ट

./gradlew clean :app:connectedDebugAndroidTest 

build.gradle पर वसंत परीक्षण निर्भरता का उपयोग कर टर्मिनल से चल वसंत नकली वर्ग लोड करने में विफल

androidTestCompile("org.springframework:spring-test:3.2.8.RELEASE") 

हैं मैं androidTestCompile के बजाय compile में बदलता हूं, एंड्रॉइड परीक्षण टर्मिनल से ठीक चल रहा है। चूंकि मैं अपने उत्पादन एपीके पर इस निर्भरता को किसी भी मदद की नहीं चाहता, सराहना की।

यह लॉग जबकि परीक्षण

08-05 00:04:12.585 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.asm.commons.JSRInlinerAdapter 08-05 00:04:12.587 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.asm.commons.TryCatchBlockSorter 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.cglib.transform.AbstractProcessTask 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.cglib.transform.AbstractTransformTask 08-05 00:04:12.603 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.core.convert.support.ConvertingPropertyEditorAdapter 08-05 00:04:12.610 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.core.io.ResourceEditor 08-05 00:04:12.611 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.core.io.support.ResourceArrayPropertyEditor 08-05 00:04:12.617 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.http.MockHttpInputMessage 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.http.MockHttpOutputMessage 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.http.client.MockClientHttpRequest 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.http.client.MockClientHttpResponse 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.jndi.ExpectedLookupTemplate 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.jndi.SimpleNamingContext 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.jndi.SimpleNamingContextBuilder 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.DelegatingServletInputStream 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.DelegatingServletOutputStream 08-05 00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockBodyContent 08-05 00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockExpressionEvaluator 08-05 00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockFilterChain 08-05 00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockFilterConfig 08-05 00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockHttpServletRequest 08-05 00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockHttpServletResponse 08-05 00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockHttpSession 08-05 00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockJspWriter 08-05 00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockMultipartFile 08-05 00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockMultipartHttpServletRequest 08-05 00:04:12.622 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockPageContext 08-05 00:04:12.622 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockRequestDispatcher 08-05 00:04:12.623 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockServletConfig 08-05 00:04:12.623 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.MockServletContext 08-05 00:04:12.628 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.PassThroughFilterChain 08-05 00:04:12.628 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.portlet.MockActionRequest 08-05 00:04:12.629 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.portlet.MockActionResponse 08-05 00:04:12.629 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.portlet.MockBaseURL 08-05 00:04:12.629 22274-22302/com.libin.androiduitesting E/TestLoader: Could not find class: org.springframework.mock.web.portlet.MockCacheControl 08-05 00:04:12.630 22274-22302/com.libin.androiduitesting E/AndroidRuntime: FATAL EXCEPTION: Instr: android.support.test.runner.AndroidJUnitRunner Process: com.libin.androiduitesting, PID: 22274 java.lang.NoClassDefFoundError: org.springframework.mock.web.portlet.MockClientDataRequest at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:324) at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92) at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113) at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801) at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747) at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354) at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)

+0

'testCompile' के बारे में क्या? –

+0

'androidTestCompile' को' testCompile 'में @ cricket_007 के रूप में बदलें। क्या यह काम कर रहा है? – piotrek1543

+0

नहीं। यह कैसे काम करता है ?, निर्भरता में जोड़ा निर्भरता कॉम्पाइल केवल यूनिट परीक्षण के लिए शामिल हैं। मैं एंड्रॉइड टेस्ट चला रहा हूँ। इसमें एंड्रॉइडटेस्ट – Libin

उत्तर

1

शुरू करने लगता है जैसे आप मजाक वर्ग है जो परीक्षण के लिए आवश्यक हैं याद कर रहे हैं। स्प्रिंग-टेस्ट जार को डॉउलोडिंग करने का प्रयास करें और जांचें कि क्या सभी मॉकिंग क्लास अंदर हैं - उदाहरण के लिए, इसे org.springframework.mock.web.portlet पैकेज से org.springframework.mock.web.portlet.MockClientDataRequest कक्षा निर्यात करनी चाहिए।

आप कुछ दुर्भाग्यपूर्ण जार बिल्ड का उपयोग कर सकते हैं जहां मॉकिंग कक्षाओं के लिए निर्भरता this issue में खो गई थी।

इसके अलावा आप वसंत ढांचे को अद्यतन करने का प्रयास कर सकते हैं, नवीनतम पहले से ही 4.3.2 है।

+0

नहीं, मुझे कक्षाएं नहीं मिल रही हैं। दौड़ने के दौरान पूरे मॉड्यूल के लिए परीक्षण को लॉडा करते समय इसे हटा दिया जाता है। यदि व्यक्तिगत कक्षा या पैकेज के लिए परीक्षण चल रहा है तो सबकुछ ठीक है – Libin

संबंधित मुद्दे