我是第一次进行本教程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;
}
}