录制模式:功能测试阶段操作应用,自动记录启动 Activity 所需参数,供其他模式使用。
录制模式:360°无死角录制每个 Activity,一劳永逸。(之后无需重复录制)
Tag
Activity: com.abc.MyGroupActivity
String Type int 1
String projectId int 0
String title String
String commentId int 0
Tag
Activity: com.abc.search.ui.SearchAdActivity
String type int 7
String typeName String 发现群
Tag
Activity: com.abc.group.ui.CreateGroupActivity
String CreateGroupGrade int 1
String GroupMemberLimit int 100
参数经过处理后变成 json 格式文件
快速模式或迭代模式读取 json 文件
代码节选
/**
* Reads the json file, generates the parameters required for the iteration, and ignores part of the activity.
* @throws Exception
*/
private void handleParams() throws Exception {
String json = FileUtils.readJson();
Log.i(LOG_TAG, "json: " + json);
ArrayList<Params> arrayList = filterActivities(JsonParser.fromJson(json), activityUtils.getAllActivities(context));
Log.d(LOG_TAG, "Params size: " + arrayList.size());
for (Params params : arrayList) {
boolean isIgnore = false;
Log.d(LOG_TAG, "Activity: " + params.name);
if(config.mode == Config.Mode.REPTILE && params.name.contains(config.homeActivity))continue;
for (String name: config.ignoreActivities) {
if (params.name.contains(name)) {
isIgnore = true;
break;
}
}
Log.d(LOG_TAG, "Ignore: " + isIgnore);
if (!isIgnore) {
Map<String, Object> hashMap = new HashMap<String, Object>();
for (Param param : params.params) {
Log.d(LOG_TAG, param.key + " " + param.value);
hashMap.put(param.key.split("\\|")[1], IntentParser.parseType(param.value));
}
iteration(params.name, hashMap.isEmpty() ? null : hashMap,
config.mode != Config.Mode.FAST && params.iteration, params.web);
}
}
}
一触即达的凶残方式
举例:
通过读取 json 文件获取相应参数直接启动 Activity
json 文件节选
[
{
"iteration": true,
"name": "com.abc.search.ui.SearchAdActivity",
"params": [
{
"key": "String|typeName",
"value": "String|发现群"
},
{
"key": "String|type",
"value": "int|7"
}
]
},
{
"iteration": true,
"name": "com.abc.UserInfoActivityV2",
"params": [
{
"key": "String|UserId",
"value": "int|3511"
},
{
"key": "String|UserType",
"value": "int|1"
},
{
"key": "String|DongCircle",
"value": "boolean|true"
},
{
"key": "String|FromGroup",
"value": "boolean|false"
},
{
"key": "String|ReceiverUserUId",
"value": "int|0"
},
{
"key": "String|ReceiverGroupUserType",
"value": "int|0"
}
]
}
]
这个部分涉及的模块比较多(不好提取)就不分享了,完整的自动遍历近期会上传 Github。
好像没什么要说的,如有错误请轻拍。