lac.js
v0.9.1
Published
这是一个loadrunner自动关联工具
Downloads
21
Maintainers
Readme
自动关联脚本工具使用文档
安装Node运行环境
注意版本需要12以上版本的nodejs
下载工具包
在工具包解压文件目录
新增初始化命令
- 使用lac init命令会在当前工作目录(命令行目录)生成默认的配置文件: lac.config.js
有两种应用模式:
1. 双文件组模式(采用差异对比进行关联)
2. 单文件组模式(采用模式匹配差异进行关联)(推荐单文件组模式)
采用全配置的方式 (在配置文件中配置)
输入输出文件夹
- input文件夹里放置对比的两/一组loadrunner录制产生的C文件(即每个动作对应的C文件)及codeGeneratorLog.txt文件(及录制后data目录下的一个请求响应信息文本)
- 如果是单组文件模式,只需放置单组文件即可,但需配置需要关联的属性
然后在nodejs cmd/cmd里跳转至解压的目录
然后输入对应命令,例如你要的对比文件组1 你要的对比文件组2, 比如:
- 以下所有第四个单词开始都是输入的文件名或者文件路径
- 双组文件匹配模式命令是:
- lac diff vuser_init,Action,vuser_end vuser_init1,Action1,vuser_end1
- 单组文件匹配模式命令则是:
- lac sdiff vuser_init,Action,vuser_end
其中空格分隔两组,每组里又用半月符号的逗号,分隔文件
新增两种链式调用模式:
- 其中self_config/lac.diff.config.js是路径文件
- self_config是根目录的文件夹, lac.config.js, lac.diff.config.js是目录下文件,则按以下命令来
- 双组文件链式匹配模式命令是
- lac diffList self_config/lac.diff.config.js
- 单组文件链式匹配模式命令是
- lac sdiffList self_config/lac.config.js
就可以在配置的output文件夹里看到产出做过自动关联的文件
为什么说是部分呢,因为额外请求的自动关联只给出关联函数和关联响应体ID,开发者可以酌情考虑是否配置自动形成额外请求函数;
或者自己手动将额外请求里摘出来形成函数,再关联替换;
除此之外,还有一些字符串关联替换
- 在self_config文件目录下的config.js文件的配置对象中
-
目录层级
--- / //工作目录,即CMD的当前目录
--- self_config
--- config.js // 这是diff、sdiff所需的
--- lac.config.js // 如果是sdiffList、diffList命令的参数是self_config/lac.config.js,那就是这里,否则按你的方式来
单个config如下所示:
多个config用数组形式包含多个config
{
// 输入的文件名,文件名以半月符的,隔开,文件组用空格隔开
// 注意此参数只有链式调用模式需要
inputFilesOfInputDir: 'vuser_init,Action,vuser_end',
// 文件夹,分别为输入、输出、打印
inputDir: 'dev-config/input',
outputDir: 'dev-config/output',
logDir: 'dev-config/log',
// 响应信息文件名
codeGeneratorResponseFileName: `CodeGenerationLog.txt`,
// 是否产生log文件
isCreateLog: true,
// 是否不替换关联参数
// 即关联的不进行全局替换成{...}
isunDoneReplace: false,
// 是否开启引用类型信息比对
// 即是否开启匹配引用类型的数据,而不单止匹配字符串
// 是否注释掉额外请求
isRemoveExtractLastContent: true,
// 输出文件是否改变编码
// 默认utf-8
outPutFileEncoding: 'gbk',
isExposeReplaceHolder: false,
// 是否开启金蝶附加脚本
isKingdeeSky: true,
isOpenJSONDiff: true,
// 是否开启插入附加请求函数的关联,会自动生成额外请求的LoadRunner函数
isOpenInsertExtractFn: true,
//单组文件匹配模式下的配置项
// 是否开启json格式的信息匹配
// 是否开启json格式里的uri信息匹配
singleMode: {
isOpenJSONDiff: true,
// 弃用
// isOpenUriDiff: true,
},
// 因为关联到的参数可能会有冗余
// 为避免性能问题,采用函数过滤,自行输入条件
// 其中参数diffInfo为差异信息,为字符串类型,例如rootd5e322119f6a4a12b9d73e4307d3014c字符串
// 如不需要可以使用return true,不作过滤
patchPropFn(diffInfo) {
// return true;
return diffInfo.length >= 18;
},
// 单组文件匹配模式下的配置项
// 匹配包含有json格式信息里的请求属性
// patchJSONProps: [],
// 匹配json格式信息里的属性
// 包含json格式信息里uri的属性
patchJSONProps: ['selDatas', 'kdedcba'],
// 弃用
// patchJSONObjectProps: ['selDatas'],
// patchUrlParamsProps: ['kdedcba'],
// patchJSONObjectProps: [],
// 匹配json格式信息里uri的属性
// patchUrlParamsProps: [],
// 匹配普通文本的属性
patchProps: ['pageId'],
// 进行字符串关联的配置
saveString: {
// 参数名
"web_host": {
// 原来录制成的值
originalValue: "webUrl",
// Loadrunner字符串关联中的替换字符串值
replaceValue: "webHost"
},
"user_name": {
// 原来录制成的值
originalValue: "useName",
// Loadrunner字符串关联中的替换字符串值
replaceValue: "user_name"
},
"password": {
// 原来录制成的值
originalValue: "password",
// Loadrunner字符串关联中的替换字符串值
replaceValue: "password"
}
}
}