我最近在我的主应用程序中创建了一个单元测试项目。但是,当我运行单元测试时,我收到以下错误。
03-19 00:25:50.579: I/TestRunner(12465): android.content.res.Resources$NotFoundException: File RuimockUnitTestTest from xml type layout resource ID #0x7f030000
03-19 00:25:50.579: I/TestRunner(12465): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2391)
03-19 00:25:50.579: I/TestRunner(12465): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2346)
03-19 00:25:50.579: I/TestRunner(12465): at android.content.res.Resources.getLayout(Resources.java:944)
03-19 00:25:50.579: I/TestRunner(12465): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
03-19 00:25:50.579: I/TestRunner(12465): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-19 00:25:50.579: I/TestRunner(12465): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
03-19 00:25:50.579: I/TestRunner(12465): at android.app.Activity.setContentView(Activity.java:1892)
我已经清理了我的项目,删除了 bin 和 gen 文件,但仍然没有希望。有人可以给一些建议吗?帮助表示赞赏。
编辑:
单元测试代码在这里,我还没有编写单元测试:
public class ServerAPITest extends ActivityUnitTestCase<SplashScreen>{
SplashScreen mainActivity;
private Solo solo;
public ServerAPITest(){
super(SplashScreen.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), (SplashScreen)getActivity());
// Starts the MainActivity of the target application
startActivity(new Intent(getInstrumentation().getTargetContext(), SplashScreen.class), null, null);
// Getting a reference to the MainActivity of the target application
mainActivity = (SplashScreen)getActivity();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
solo.finishOpenedActivities();
}
@SmallTest
public void testHello() throws Throwable{
//TODO Test Function
}
}