关于项目自动化测试架构的改良计划 - 分离出动作指令信息

简介:

但是,我们这些动作指令信息毕竟是让测试用例数据的设计者告诉Engine怎样修改原始数据集合的,所以我们必须把这些信息分离出来,但是刚才一步骤,已经把这些片断移除了,那么怎么把这些信息拿到呢?很简单,不是我们有原始数据么,所以我们就可以对于原始数据的xml字符串,一个testcase,一个testcase的吧这些动作指令解析出来并且存放在相应的Value Object 列表中,以后我们只要根据这些列表中提供的信息就可以正确的对于原来的数据集合进行操作了。


分离信息的类叫XMLModifyInfoExtractor,它负责分离动作:

代码如下:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
      * extract all the modification information and store to member fields.
      * @param filePath
      * @throws Exception
      */
     public  void  extractModifyInfo(String filePath)  throws  Exception{
              
         SAXReader reader =  new  SAXReader();
         Document document = reader.read( new  File(filePath));
              
         Element rootElement = document.getRootElement();
              
         String testcaseElementPathValue;
              
              
         Element addElements;
         Element addElementPath;
         String addElementPathValue;
         Element addElementValue;
         String addElementValueValue;
              
         Element updateElements;
         Element updateElementPath;
         String updateElementPathValue;
         Element updateElementValue;
         String updateElementValueValue;
              
         Element removeElements;
         Element removeElementPath;
         String removeElementPathValue;
              
         //first ,get all the <test_case> element
         List<Element> testcaseElementList = rootElement.elements( "test_case" );
         for (Element testcaseElement : testcaseElementList){
                  
             testcaseElementPathValue = testcaseElement.getUniquePath();
                  
             //get <add_elements> part from the <test_case>
             addElements= testcaseElement.element( "add_elements" );
             if (addElements!= null ){
                      
             //traverse the <add_elements> to get a seris of <add_element>
             List<Element> addElementList = addElements.elements( "add_element" );
             for (Element addElement : addElementList){
                 //extract the <path> information from <add_element>
                 addElementPath = addElement.element( "path" );
                 addElementPathValue = addElementPath.getTextTrim();
                 //extract the <value> information from <add_element>
                 addElementValue = addElement.element( "value" );
                      
                      
                 String xmlValue=addElementValue.asXML();
                 //remove the <value> and </value> part from this xml
                 addElementValueValue=xmlValue.replace( "<value>" , "" ).replace( "</value>" , "" );
                 addElementInfoList.add
                 ( new  AddElement(testcaseElementPathValue,addElementPathValue,addElementValueValue));
             }
                  
             }
                  
             //get <update_elements> part from the <test_case>
             updateElements= testcaseElement.element( "update_elements" );
             if (updateElements!= null ){
                      
                  
             //traverse the <update_elements> to get a seris of <update_element>
             List<Element> updateElementList = updateElements.elements( "update_element" );
             for (Element updateElement : updateElementList){
                 //extract the <path> information from <update_element>
                 updateElementPath = updateElement.element( "path" );
                 updateElementPathValue = updateElementPath.getTextTrim();
                 //extract the <value> information from <update_element>
                 updateElementValue = updateElement.element( "value" );
                 updateElementValueValue=updateElementValue.getTextTrim();
                      
                 updateElementInfoList.add
                 ( new  UpdateElement(testcaseElementPathValue,updateElementPathValue,updateElementValueValue));
             }
                  
             }
                          
                  
             //get <remove_elements> part from the <test_case>
             removeElements= testcaseElement.element( "remove_elements" );
             if (removeElements !=  null ){
                      
                  
             //traverse the <remove_elements> to get a seris of <remove_element>
             List<Element> removeElementList = removeElements.elements( "remove_element" );
             for (Element removeElement : removeElementList){
                 //extract the <path> information from <remove_element>
                 removeElementPath = removeElement.element( "path" );
                 removeElementPathValue = removeElementPath.getTextTrim();
                      
                 removeElementInfoList.add( new  RemoveElement(testcaseElementPathValue,removeElementPathValue));
             }
                  
             }
         }
              
                          
     }


