关于项目自动化测试架构的改良计划 - 对于内容文件动作指令信息

简介:

我们分为3个方法依次对于<add_elements>,<update_elements>,<remove_elements>进行解析:


对于<add_elements>内部遍历解析的代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* add the new information which configured in original xml and finally generate the new xml
*/
publicstaticString addElementToXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc =  null ;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the add information are provided by XMLModifyInfoExtractor
List<AddElement>  addElementInfoList = extractor.getAddElementInfoList();
List<Node> nodes ;
for (AddElement addElement : addElementInfoList){
String testcaseXPath =addElement.getTestcaseXPath();
String path =addElement.getPath();
String value=addElement.getValue();
//make the value as a Element block
Element newElementSnippet = DocumentHelper.parseText(value).getRootElement();         
nodes = doc.selectNodes(path);
for (Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if (nodeUniquePath.indexOf(testcaseXPath) !=- 1 ){
//node.getParent().remove(node);
//node.setText(value);
Element addingPointElement = (Element) node;
addingPointElement.add(newElementSnippet);
}
}
}
returndoc.asXML();
}


对于<update_elements>内部元素进行遍历的代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* update the information which configured in original xml and finally generate the new xml
*/
publicstaticString updateElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc =  null ;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the update information are provided by XMLModifyInfoExtractor
List<UpdateElement>  updateElementInfoList = extractor.getUpdateElementInfoList();
List<Node> nodes ;
for (UpdateElement updateElement : updateElementInfoList){
String testcaseXPath =updateElement.getTestcaseXPath();
String path =updateElement.getPath();
String value=updateElement.getValue();
nodes = doc.selectNodes(path);
for (Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if (nodeUniquePath.indexOf(testcaseXPath) !=- 1 ){
node.setText(value);
}
}
}
returndoc.asXML();
}


对于<remove_elements>中元素进行遍历解析的代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* remove the information which configured in original xml and finally generate the new xml
*/
publicstaticString removeElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc =  null ;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the remove information are provided by XMLModifyInfoExtractor
List<RemoveElement>  removeElementInfoList = extractor.getRemoveElementInfoList();
List<Node> nodes ;
for (RemoveElement removeElement : removeElementInfoList){
String testcaseXPath =removeElement.getTestcaseXPath();
String path =removeElement.getPath();
nodes = doc.selectNodes(path);
for (Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if (nodeUniquePath.indexOf(testcaseXPath) !=- 1 ){
node.getParent().remove(node);
}
}
}
returndoc.asXML();
}



最后,当执行3步骤动作系列转化之后,最终的xml文件就是包含最终的我们修改后的结果了。






本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1221752,如需转载请自行联系原作者
目录
相关文章
|
27天前
|
设计模式 前端开发 测试技术
Flutter 项目架构技术指南
探讨Flutter项目代码组织架构的关键方面和建议。了解设计原则SOLID、Clean Architecture,以及架构模式MVC、MVP、MVVM,如何有机结合使用,打造优秀的应用架构。
Flutter 项目架构技术指南
|
26天前
|
传感器 算法 计算机视觉
基于肤色模型和中值滤波的手部检测算法FPGA实现,包括tb测试文件和MATLAB辅助验证
该内容是关于一个基于肤色模型和中值滤波的手部检测算法的描述,包括算法的运行效果图和所使用的软件版本(matlab2022a, vivado2019.2)。算法分为肤色分割和中值滤波两步,其中肤色模型在YCbCr色彩空间定义,中值滤波用于去除噪声。提供了一段核心程序代码,用于处理图像数据并在FPGA上实现。最终,检测结果输出到&quot;hand.txt&quot;文件。
|
29天前
|
算法 异构计算
m基于FPGA的电子钟verilog实现,可设置闹钟,包含testbench测试文件
该文介绍了基于FPGA的电子钟设计,利用Vivado2019.2平台进行开发并展示测试结果。电子钟设计采用Verilog硬件描述语言,核心包括振荡器、分频器和计数器。时间显示为2个十进制格式,闹钟功能通过存储器和比较器实现,当当前时间等于设定时间时触发。文中给出了Verilog核心程序示例,展示了时钟信号、设置信号及输出的交互。
27 2
|
1月前
|
IDE Linux 编译器
【Linux】项目自动化构建工具 —— make/Makefile
【Linux】项目自动化构建工具 —— make/Makefile
|
30天前
|
SpringCloudAlibaba Java 持续交付
【构建一套Spring Cloud项目的大概步骤】&【Springcloud Alibaba微服务分布式架构学习资料】
【构建一套Spring Cloud项目的大概步骤】&【Springcloud Alibaba微服务分布式架构学习资料】
130 0
|
30天前
|
Java PHP 数据库
在护卫神上部署javaWeb项目,已经测试通过
在护卫神上部署javaWeb项目,已经测试通过
9 0
|
30天前
|
消息中间件 并行计算 网络协议
探秘高效Linux C/C++项目架构:让进程、线程和通信方式助力你的代码飞跃
探秘高效Linux C/C++项目架构:让进程、线程和通信方式助力你的代码飞跃
33 0
|
1月前
|
存储 测试技术 C++
P2P网络下分布式文件共享场景的测试
P2P网络下分布式文件共享场景的测试
31 6
|
1月前
|
算法 异构计算
m基于FPGA的Alamouti编码verilog实现,包含testbench测试文件
m基于FPGA的Alamouti编码verilog实现,包含testbench测试文件
28 5
|
7天前
|
数据采集 存储 API
网络爬虫与数据采集:使用Python自动化获取网页数据
【4月更文挑战第12天】本文介绍了Python网络爬虫的基础知识,包括网络爬虫概念(请求网页、解析、存储数据和处理异常)和Python常用的爬虫库requests(发送HTTP请求)与BeautifulSoup(解析HTML)。通过基本流程示例展示了如何导入库、发送请求、解析网页、提取数据、存储数据及处理异常。还提到了Python爬虫的实际应用,如获取新闻数据和商品信息。

热门文章

最新文章