android - 用于活动的 Android Studio 单元测试
问题描述
我正在关注本教程https://www.youtube.com/watch?v=_TR6QcRozAg ,这是我第一次进行 android studio 活动单元测试,但在代码中出现了一些错误,其中“ActivityTestRule”和“getClass()”显示为红色.无法运行代码
package e.asus.supershop;
import android.view.View;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.*;
public class LoginActivityTest {
@Rule
public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<LoginActivity>(LoginActivity.class);
private LoginActivity mActivity = null;
@Before
public void setUp() throws Exception {
mActivity = mActivityTestRule.getClass();
}
@Test
public void testLaunch()
{
View view = mActivity.findViewById(R.id.buttonSignin);
assertNotNull(view);
}
@After
public void tearDown() throws Exception {
mActivity = null;
}
}
解决方案
推荐阅读
- c# - 我无法评估 c# 中的高度,当我引入一个小于 1.5 的数字时仍然说进来
- api - 使用 REST API 的 Sharepoint 身份验证 - 邮递员
- c++ - 是否可以在另一个模板参数的模板参数中声明模板参数?
- python - 如何将 JSON 对象键拆分为多个键,并相应地使用它们的值(最好在 R 中)?
- java - 无法获取将文件上传到 PHP 服务器的 Java 方法
- kubeflow - KubeFlow 中 TFX 标准组件的等价物
- oracle - 在 ADW 中使用 UTL_FILE
- android - 添加库以输入 Android C++ Visual Studio Clang exit -1
- docker - Docker Compose HAProxy 负载均衡器问题
- mobile - 会员插件的两个单独菜单