मैं एंड्रॉइड के लिए नया हूं और जावा पर थोड़ा जंगली हूं, जो .NET पृष्ठभूमि से आ रहा है। मैं एंड्रॉइड पर चल रहे मोबाइल एप्लिकेशन के लिए कुछ परीक्षण स्वचालन विकसित कर रहा हूं।एंड्रॉइड - इंस्ट्रुमेंटेशनटेस्टरनर
वर्तमान में, मैं सिर्फ Android डीबग ब्रिज का उपयोग कर कमांड लाइन के माध्यम से परीक्षण शुरू करने कर रहा हूँ, लेकिन जब मैं किसी भी परीक्षण चलाने के लिए प्रयास मैं एक त्रुटि हो रही है:
सबसे पहले, इस त्रुटि मैं है 'मी प्राप्त:
junit.framework.TestSuite$1: Failure in warning: junit.framework.AssertionFailedError: No tests found in com.myapp.test.UITests at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
मैं (एक निहित डिवाइस पर) परीक्षण शुरू करने के लिए प्रयास करने के लिए इस aDB कमांड का उपयोग कर रहा:
adb shell am instrument -e class com.myapp.test.UITests -w com.myapp.test/android.test.InstrumentationTestRunner
अंत में, यहाँ वर्ग मैं चलाने का प्रयास कर रहा हूँ है ट टीएस से:
package com.myapp.test;
import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;
import com.jayway.android.robotium.solo.Solo;
import junit.framework.Assert;
@SuppressWarnings("unchecked")
public class UITests extends ActivityInstrumentationTestCase2
{
private static final String TARGET_PACKAGE_ID = "com.myapp.main";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.myapp.main.activities.MainActivity";
private static Class<?> launcherActivityClass;
private Solo solo;
private Activity activity;
static
{
try
{
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
}
catch(ClassNotFoundException e)
{
throw new RuntimeException(e);
}
}
public UITests() throws ClassNotFoundException
{
super(TARGET_PACKAGE_ID, launcherActivityClass);
}
@Override
protected void setUp()
{
activity = getActivity();
solo = new Solo(getInstrumentation(), activity);
}
@Override
public void runTest() throws Throwable
{
// Simple Test
Assert.assertTrue(solo.searchText("Welcome"));
}
@Override
protected void tearDown() throws Exception
{
try
{
solo.finalize();
}
catch(Throwable e)
{
}
getActivity().finish();
super.tearDown();
}
}
मुझे कुछ गलत करना होगा, लेकिन मुझे यकीन नहीं है कि क्या। मैंने रोबोटियम साइट पर example पर अपना कोड आधारित किया है।
अगर कोई मेरी गलती को इंगित कर सकता है तो मैं बहुत सराहना करता हूं।
अपडेट - के रूप में अनुरोध
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="@drawable/icon" android:label="@string/ws_app_name">
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.myapp.main"
android:label="My App Tests"/>
</manifest>
फ़ाइल/परियोजना सेटिंग्स/जायके सेट करके किया है अपने प्रकट साझा करें फ़ाइल .. –
@RajdeepDua मैंने अब अपनी मेनिफेस्ट फ़ाइल जोड़ दी है। –