Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试Android活动_Android_Testing - Fatal编程技术网

测试Android活动

测试Android活动,android,testing,Android,Testing,这是我的方法 @MediumTest public void testLoginSenzaCredenziali() { Button btn_login = (Button) mActiviy.findViewById(R.id.btn_login); EditText txt_username = (EditText) mActiviy.findViewById(R.id.txt_login_username); EditText txt_password = (E

这是我的方法

@MediumTest
public void testLoginSenzaCredenziali() {

    Button btn_login = (Button) mActiviy.findViewById(R.id.btn_login);
    EditText txt_username = (EditText) mActiviy.findViewById(R.id.txt_login_username);
    EditText txt_password = (EditText) mActiviy.findViewById(R.id.txt_login_password);

    assertNotNull("Button btn_login non può essere nullo", btn_login);
    assertNotNull("EditText txt_username non può essere nullo", txt_username);
    assertNotNull("EditText txt_password non può essere nullo", txt_password);
    assertEquals("EditText txt_username deve essere vuota", "", txt_username.getText());
    assertEquals("EditText txt_password deve essere vuota", "", txt_password.getText());


}
类标题是

public class LoginTest extends ActivityUnitTestCase<LoginActivity>
公共类LoginTest扩展了ActivityUnitTestCase
但当我在Android Studio中运行它时,它不识别我的测试方法,它说“空测试套件”


为什么?

您还需要在ActivityUnitTestCase中重写setUp()方法:

@Override
protected void setUp() throws Exception {
    super.setUp();
}
您是否在设备或模拟器上安装了测试中的应用程序?通过运行以下命令检查是否也安装了instrumentation应用程序:

adb shell pm list packages
查找您的测试包-与您在测试项目下的AndroidManifest.xml中定义的测试包相同