search

Home  >  Q&A  >  body text

android-studio - Error reported in AndroidTest

1. I defined a class to test parsing JSON data. The code of the GSON framework was called in the method, but an error occurred when running the method: Test running failed: Unable to find instrumentation info for: ComponentInfo{com. example.lweicheng.splash.test/android.test.InstrumentationTestRunner}
The following is the relevant code:

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"/>
    
    请问各位大神是否遇过同样的问题? 我的上述代码出了什么问题? 谢谢!
    
世界只因有你世界只因有你2743 days ago714

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-16 13:30:53

    Give you a reference:
    http://www.paincker.com/android-empty-test-suite
    https://testerhome.com/topics/2098

    Judging from your code, your targetpackage is:com.example.lweicheng.splash.GsonTest, which is the name of the class you want to test.

    reply
    0
  • Cancelreply