Android黑盒自动化测试框架Robotium
作者:网络转载 发布时间:[ 2015/8/12 13:29:22 ] 推荐标签:自动化测试 软件测试
用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
这个为远程接口的调用问题
相关推荐
更新发布
功能测试和接口测试的区别
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