问题描述
1.我定义了一个测试解析JSON数据的类,方法里调用了GSON框架的代码,但是在运行方法的时候出现了报错:Test running failed: Unable to find instrumentation info for: ComponentInfo{com.example.lweicheng.splash.test/android.test.InstrumentationTestRunner}如下为相关代码:
public class GsonTest extends AndroidTestCase { public void testJson() {String json = '{'name':'小王','age':18,'gander':'true'}';Gson gson = new Gson();Person person=gson.fromJson(json,Person.class);Log.d('lweicheng',person.toString()); } class Person {private String name;private int age;private boolean gender;public String getName() { return name;}public void setName(String name) { this.name = name;}public int getAge() { return age;}public void setAge(int age) { this.age = age;}public boolean isGender() { return gender;}public void setGender(boolean gender) { this.gender = gender;}public String toString() { return 'name' + name + ',age:' + age + ',gender:' + gender;} }}如下是Androidmanifest文件的配置 <activity android:name='.RegisterActivity'></activity> <uses-library android:name='android.test.runner'/></application><instrumentation android:name='android.test.InstrumentationTestRunner' android:targetPackage='com.example.lweicheng.splash.GsonTest'/>请问各位大神是否遇过同样的问题? 我的上述代码出了什么问题? 谢谢!
问题解答
回答1:给你个参考:http://www.paincker.com/android-empty-test-suitehttps://testerhome.com/topics/2098
就你的代码来看,你的targetpackage为:com.example.lweicheng.splash.GsonTest,这是你要测试的类名.