目录
一、背景介绍
二、Monkey诞生
1. 出发点
2. 核心能力介绍
2.1 Monkey端侧自动化能力
2.2 Monkey平台化能力建设
2.3 Monkey自动化测试核心流程
三、Monkey创新过程
1. 智能模拟用户行为
2. Monkey结合B端组件测试
2.1 结合大仓组件能解决什么问题
2.2 结合大仓组件实践
2.2.1 ProTable单品类组件行为分析&拆解实战
2.2.1.1 操作行为分析
2.2.1.2 拆解步骤
2.2.1.3 注意事项
2.2.2 ProForm单品类组件行为分析&拆解实战
2.2.2.1 操作行为分析
2.2.2.2 拆解步骤
2.2.2.3 ProForm准确提交率
2.3 表单项数据填充
2.3.1 表单项 - Input types 通用填充
2.3.2 表单项 - 精准填充
3. 实时验证前后端接口参数一致性
4. 自动化错误捕获
4.1 错误类型分类
4.2 常规错误捕获
5. 用例模型定制化配置
四、Monkey可行性探索情况
1. 数据分析
2. 有效错误率统计
五、总结 & 规划
Monkey , 也有人叫做搞怪测试,一般指用毫无规律的指令或操作去测试被测系统,观察被测系统的稳定性。
出发点
核心能力介绍
Monkey端侧自动化能力
Monkey平台化能力建设
Monkey自动化测试核心流程
智能模拟用户行为
Monkey结合B端组件测试
结合大仓组件能解决什么问题
结合大仓组件实践
01
ProTable单品类组件行为分析&拆解实战
操作行为分析
拆解步骤
注意事项
// 检查一个元素是否在另外一个元素中 原理类似于JQ $("#container").has(".selector");
const isSafeArea = (parentElement, childElement) => {
const childClassNames = Array.from(childElement.classList);
return childClassNames.every(className => parentElement.querySelector(`.${className}`));
};
const layoutContentElement = document.querySelector('.layout-content');
const isisSafeAreaResult = isSafeArea(layoutContentElement,element)
element.matches('a')
02
ProForm单品类组件行为分析&拆解实战
操作行为分析
拆解步骤
ProForm准确提交率
表单项数据填充
01
表单项 - Input types 通用填充
B端系统未接入类型检测工具, 接口请求参数类型约束不严格。Monkey 会根据 Input Types 类型随机生成字符串,填充表单项以触发接口调用,发现接口参数类型错误。
// input type 集合
const defaultMapElements = {
textarea: fillTextAreaElement,
'input[type="text"]': fillTextElement,
'input[type="password"]': fillTextElement,
'input[type="number"]': fillNumberElement,
select: fillSelect,
'input[type="radio"]': fillRadio,
'input[type="checkbox"]': fillCheckbox,
'input[type="email"]': fillEmail,
'input:not([type])': fillTextElement,
};
// 填充逻辑
const fillTextElement = async (element, character) => {
const selectedCharacters = Array.from({ length: 5 }, () =>randomizer.getCharacter[Math.floor(Math.random() * randomizer.getCharacter.length)]).join('');
const newValue = element.value + (character ? character : selectedCharacters);
if (element) {
triggerSimulatedOnChange(element, newValue, window.HTMLInputElement.prototype);
return newValue;
}
};
// Hacky function to trigger react, angular & vue.js onChange on input
const triggerSimulatedOnChange = (element, newValue, prototype) => {
const lastValue = element.value;
element.value = newValue;
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
nativeInputValueSetter.call(element, newValue);
const event = new Event('input', { bubbles: true }) as CustomEvent;
// React 15
event.simulated = true;
// React >= 16
let tracker = element._valueTracker;
if (tracker) {
tracker.setValue(lastValue);
}
element.dispatchEvent(event);
};
02
表单项 - 精准填充
实时验证前后端接口参数一致性
自动化错误捕获
错误类型分类
常规错误捕获
用例模型定制化配置
数据分析
有效错误率统计
往期回顾
“
扫码添加小助手微信
如有任何疑问,或想要了解更多技术资讯,请添加小助手微信: