Android??????????????Robotium
???????????? ???????[ 2015/8/12 13:29:22 ] ????????????????? ???????
??????Robotium?????Android???к?е?????????????????????????????????????Щ????????????????????????????????????????????????????3????
??????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
???????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11