现在经过上述3步骤之后,我们的代码中所有的动作序列的执行内容都被存放在相应变量中了。





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1221749,如需转载请自行联系原作者
目录
相关文章
|
运维 监控 Cloud Native
自动化运维的魔法书云原生之旅:从容器化到微服务架构的演变
【8月更文挑战第29天】本文将带你领略自动化运维的魅力,从脚本编写到工具应用,我们将一起探索如何通过技术提升效率和稳定性。你将学会如何让服务器自主完成更新、监控和故障修复,仿佛拥有了一本能够自动翻页的魔法书。
|
人工智能 Linux API
PromptWizard:微软开源 AI 提示词自动化优化框架,能够迭代优化提示指令和上下文示例,提升 LLMs 特定任务的表现
PromptWizard 是微软开源的 AI 提示词自动化优化框架,通过自我演变和自我适应机制,迭代优化提示指令和上下文示例,提升大型语言模型(LLMs)在特定任务中的表现。本文详细介绍了 PromptWizard 的主要功能、技术原理以及如何运行该框架。
1580 8
PromptWizard:微软开源 AI 提示词自动化优化框架,能够迭代优化提示指令和上下文示例,提升 LLMs 特定任务的表现
|
存储 缓存 运维
阿里云先知安全沙龙(上海站)——后渗透阶段主机关键信息自动化狩猎的实现与应用
本文介绍了在后渗透测试中使用LSTAR工具和PowerShell脚本进行RDP状态查询、端口获取及凭据收集的过程,强调了高强度实战场景下的OPSEC需求。通过MITRE ATT&CK框架的应用,详细阐述了凭证访问、发现和收集等关键技术,确保攻击者能够隐蔽、持续且高效地渗透目标系统,最终获取核心数据或控制权。文中还展示了SharpHunter等工具的自动化实现,进一步提升了操作的安全性和效率。
|
运维 监控 安全
自动化运维的利剑:Ansible在现代IT架构中的应用
在数字化浪潮中,企业对IT系统的敏捷性和可靠性要求日益提高。Ansible,一种简单但强大的自动化运维工具,正成为现代IT架构中不可或缺的一部分。它通过声明式编程语言YAM,简化了系统配置、应用部署和任务自动化的过程,显著提升了运维效率和准确性。本文将深入探讨Ansible的核心特性、应用场景以及如何有效整合进现有IT环境,为读者揭示其在自动化运维中的实用价值和未来发展潜力。
|
Serverless 决策智能 UED
构建全天候自动化智能导购助手:从部署者的视角审视Multi-Agent架构解决方案
在构建基于多代理系统(Multi-Agent System, MAS)的智能导购助手过程中,作为部署者,我体验到了从初步接触到深入理解再到实际应用的一系列步骤。整个部署过程得到了充分的引导和支持,文档详尽全面,使得部署顺利完成,未遇到明显的报错或异常情况。尽管初次尝试时对某些复杂配置环节需反复确认,但整体流程顺畅。
447 3
|
存储 人工智能 编译器
【AI系统】CPU 指令集架构
本文介绍了指令集架构(ISA)的基本概念,探讨了CISC与RISC两种主要的指令集架构设计思路,分析了它们的优缺点及应用场景。文章还简述了ISA的历史发展,包括x86、ARM、MIPS、Alpha和RISC-V等常见架构的特点。最后,文章讨论了CPU的并行处理架构,如SISD、SIMD、MISD、MIMD和SIMT,并概述了这些架构在服务器、PC及嵌入式领域的应用情况。
2329 5
|
运维 Devops 应用服务中间件
自动化运维的利剑:Ansible在现代IT架构中的应用
【10月更文挑战第42天】本文旨在揭示自动化运维工具Ansible如何革新现代IT架构,通过简化配置管理和部署流程,提升效率和可靠性。我们将探索Ansible的核心功能、语言特性以及其在DevOps文化中的角色。文章还将展示如何借助Ansible构建模块化和可重用的配置代码,实现快速迭代与部署,并确保系统一致性。通过阅读本文,运维人员将了解如何利用Ansible优化日常任务,加速产品上线速度,同时提高系统的稳健性。
502 5
|
数据采集 监控 数据挖掘
CSV文件自动化生成:用Pandas与Datetime高效处理京东商品信息
在电商竞争激烈的背景下,实时掌握商品价格和库存信息至关重要。本文介绍如何使用Python的`pandas`和`datetime`库从京东抓取商品名称、价格等信息,并生成CSV文件。结合代理IP技术,提升爬取效率和稳定性。通过设置请求头、使用代理IP和多线程技术,确保数据抓取的连续性和成功率。最终,数据将以带时间戳的CSV文件形式保存,方便后续分析。
832 2
|
运维 分布式计算 大数据
自动化运维的利剑:Ansible在现代IT架构中的应用
【7月更文挑战第16天】本文深入探讨了Ansible作为自动化运维工具的核心价值及其在现代IT架构中的多维度应用。我们将通过具体案例分析,揭示Ansible如何优化IT运维流程、提升工作效率,并讨论其在云环境、容器化及大数据处理等领域的创新应用。文章旨在为读者提供一套实用的Ansible应用策略,助力企业构建更加高效、稳定的IT运维体系。
|
弹性计算 运维 Kubernetes
自动化运维的新篇章:容器编排与微服务架构
【7月更文挑战第14天】在数字化转型的浪潮中,企业对运维效率和系统可靠性的需求日益增长。本文深入探讨了自动化运维的最新趋势——容器编排和微服务架构,并阐述了如何通过这些技术提升运维效率、降低系统复杂性以及提高服务的可用性和可扩展性。文章不仅介绍了相关技术和工具的选择,还提供了实际案例分析,旨在为读者提供一套完整的解决方案框架,以适应快速变化的市场需求。

热门文章

最新文章