gpt4 book ai didi

java - 在测试项目中找不到从方法 y 引用的类 x

转载 作者:行者123 更新时间:2023-12-01 13:01:14 25 4
gpt4 key购买 nike

我在我正在开发的应用程序上使用了 Robotium 测试框架,我在项目的第一阶段运行了它,一切都很好,但是昨天我实现了更多测试并感到非常沮丧,因为它看起来像测试项目找不到我的任何类(class)来测试。这是在我更新了 SDK 管理器中的一些内容后发生的,但我不确定它是否与我的问题有关。无论如何,logcat 中有一个输出示例:

05-06 16:30:27.541: E/dalvikvm(24080): Could not find class 'com.tuntzme.controller.activities.ActivityLogin', referenced from method com.tuntzme.test.activities.ActivityLoginTest.

这是我的测试用例之一:

public class ActivityCadastroTest extends ActivityInstrumentationTestCase2<ActivityCadastro>{

private Solo solo;

public ActivityCadastroTest() {
super(ActivityCadastro.class);
}

public void TesteCadastroCamposVazios() {
solo.assertCurrentActivity("activity_errada", ActivityCadastro.class);
solo.clickOnActionBarItem(R.id.menu_item_pronto_cadastro);
solo.waitForText(MensagensException.CAMPO_EMAIL_VAZIO.toString());

solo.enterText(com.tuntzme.R.id.edit_text_email_cadastro, SharedStuff.Strings.EMAIL_TESTE_SUCESSFULL.value());
solo.waitForText(MensagensException.CAMPO_SENHA_VAZIO.toString());
}

public void TesteCadastroEmailInvalido() {
solo.assertCurrentActivity("activity_errada", ActivityCadastro.class);
solo.enterText(com.tuntzme.R.id.edit_text_email_cadastro, SharedStuff.Strings.EMAIL_TESTE_WRONG_FORMAT.value());
solo.enterText(com.tuntzme.R.id.edit_text_senha_cadastro, SharedStuff.Strings.SENHA_TESTE.value());
solo.enterText(com.tuntzme.R.id.edit_text_confirmar_senha_cadastro, SharedStuff.Strings.SENHA_TESTE.value());
solo.clickOnActionBarItem(R.id.menu_item_pronto_cadastro);
solo.waitForText(MensagensException.EMAIL_INVALIDO.toString());
}

public void TesteCadastroSenhaDivergente() {
solo.assertCurrentActivity("activity_errada", ActivityCadastro.class);
solo.enterText(com.tuntzme.R.id.edit_text_email_cadastro, SharedStuff.Strings.EMAIL_TESTE_SUCESSFULL.value());
solo.enterText(com.tuntzme.R.id.edit_text_senha_cadastro, SharedStuff.Strings.SENHA_TESTE.value());
solo.enterText(com.tuntzme.R.id.edit_text_confirmar_senha_cadastro, SharedStuff.Strings.SENHA_TESTE_DIVERGENTE.value());
solo.clickOnActionBarItem(R.id.menu_item_pronto_cadastro);
solo.waitForText(MensagensException.SENHAS_NAO_COINCIDEM.toString());
}

public void TesteCadastroSucesso() {
solo.assertCurrentActivity("activity_errada", ActivityCadastro.class);
solo.enterText(com.tuntzme.R.id.edit_text_email_cadastro, SharedStuff.Strings.EMAIL_TESTE_SUCESSFULL.value());
solo.enterText(com.tuntzme.R.id.edit_text_senha_cadastro, SharedStuff.Strings.SENHA_TESTE.value());
solo.enterText(com.tuntzme.R.id.edit_text_confirmar_senha_cadastro, SharedStuff.Strings.SENHA_TESTE.value());
solo.clickOnActionBarItem(R.id.menu_item_pronto_cadastro);
solo.waitForActivity(ActivityLogin.class);
}

}

我的测试项目 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tuntzme.test"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.tuntzme" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:targetPackage="com.tuntzme" android:name="android.test.InstrumentationTestRunner" />

最后是我的测试项目的订单和导出内容

希望有人能帮助我,我真的很感激

最佳答案

您可以尝试使用waitFor的其他方法:

solo.waitForText(); //if a certain text appears after the loading is done

solo.waitForView(); //if a certain view is shown after the load screen is done.

或者您可以使用

solo.assertCurrentActivity("Expected MyActivity", "MyActivity");

使用一些延迟,例如

Thread.sleep(1500);

solo.sleep(1500);

关于java - 在测试项目中找不到从方法 y 引用的类 x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23503579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com