用Robotium打算对Android进行黑盒的自动化测试,在用例子进行实践的时候出现了一些问题,现在不知道怎么解决,暂时记录下来,期待有人帮助或者自己重新尝试。 在TestMain.java中出现以下问题: package com.calculator.test; import java.util.ArrayList; import android.test.ActivityInstrumentationTestCase2; import android.widget.EditText; import android.widget.TextView; import com.calculator.Main; import com.calculator.R; import com.jayway.android.robotium.solo.Solo; public class TestMain extends ActivityInstrumentationTestCase2<Main> { private Solo solo; public TestMain() { super("com.calculator", Main.class); } @Override protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); } public void testDisplayBlackBox() { //Enter 10 in first editfield solo.enterText(0, "10"); //Enter 20 in first editfield solo.enterText(1, "20"); //Click on Multiply button solo.clickOnButton("Multiply"); //Verify that resultant of 10 x 20 assertTrue(solo.searchText("200")); } public void testDisplayWhiteBox() { //Defining our own values to multiply float firstNumber = 10; float secondNumber = 20; float resutl = firstNumber * secondNumber ; //Access First value (editfiled) and putting firstNumber value in it EditText FirsteditText = (EditText) solo.getView(R.id.EditText01); solo.enterText(FirsteditText, String.valueOf(firstNumber)); //Access Second value (editfiled) and putting SecondNumber value in it EditText SecondeditText = (EditText) solo.getView(R.id.EditText02); solo.enterText(SecondeditText, String.valueOf(secondNumber)); //Click on Multiply button solo.clickOnButton("Multiply"); assertTrue(solo.searchText(String.valueOf(resutl))); TextView outputField = (TextView) solo.getView(R.id.TextView01); ArrayList currentTextViews = solo.getCurrentTextViews(outputField); assertFalse(currentTextViews.isEmpty()); TextView output = (TextView) currentTextViews.get(0); //Assert to verify result with visible value assertEquals(String.valueOf(resutl), output.getText().toString()); } @Override protected void tearDown() throws Exception{ solo.finishOpenedActivities(); } } 问题为: the import com.calculator.Main cannot be resolved the import com.calculator.R cannot be resolved 这个为远程接口的调用问题