OData服务的API自动化测试

 2022-08-29 09:08

论文总字数:46995字

摘 要

Web时代着力于为用户提供更快、更高效、更稳定的产品和服务,敏捷开发与持续交付的采用率不断上升,Web产品无时无刻都在变化。API自动化测试是保证高复杂性系统质量的内在要求和低成本的经济利益的驱动作用下的最佳解决方案。开放数据协议(OData) 是一个查询和更新数据的完全符合REST原则的Web协议,最初由微软提倡,OData已经赢得了众多追捧者。因此,工业中对OData API的自动化测试也开始有了迫切的需求。

本课题的设计目的是对实现了RESTful 的OData Web项目,用脚本实现API层级的自动化测试,并搭建基于SoapUI、Maven、Git、Jenkins的可持续集成环境,从而完成对测试脚本的自动化构建和分析,最终完成对项目API功能的验证,帮助提高项目服务的可靠性。

本文实现API自动化测试的主要技术路线如下:基于SoapUI实现API测试脚本,使用Maven管理和自动化构建测试脚本,利用Git对测试项目进行版本控制,再搭建Jenkins的持续集成环境,在Roadmap Viewer的开发系统和测试系统发布新版本时,自动触发测试脚本的运行和分析,并将测试结果发送到代码成员邮箱,为其提供丰富的反馈信息。

关键词:API,SoapUI, OData,自动化测试 ,Jenkins,Maven

Method and Implementation of OData Service API Automation Test Based on SoapUI

ABSTRACT

The era of Web focuses on offering faster, more efficient and more stable product and services for customers, which results in the increasing adoption of agile and continuous delivery, and the Web products is changing all the time under its influence. In this situation, the API automated testing is the best solution for not only ensuring the inherent requirements of high complexity system quality, but also satisfying low-cost economic benefits. Therefore, the API automated testing has been placed more and more emphasize. The Open Data Protocol (OData) is a Web protocol for querying and updating data. It is fully compliant with REST principles, which allows requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless operations. The OData is initially advocated by Microsoft, and it has won a number of sought-after later. Therefore, the industrial OData API automated testing began to be urgent needs in order to ensure the quality of Web projects using OData.

The purpose of this project is to implement automated testing on the API level of the RESTful OData Web project by using script, and build up sustainable integration environment based on SoapUI, Maven, Git and Jenkins, thereby complete the automated construction and analysis on the testing script. The project will finally complete verification on the API function of a Web project, and to help improve the reliability of the project services.

In this paper, the main technical route of API automation testing is as follows: Implementing API test script based on SoapUI, using Maven for management and construction of the testing script automatically. Using Git for version controlling of the testing project, it is of great importance in large-scale projects and team working. Then building Jenkins continuous integration environment to automatically trigger the operation and analysis of the testing script in Roadmap Viewer development and testing system when a new version is released, and the test results will be sent to the mailbox of the team members to provide a wealth of feedback.

Keywords:API,SoapUI, OData,Automation Test,Jenkins,Maven

目 录

摘 要 I

ABSTRACT II

第一章 绪论 1

1.1 课题研究背景与研究意义 1

1.2 研究现状 2

1.3 本课题的主要工作 3

1.4 本章小结 4

第二章 相关技术分析 5

2.1 REST体系架构 5

2.2 OData 开放数据协议 6

2.3 SoapUI API测试工具 8

2.3.1 SoapUI简介 8

2.3.2 SoapUI支持Groovy Script 10

2.3.3 SoapUI中的属性和传值模式 10

2.4 本章小结 11

第三章 API自动化测试方案的研究 12

3.1 API自动化测试框架 12

3.1.1 总体测试框架 12

3.1.2 SoapUI 开源版vs. JMeter 12

3.2 设计Roadmap Viewer API测试用例 13

3.2.1 归纳API测试范畴 13

3.2.2 准备测试用例数据 15

3.3 基于SoapUI的测试方法设计 17

3.3.1 准备测试环境数据 17

3.3.2 API测试方法 19

3.4 本章小结 20

第四章 基于SoapUI对OData API测试的实现 21

4.1 创建REST服务和资源定义 21

4.2 单点登录 23

4.3 上传测试环境数据 29

4.4 Function Import测试 32

4.5 EntitySet相关测试 39

4.6 Access Level测试 43

4.7 本章小结 48

第五章 API测试自动化持续集成平台的实现 49

5.1 SoapUI-Maven集成 49

5.2 Maven-Git-Jenkins集成 50

5.3 记录和跟踪API自动化测试错误 55

5.4 本章小结 57

第六章 结论与展望 58

6.1结论 58

6.2工作展望 58

致 谢 60

参考文献 61

第一章 绪论

1.1 课题研究背景与研究意义

近年来Web应用变得越来越复杂,通常需要把一个复杂的系统划分成小的组成部分,这时就体现了编程接口的设计的重要性。良好的接口设计可以使软件系统的职责得到合理划分,从而降低系统之间各个部分的依赖,提高组成单元的内聚性,降低组成单元间的耦合程度,从而提高系统的扩展性和可维护性[[1]]。API(Application Programming Interface)测试是软件测试中最基本的一种类型,是保证高复杂性系统质量的内在要求和低成本的经济利益的驱动作用下的最佳解决方案。

接口测试是保证高复杂性系统质量的内在要求和低成本的经济利益的驱动作用下的最佳解决方案[[2]]。主要体现在下面的三个方面: (1) 接口测试节省了测试成本,根据数据模型推算,底层的一个错误可能会引起上层的八个错误,并且底层错误很可能会引起应用直接宕机。系统复杂度上升情况下,相反接口测试能够提供高效率低成本的解决方案。 (2) 有别于传统的单元测试,接口测试时在用户角度上对系统进行更高层次的全面的检测。 (3) 接口测试便于进行自动化和持续集成,这也是促成接口测试高效率低成本的根本原因。

剩余内容已隐藏,请支付后下载全文,论文总字数:46995字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;