WO2012174946A1 - 软件自动测试的方法及系统 - Google Patents

软件自动测试的方法及系统 Download PDF

Info

Publication number
WO2012174946A1
WO2012174946A1 PCT/CN2012/074697 CN2012074697W WO2012174946A1 WO 2012174946 A1 WO2012174946 A1 WO 2012174946A1 CN 2012074697 W CN2012074697 W CN 2012074697W WO 2012174946 A1 WO2012174946 A1 WO 2012174946A1
Authority
WO
WIPO (PCT)
Prior art keywords
module
message
use case
response
test
Prior art date
Application number
PCT/CN2012/074697
Other languages
English (en)
French (fr)
Inventor
林明东
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012174946A1 publication Critical patent/WO2012174946A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Definitions

  • Embodiments of the present invention relate to the field of computer communications, and in particular, to a method and system for automatic software testing. Background technique
  • Automated testing has been widely used in various software testing activities. Automated testing can not only easily simulate various normal or abnormal conditions, but also save a lot of time and manpower and improve testing efficiency.
  • the software automatic test system can be generally divided into a control module, a drive module and a pile module.
  • the control module coordinates the entire automatic test flow, and the drive module drives the test message according to the test case construction request message to the object to be tested, and the pile module is used to give the test object.
  • the test object provides data support needed for the operation.
  • the main purpose of the embodiments of the present invention is to provide a software automatic testing method and system, which can It can effectively and automatically test various interfaces of multiple input and multiple output modes, support various types of input and output interface types such as network message/file/database, and support flexible 1+N mode (ie, 1 drive module + N pile modules). deploy.
  • an embodiment of the present invention provides a method for software automatic testing, which includes the following steps:
  • the control module saves all test cases in a cache; the test cases include response use cases, request use cases, and expected response use cases;
  • control module After the test starts, the control module notifies the response module to the stub module according to the message type, and notifies the request module and the expected response use case to the driver module;
  • the driving module calls the preset message communication module to send the encapsulated request use case message to the object to be tested, so as to cause the test object to send the request message supported by the request data to the stub module;
  • the stub module invokes a preset message protocol module to perform a message field adjustment on the response use case according to the request message sent by the measured object, so as to meet the requirement of the running data of the measured object;
  • the driving module receives the response message of the measured object, and the calling message protocol module parses the response message, compares it with the expected response use case message, and confirms whether the current use case passes the test.
  • the driving module invokes the message communication module to send the encapsulated request use case message to the object to be tested, so as to cause the test object to send the request message support request message to the stub module:
  • the stub module performs a message field adjustment on the response use case according to the request message sent by the test object, so as to meet the requirements of the test object running data, including:
  • the message field is adjusted for the original encapsulated response use case to meet the needs of the measured object running data
  • the adjusted response use case is responded to the object under test.
  • the method further comprises:
  • the control module records the execution of the use case into the test log
  • the control module checks if all use cases have been executed. If there are test cases, the next test case is retrieved for the next round of use case automatic test; otherwise, the test ends.
  • the embodiment of the invention further provides a system for software automatic testing, comprising a control module, a driving module, a stub module, a message communication module and a message protocol module, wherein:
  • control module configured to save all test cases in a cache;
  • the test cases include a response use case, a request use case, and an expected response use case; and, after the test starts, notify the response module to the stub module according to the message type, and the request use case And the expectation response use case notification to the driver module;
  • the driver module configured to invoke the preset message communication module to send the encapsulated request use case message to the object to be tested, to cause the test object to send the request message support request message to the stub module; And receiving a response message of the measured object, invoking the message protocol module to parse the response message, and comparing the result to the expected response use case message, and confirming whether the current use case passes;
  • the stub module is configured to, according to the request message sent by the measured object, invoke a preset message protocol module to adjust the message field of the response use case to meet the requirement of the running data of the measured object.
  • the driving module is specifically configured to:
  • the pile module is specifically configured to:
  • the message field is adjusted for the original encapsulated response use case to meet the needs of the measured object running data
  • the adjusted response use case is responded to the object under test.
  • control module is specifically configured to:
  • the method or system for automatically testing software provided by the embodiments of the present invention can process one-end input use cases, multi-end output to various types of piles, message fields can be customized, and response cases can support regular wildcard comparisons, so that test cases can Support multiple message types and flexible configuration.
  • Related test cases can be saved in a unified manner, which is convenient for saving, transferring and loading, which greatly improves the efficiency of function fast regression testing after code reconstruction.
  • the embodiment of the present invention can separately deploy the driving module and the pile module according to requirements, so that the testing environment is more in line with the actual operating environment.
  • FIG. 1 is a flowchart of a method for automatic software testing according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for automatic software testing according to another embodiment of the present invention
  • FIG. 3 is a flowchart of a method for automatic software testing according to another embodiment of the present invention
  • FIG. 4 is an automatic software testing method according to an embodiment of the present invention
  • FIG. 5 is a schematic flowchart of a system for automatically testing software according to an embodiment of the present invention.
  • FIG. 1 shows a method flow of software automatic testing in an embodiment of the present invention, the flow The process is based on a test system including a control module, a drive module, a plurality of stub modules, a message protocol module, and a message communication module.
  • the method includes the following steps:
  • Step S10 preset a message communication module for sending or receiving a message, and a message protocol module for encapsulating or parsing the message; specifically, the message protocol module is configured to encapsulate or parse the request use case or the response use case by message type.
  • the message communication module is used to send encapsulated request use cases and receive response use cases.
  • the message protocol module encapsulates the request use case from the driver module and the response use case of the stub module; parses the request message and response message from the object under test.
  • the message communication module sends the request case encapsulated by the message protocol module to the object to be tested, or receives the request message sent by the object under test and sends it to the message protocol module for parsing.
  • Step S20 The control module saves all the test cases in the cache; the test cases include response use cases, request use cases, and expected response use cases; and the control module includes use case management sub-blocks for various link information, request use cases, and responses. Use case and expectation response use case management.
  • the control module calls the use case management sub-block to load all the test cases and save them in the cache.
  • Step S30 after the test starts, the control module notifies the response use case to the stub module according to the message type, and notifies the request case and the expected response use case to the driver module; the notification mode is not limited to function call, Socket notification, and the like.
  • step S30 may include: First, the control module retrieves a test case that needs to be executed currently; then, the response use case in the test case is notified to the stub module, and waits for feedback from the stub module. If the notification stub module is successful, the request use case and the pending response use case in the test case are notified to the driver module.
  • the stub module can have N, N is an integer greater than 1, and is configured on demand. The control module can automatically notify which specific stub module according to the message type.
  • Step S40 The driver module invokes the message communication module to send the encapsulated request use case message to the object to be tested, so as to cause the test object to send the request message supported by the request data to the stub module;
  • Step S50 The stub module performs a message field adjustment on the response use case according to the request message sent by the tested object, so as to meet the requirement of the running data of the measured object;
  • Step S60 the driver module receives the response message of the measured object, and invokes the message protocol module to parse The response message is compared with the expected response use case message to confirm whether the current use case passes the test.
  • the message field can be customized, and the response use case supports the regular wildcard comparison, so that the test case can support multiple message types and the configuration is flexible.
  • FIG. 2 a workflow of a software automatic test system in a specific example of the present invention is shown, which in turn includes the following steps:
  • Step S101 The control module notifies the stub module of the response use case
  • Step S102 The control module notifies the control module of the request use case and the expected response use case.
  • Step S103 The driving module invokes the message protocol module to encapsulate the request use case.
  • Step S104 The driving module invokes the message communication module to send the encapsulated request use case to the object to be tested.
  • Step S105 The measured object receives the request use case, causing the measured object to perform an internal operation.
  • Step S107 The stub module receives the test object request message, and analyzes and responds to the original control module to notify the necessary use case.
  • Step S108 The stub module sends the adjusted response use case response to the measured object.
  • Step S109 After receiving the response use case of the stub module, the measured object causes internal operation of the measured object.
  • Step S110 After the internal object operation operation is performed, the object to be tested responds to the driver module message.
  • Step S111 The driving module invokes the message protocol module to parse the response message, and compares the parsed response message with the expected response use case message notified by the original control module to determine whether the current use case passes.
  • the processing procedure of the driving module may specifically include:
  • step S60 Enter the waiting state of the object to be tested, and determine whether the response of the measured object is received. If yes, step S60 is performed. If no, the message that the test object response message fails is received, for example, the received message has an error, the measured object times out, and the response does not respond.
  • the processing of the stub module may specifically include:
  • the adjusted response use case is responded to the object under test.
  • the method may further include: Step S70: The control module records the current use case execution status into the test log.
  • the control module further includes the test.
  • the log sub-block is used to record the test operation log in real time, format the log on the interface, and output the final test result log.
  • Step S80 The control module checks whether all the use cases are executed. If there are test cases, the next test case is called to perform the next round of use case automatic test; otherwise, the test ends.
  • the software automatic test method provided by the embodiment of the invention can process one end input use case, multi-end output to various types of piles, the message field can be customized, and the response use case supports regular wildcard comparison, so that the test case can support multiple messages.
  • Type and configuration are flexible.
  • Related test cases can be saved in a unified manner, which is convenient for saving, transferring and loading. It greatly improves the efficiency of fast regression testing after code refactoring.
  • the embodiment of the present invention can separately deploy the driving module and the pile module as needed, so that the testing environment is more in line with the actual operating environment.
  • the embodiment of the invention further provides a software automatic test system for implementing the above method.
  • the system includes a control module 10, a drive module 20, a stub module 30, a message communication module 40, and a message protocol module 50, where:
  • the control module 10 is configured to save all test cases in a cache; the test cases include a response use case, a request use case, and an expected response use case; and the control module 10 includes a use case management sub-block 11 for various link information, requests Management of the use case, the response use case, and the expected response use case. In this step, the control module 10 calls the use case management sub-block 11 to load all the test cases and save them in the cache.
  • the control module 10 After the test is started, the control module 10 notifies the response module to the stub module 30 according to the message type, and notifies the request module and the expected response use case to the driver module 20; the notification mode of the control module 10 is not limited to the function call, the Socket notification, or the like.
  • the control module 10 first retrieves the test case that needs to be executed currently; then notifies the stub module 30 of the response use case in the test case and waits for feedback from the stub module 30. If the notification stub module 30 is successful, the request use case and the expected response use case in the test case are notified to the drive module 20.
  • the pile module 30 can have N, N is an integer greater than 1, and the control module 10 can automatically notify which specific pile module according to the message type.
  • the driving module 20 is configured to send the encapsulated request use case message to the object to be tested, so as to cause the test object to send the request message supported by the request data to the stub module 30.
  • the message protocol module 50 is arranged to encapsulate or parse the request or response use case by message type.
  • the message communication module 40 is arranged to send the encapsulated request use case and the receive response use case.
  • the message protocol module 50 encapsulates the request use case from the driver module 20 and the response use case of the stub module; parses the request message and the response message from the object under test.
  • the message communication module 40 sends the request case encapsulated by the message protocol module 50 to the object to be tested, or receives the request message sent by the object to be tested and sends it to the message protocol module 50 for parsing.
  • the stub module 30 is configured to, according to the request message sent by the measured object, invoke the preset message protocol module 50 to adjust the message field of the response use case to meet the requirement of the running data of the measured object;
  • the driving module 20 is further configured to receive a response message of the measured object, and the calling message protocol module 50 parses the response message, compares it with the expected response use case message, and confirms whether the current use case passes.
  • the driving module 20 is specifically configured to:
  • the pile module 30 is specifically configured to:
  • the call message protocol module 50 encapsulates the response use case notified by the control module 10;
  • the adjusted response use case is responded to the object under test.
  • control module 10 is further configured to:
  • control module 10 further includes a test log sub-block 12, which is set to record the test operation log in real time, format the log on the interface, and output a final test result log. .
  • FIG. 5 it is a working flow chart of an embodiment of the software automatic testing system of the present invention. The flow includes the following steps:
  • Step S201 the control module 10 retrieves a test case that needs to be executed currently
  • step S202 the control module 10 notifies the stub module 30 of the response use case in the test case, and then waits for the feedback of the stub module 30; the notification mode is not limited to a function call, a Socket notification, or the like. If the notification stub module is successful, the process proceeds to step S203, otherwise, the process proceeds to step S204 via step S401. Step S401, the stub module 30 waits for the control module 10 to respond to the use case notification.
  • step 402 If the response use case notification is successfully received, the process proceeds to step 402, and is fed back to the control module 10, and the control module 10 proceeds to step 203; otherwise, if the notification fails, the feedback is sent to The control module 10 proceeds to step 204, and the failure to notify the stub module 30 in response to the use case is not limited to the call failure, the Socket timeout, no response, and the like.
  • Step S203 the control module 10 notifies the drive module 20 of the request use case and the expected response use case in the test case;
  • control module 10 completes the notification of the current use case to the stub module 30 and the drive module 20.
  • the pile module 30 and the drive module 20 simultaneously enter a standby and drive state.
  • Step S301 the driver module 20 invokes the message protocol module 50 to encapsulate the request use case notified by the control module 10;
  • step S302 the driving module 20 calls the message communication module 40 to send the encapsulated request use case to the object to be tested, causing the internal operation of the object to be tested, and sending the request message to the stub module 30.
  • step S303 the driving module 20 sends the request use case. Enter the waiting state of the object to be tested;
  • Step S404 the stub module 30 receives the request message of the measured object, and invokes the message protocol module.
  • Step S405 the stub module 30 performs the necessary message field adjustment on the original encapsulated response use case according to the test object request message parsing result to meet the test object operation data requirement; Step S406, the stub module 30 will adjust the response use case.
  • Step S304 the driving module 20 determines whether the response of the measured object is received; if the receiving is successful, the process proceeds to step S305, and if it fails, the process proceeds to step S306, and the receiving failure is not limited to receiving the message with an error, and the measured object times out. No response, etc.
  • Step S305 the driving module 20 successfully receives the measured object response message, invokes the message protocol module 50 to parse the response message, compares the response message with the expected response use case originally notified by the control module 10, and confirms whether the current use case passes; Go to step 204.
  • step S306 the driving module 10 fails to receive the test object response message, and the receiving failure is not limited to the receiving message having an error, the measured object timeout is unresponsive, and the like, and the process proceeds to step S204.
  • Step S204 the control module 10 records the current use case execution status into the test log.
  • Step S205 the control module 10 checks whether all the use cases are executed. If there are test cases, the next test case is taken, and the process returns to step S201 to continue the next round of use case automatic test; otherwise, the useful example is executed and the test is ended.

Abstract

本发明提供一种软件自动测试的方法,包括:控制模块根据消息类型将响应用例通知到桩模块,将请求用例和期待响应用例通知到驱动模块;驱动模块调用预置的消息通信模块将封装后的请求用例消息发送到被测对象,以引起被测对象发送请求数据支持的请求消息至桩模块;桩模块根据被测对象发送的请求消息,调用预置的消息协议模块对所述响应用例进行消息字段调整,以符合被测对象运行数据的需要;驱动模块接收被测对象的响应消息,调用消息协议模块解析该响应消息,将其与所述期待响应用例消息进行比对,确认本次用例是否通过测试。本发明还提供一种软件自动测试的系统。本发明支持1个驱动模块+多个桩模块的灵活部署。

Description

软件自动测试的方法及系统 技术领域
本发明实施例涉及计算机通信领域, 尤其涉及一种软件自动测试的方 法及系统。 背景技术
软件自动测试已广泛应用到各种软件测试活动中, 通过自动测试不仅 能方便的模拟各种正常或异常情况的测试, 同时也可以节省大量的时间和 人力, 提高测试效率。
软件自动测试系统从结构上一般可以分为控制模块、 驱动模块和桩模 块, 其中, 控制模块协调整个自动测试流程, 驱动模块根据测试用例构造 请求消息驱动到被测对象, 桩模块用于给被测对象提供运行需要的数据支 持。
目前软件测试中, 软件模块往往有多种输入以及多种输出, 需要与多 个外部模块和系统进行交互, 输入输出方式不仅只有函数调用接口, 目前 常见的还有网络消息 /文件 /数据库记录等输入输出接口。但现有的软件测试 技术大部分都是单一消息输入、 单一消息类型输出, 或者是从函数级别对 软件模块和系统进行测试, 难以从流程上对多种输入多输出接口交互和数 据处理进行有效自动测试。 另外, 目前软件自动测试系统中的各模块受结 构限制不能分开部署在不同的测试环境中运行, 难以模拟被测对象真实的 运行环境, 往往使测试效果大打折扣。 发明内容
本发明实施例的主要目的在于提供一种软件自动测试方法和系统, 能 够对多输入多输出方式的各种接口进行有效自动测试, 支持网络消息 /文件 / 数据库等多种输入输出接口类型, 支持 1+N方式 (即 1个驱动模块 +N个桩 模块)的灵活部署。
为了实现发明目的, 本发明实施例提供一种软件自动测试的方法, 包 括以下步驟:
控制模块将所有的测试用例保存在緩存中; 所述测试用例包括响应用 例、 请求用例和期待响应用例;
测试开始后, 控制模块根据消息类型将响应用例通知到桩模块, 将请 求用例和期待响应用例通知到驱动模块;
驱动模块调用预置的消息通信模块将封装后的请求用例消息发送到被 测对象, 以引起被测对象发送请求数据支持的请求消息至桩模块;
桩模块根据被测对象发送的请求消息, 调用预置的消息协议模块对所 述响应用例进行消息字段调整, 以符合被测对象运行数据的需要;
驱动模块接收被测对象的响应消息, 调用消息协议模块解析该响应消 息, 将其与所述期待响应用例消息进行比对, 确认本次用例是否通过测试。
优选地, 所述驱动模块调用消息通信模块将封装后的请求用例消息发 送到被测对象, 以引起被测对象发送请求数据支持的请求消息至桩模块包 括:
调用消息协议模块封装由控制模块通知的请求用例;
调用消息通信模块将封装后的请求用例发送到被测对象;
判断是否接收到被测对象的响应。
优选地, 所述桩模块根据被测对象发送的请求消息, 对所述响应用例 进行消息字段调整, 以符合被测对象运行数据的需要包括:
调用消息协议模块封装由控制模块通知的响应用例;
接收被测对象的请求消息, 调用消息解析模块对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要;
将调整后的响应用例响应给被测对象。
优选地, 该方法还包括:
控制模块将本次用例执行情况记录入测试日志;
控制模块检查是否所有用例执行完毕, 若还有测试用例, 则调取下一 个测试用例, 进行下一轮用例自动测试; 否则, 结束测试。
本发明实施例还提供一种软件自动测试的系统, 包括控制模块、 驱动 模块、 桩模块、 消息通信模块和消息协议模块, 其中:
控制模块, 设置为将所有的测试用例保存在緩存中; 所述测试用例包 括响应用例、 请求用例和期待响应用例; 以及在测试开始后, 根据消息类 型将响应用例通知到桩模块, 将请求用例和期待响应用例通知到驱动模块; 驱动模块, 设置为调用预置的消息通信模块将封装后的请求用例消息 发送到被测对象, 以引起被测对象发送请求数据支持的请求消息至桩模块; 以及接收被测对象的响应消息, 调用消息协议模块解析该响应消息, 将其 与所述期待响应用例消息进行比对, 确认本次用例是否通过;
桩模块, 设置为根据被测对象发送的请求消息, 调用预置的消息协议 模块对所述响应用例进行消息字段调整, 以符合被测对象运行数据的需要。
优选地, 所述驱动模块具体设置为:
调用消息协议模块封装由控制模块通知的请求用例;
调用消息通信模块将封装后的请求用例发送到被测对象;
判断是否接收到被测对象的响应。
优选地, 所述桩模块具体设置为:
调用消息协议模块封装由控制模块通知的响应用例;
接收被测对象的请求消息, 调用消息解析模块对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要;
将调整后的响应用例响应给被测对象。
优选地, 所述控制模块具体设置为:
根据消息类型将响应用例通知到桩模块, 将请求用例和期待响应用例 通知到驱动模块; 将本次用例执行情况记录入测试日志;
检查是否所有用例执行完毕, 若还有测试用例, 则调取下一个测试用 例, 进行下一轮用例自动测试; 否则, 结束测试。
本发明实施例所提供的软件自动测试的方法或系统, 能够处理一端输 入用例, 多端输出到各种类型桩的情况, 消息字段可自定义, 响应用例可 支持正则通配符比对, 使得测试用例能支持多消息类型、 配置灵活。 相关 测试用例可统一保存, 方便保存、 传送和加载, 极大地提升了代码重构后 做功能快速回归测试的效率。 此外, 本发明实施例还可根据需要可将驱动 模块和桩模块分离部署, 使得测试环境更符合实际运行环境。 附图说明
图 1为本发明一实施方式中软件自动测试的方法的流程图;
图 2为本发明另一实施方式中软件自动测试的方法的流程图; 图 3为本发明另一实施方式中软件自动测试的方法的流程图; 图 4为本发明一实施方式中软件自动测试的系统的结构示意图; 图 5为本发明一实施例中软件自动测试的系统的工作流程图。 具体实施方式
应当理解, 此处所描述的具体实施例仅仅用以解释本发明, 并不用于 限定本发明。
图 1 示出了本发明的一个实施方式中软件自动测试的方法流程, 该流 程基于包括有控制模块、 驱动模块、 多个桩模块、 消息协议模块和消息通 信模块的测试系统。 如图 1所示, 该方法包括以下步驟:
步驟 S10,预置用以发送或接收消息的消息通信模块以及用以封装或解 析消息的消息协议模块; 具体的, 消息协议模块用于按消息类型封装或解 析请求用例或响应用例。 消息通信模块用于发送封装后的请求用例和接收 响应用例。 例如, 消息协议模块封装来自驱动模块的请求用例和桩模块的 响应用例; 解析来自被测对象的请求消息和响应消息。 消息通信模块将消 息协议模块封装好的请求用例发送到被测对象, 或接收被测对象发来的请 求消息送给消息协议模块解析。
步驟 S20,控制模块将所有的测试用例保存在緩存中; 所述测试用例包 括响应用例、 请求用例和期待响应用例; 控制模块包括用例管理子块, 用 于各种链路信息、 请求用例、 响应用例和期待响应用例的管理, 本步驟中, 控制模块调用用例管理子块加载所有的测试用例保存在緩存中。
步驟 S30, 测试开始后,控制模块根据消息类型将响应用例通知到桩模 块, 将请求用例和期待响应用例通知到驱动模块; 通知方式不限于函数调 用、 Socket通知等。 在一实施例中, 步驟 S30可包括: 首先, 控制模块调 取当前需要执行的测试用例; 然后将测试用例中的响应用例通知给桩模块, 并等待桩模块的反馈。 若通知桩模块成功则将测试用例中的请求用例和期 待响应用例通知驱动模块。 桩模块可有 N个, N为大于 1的整数, 按需配 置, 控制模块根据消息类型可自动通知到具体的哪个桩模块。
步驟 S40,驱动模块调用消息通信模块将封装后的请求用例消息发送到 被测对象, 以引起被测对象发送请求数据支持的请求消息至桩模块;
步驟 S50,桩模块根据被测对象发送的请求消息,对所述响应用例进行 消息字段调整, 以符合被测对象运行数据的需要;
步驟 S60,驱动模块接收被测对象的响应消息,调用消息协议模块解析 该响应消息, 将其与所述期待响应用例消息进行比对, 确认本次用例是否 通过测试。 本发明实施例中消息字段可自定义, 响应用例支持正则通配符 比对, 使得测试用例能支持多消息类型、 配置灵活。
参照图 2, 示出了本发明一具体示例中软件自动测试系统的工作流程, 该流程依次包括以下步驟:
步驟 S101, 控制模块将响应用例通知桩模块;
步驟 S102 , 控制模块将请求用例和期待响应用例通知控制模块。
步驟 S103, 驱动模块调用消息协议模块封装请求用例。
步驟 S104, 驱动模块调用消息通信模块将封装后的请求用例发送到被 测对象。
步驟 S105 , 被测对象接收到请求用例, 引起被测对象做内部操作。 步驟 S106, 被测对象发送请求消息到桩模块请求数据支持, 此步驟不 限于只发送给一个桩, 可以不发送给桩仅在被测对象内部操作, 也可以发 送给多个桩。
步驟 S107, 桩模块接收被测对象请求消息, 解析、 对原先控制模块通 知的响应用例 必要调整。
步驟 S108 , 桩模块将调整后的响应用例响应给被测对象。
步驟 S109, 被测对象接收到桩模块的响应用例后, 引起被测对象内部 操作。
步驟 S110, 被测对象做内部操作运算后, 响应给驱动模块消息。
步驟 S111 , 驱动模块调用消息协议模块解析响应消息, 将解析后的响 应消息和原先控制模块通知的期待响应用例消息进行比对、 确定本次用例 是否通过。
至此, 完成一次自动测试流程, 根据用例的数目, 将自动继续进行下 一个用例自动测试。 上述步驟 S40中, 驱动模块的处理过程具体可以包括:
调用消息协议模块封装由控制模块通知的请求用例;
调用消息通信模块将封装后的请求用例发送到被测对象;
进入等待被测对象响应状态, 判断是否接收到被测对象的响应。 如果 是, 则执行步驟 S60, 如果否, 则接收被测对象响应消息失败的消息, 例如 接收消息有错误、 被测对象超时无响应等。
上述步驟 S50中, 桩模块的处理过程具体可以包括:
调用消息协议模块封装由控制模块通知的响应用例;
接收被测对象的请求消息, 调用消息协议模块对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要;
将调整后的响应用例响应给被测对象。
参照图 3 ,在一实施例中,在执行图 1所示的所有步驟之后还可以包括: 步驟 S70 ,控制模块将本次用例执行情况记录入测试日志;本实施例中, 控制模块还包括测试日志子块, 用于实时记录测试操作日志, 将日志格式 化显示在界面上, 输出最终的测试结果日志。
步驟 S80 , 控制模块检查是否所有用例执行完毕, 若还有测试用例, 则 调取下一个测试用例, 进行下一轮用例自动测试; 否则, 结束测试。
本发明实施例所提供的软件自动测试的方法, 能够处理一端输入用例, 多端输出到各种类型桩的情况, 消息字段可自定义, 响应用例支持正则通 配符比对, 使得测试用例能支持多消息类型、 配置灵活。 相关测试用例可 统一保存, 方便保存、 传送和加载, 极大地提升了代码重构后做功能快速 回归测试的效率。 此外, 本发明实施例还可根据需要可将驱动模块和桩模 块分离部署, 使得测试环境更符合实际运行环境。
本发明实施例还提供一种软件自动测试系统, 用以实现上述方法。 参 照图 4, 该系统包括控制模块 10、 驱动模块 20、 桩模块 30、 消息通信模块 40以及消息协议模块 50 , 其中:
控制模块 10, 设置为将所有的测试用例保存在緩存中; 所述测试用例 包括响应用例、 请求用例和期待响应用例; 控制模块 10包括用例管理子块 11 , 用于各种链路信息、 请求用例、 响应用例和期待响应用例的管理, 本 步驟中, 控制模块 10调用用例管理子块 11加载所有的测试用例保存在緩 存中。
测试开始后, 控制模块 10根据消息类型将响应用例通知到桩模块 30, 将请求用例和期待响应用例通知到驱动模块 20;控制模块 10的通知方式不 限于函数调用、 Socket通知等。 在一实施例中, 控制模块 10首先调取当前 需要执行的测试用例; 然后将测试用例中的响应用例通知给桩模块 30, 并 等待桩模块 30的反馈。 若通知桩模块 30成功则将测试用例中的请求用例 和期待响应用例通知驱动模块 20。 桩模块 30可有 N个, N为大于 1的整 数,按需配置,控制模块 10根据消息类型可自动通知到具体的哪个桩模块。
驱动模块 20,设置为调用预置的消息通信模块 40将封装后的请求用例 消息发送到被测对象, 以引起被测对象发送请求数据支持的请求消息至桩 模块 30; 本发明实施例中, 消息协议模块 50设置为按消息类型封装或解析 请求用例或响应用例。 消息通信模块 40设置为发送封装后的请求用例和接 收响应用例。 例如, 消息协议模块 50封装来自驱动模块 20的请求用例和 桩模块的响应用例; 解析来自被测对象的请求消息和响应消息。 消息通信 模块 40将消息协议模块 50封装好的请求用例发送到被测对象, 或接收被 测对象发来的请求消息送给消息协议模块 50解析。
桩模块 30, 设置为根据被测对象发送的请求消息, 调用预置的消息协 议模块 50对所述响应用例进行消息字段调整, 以符合被测对象运行数据的 需要; 驱动模块 20还设置为接收被测对象的响应消息,调用消息协议模块 50 解析该响应消息, 将其与所述期待响应用例消息进行比对, 确认本次用例 是否通过。
在一实施例中, 上述驱动模块 20具体设置为:
调用消息协议模块 50封装由控制模块通知的请求用例;
调用消息通信模块 40将封装后的请求用例发送到被测对象;
判断是否接收到被测对象的响应。
在一实施例中, 上述桩模块 30具体设置为:
调用消息协议模块 50封装由控制模块 10通知的响应用例;
接收被测对象的请求消息,调用消息解析模块 50对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要;
将调整后的响应用例响应给被测对象。
在一实施例中, 控制模块 10还设置为:
将本次用例执行情况记录入测试日志; 本实施例中, 控制模块 10还包 括测试日志子块 12, 设置为实时记录测试操作日志, 将日志格式化显示在 界面上, 输出最终的测试结果日志。
检查是否所有用例执行完毕, 若还有测试用例, 则调取下一个测试用 例, 进行下一轮用例自动测试; 否则, 结束测试。
参照图 5 , 为本发明软件自动测试系统一实施例的工作流程图。 该流包 括以下步驟:
步驟 S201 , 控制模块 10调取当前需要执行的测试用例;
步驟 S202 , 控制模块 10将测试用例中的响应用例通知给桩模块 30, 然后等待桩模块 30的反馈; 通知方式不限于函数调用、 Socket通知等。 若 通知桩模块成功则进入步驟 S203 , 否则经步驟 S401进入步驟 S204。 步驟 S401 , 桩模块 30等待控制模块 10响应用例通知, 若成功接收到 响应用例通知, 则进入步驟 402 , 同时反馈给控制模块 10, 由控制模块 10 进入步驟 203 ; 否则若通知失败, 则反馈给控制模块 10, 进入步驟 204 , 响 应用例通知桩模块 30失败不限于调用失败、 Socket超时无响应等。
步驟 S203 ,控制模块 10将测试用例中的请求用例和期待响应用例通知 驱动模块 20;
至此, 控制模块 10完成将本次用例通知到桩模块 30和驱动模块 20。 桩模块 30和驱动模块 20同时进入待命和驱动状态。
步驟 S301,驱动模块 20调用消息协议模块 50封装由控制模块 10通知 的请求用例;
步驟 S302 , 驱动模块 20调用消息通信模块 40将封装后的请求用例发 送到被测对象, 引起被测对象内部操作, 将请求消息发送给桩模块 30; 步驟 S303 ,驱动模块 20发送请求用例完毕,进入等待被测对象响应状 态;
步驟 S404,桩模块 30接收到被测对象的请求消息,调用消息协议模块
50进行消息解析;
步驟 S405 ,桩模块 30根据被测对象请求消息解析结果,对原先封装后 的响应用例进行必要的消息字段调整, 以符合被测对象运行数据需要; 步驟 S406 , 桩模块 30将调整后的响应用例响应给被测对象; 步驟 S304 ,驱动模块 20判断是否接收到被测对象的响应; 如果接收成 功则进入步驟 S305 , 如果失败则进入步驟 S306, 接收失败不限于接收消息 有错误、 被测对象超时无响应等。
步驟 S305 ,驱动模块 20成功接收到被测对象响应消息,调用消息协议 模块 50解析响应消息, 将响应消息和原先由控制模块 10通知的期待响应 用例进行比对, 确认本次用例是否通过; 然后进入步驟 204。 步驟 S306,驱动模块 10接收被测对象响应消息失败,接收失败不限于 接收消息有错误、 被测对象超时无响应等, 进入步驟 S204。
步驟 S204, 控制模块 10将本次用例执行情况记录入测试日志。
步驟 S205 ,控制模块 10检查是否所有用例执行完毕,若还有测试用例, 则取下一个测试用例, 返回到步驟 S201继续下一轮用例自动测试; 否则所 有用例执行完毕, 结束测试。
以上仅为本发明的优选实施例, 并非因此限制本发明的专利范围, 凡 是利用本发明说明书及附图内容所作的等效结构或等效流程变换, 或直接 或间接运用在其他相关的技术领域, 均同理包括在本发明的专利保护范围 内。

Claims

权利要求书
1、 一种软件自动测试的方法, 其中, 该方法包括:
控制模块将所有的测试用例保存在緩存中; 所述测试用例包括响应用 例、 请求用例和期待响应用例;
测试开始后, 控制模块根据消息类型将响应用例通知到桩模块, 将请 求用例和期待响应用例通知到驱动模块;
驱动模块调用预置的消息通信模块将封装后的请求用例消息发送到被 测对象, 以引起被测对象发送请求数据支持的请求消息至桩模块;
桩模块根据被测对象发送的请求消息, 调用预置的消息协议模块对所 述响应用例进行消息字段调整, 以符合被测对象运行数据的需要;
驱动模块接收被测对象的响应消息, 调用消息协议模块解析该响应消 息, 将其与所述期待响应用例消息进行比对, 确认本次用例是否通过测试。
2、 如权利要求 1所述的方法, 其中, 所述驱动模块调用消息通信模块 将封装后的请求用例消息发送到被测对象, 以引起被测对象发送请求数据 支持的请求消息至桩模块为:
调用消息协议模块封装由控制模块通知的请求用例;
调用消息通信模块将封装后的请求用例发送到被测对象;
判断是否接收到被测对象的响应。
3、 如权利要求 1所述的方法, 其中, 所述桩模块根据被测对象发送的 请求消息, 对所述响应用例进行消息字段调整, 以符合被测对象运行数据 的需要为:
调用消息协议模块封装由控制模块通知的响应用例;
接收被测对象的请求消息, 调用消息协议模块对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要; 将调整后的响应用例响应给被测对象。
4、 如权利要求 1至 3中任一项所述的方法, 其中, 该方法还包括: 控制模块将本次用例执行情况记录入测试日志;
控制模块检查是否所有用例执行完毕, 若还有测试用例, 则调取下一 个测试用例, 进行下一轮用例自动测试; 否则, 结束测试。
5、 一种软件自动测试的系统, 其中, 该系统包括: 控制模块、 驱动模 块、 桩模块、 消息通信模块和消息协议模块, 其中:
所述控制模块, 设置为将所有的测试用例保存在緩存中, 所述测试用 例包括响应用例、 请求用例和期待响应用例; 以及在测试开始后, 根据消 息类型将响应用例通知到桩模块, 将请求用例和期待响应用例通知到驱动 模块;
所述驱动模块, 设置为调用预置的消息通信模块将封装后的请求用例 消息发送到被测对象, 以引起被测对象发送请求数据支持的请求消息至桩 模块; 以及接收被测对象的响应消息, 调用消息协议模块解析该响应消息, 将其与所述期待响应用例消息进行比对, 确认本次用例是否通过;
所述桩模块, 设置为根据被测对象发送的请求消息, 调用预置的消息 协议模块对所述响应用例进行消息字段调整, 以符合被测对象运行数据的 需要。
6、 如权利要求 5所述的系统, 其中, 所述驱动模块具体设置为: 调用消息协议模块封装由控制模块通知的请求用例;
调用消息通信模块将封装后的请求用例发送到被测对象;
判断是否接收到被测对象的响应。
7、 如权利要求 6所述的系统, 其中, 所述桩模块具体设置为: 调用消息协议模块封装由控制模块通知的响应用例;
接收被测对象的请求消息, 调用消息解析模块对请求消息进行解析; 对原先封装的响应用例进行消息字段调整, 以符合被测对象运行数据 需要;
将调整后的响应用例响应给被测对象。
8、 如权利要求 5至 7中任一项所述的系统, 其中, 所述控制模块具体 设置为:
根据消息类型将响应用例通知到桩模块, 将请求用例和期待响应用例 通知到驱动模块;
将本次用例执行情况记录入测试日志;
检查是否所有用例执行完毕, 若还有测试用例, 则调取下一个测试用 例, 进行下一轮用例自动测试; 否则, 结束测试。
PCT/CN2012/074697 2011-06-21 2012-04-25 软件自动测试的方法及系统 WO2012174946A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110168160.3A CN102214140B (zh) 2011-06-21 2011-06-21 软件自动测试的方法及系统
CN201110168160.3 2011-06-21

Publications (1)

Publication Number Publication Date
WO2012174946A1 true WO2012174946A1 (zh) 2012-12-27

Family

ID=44745459

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/074697 WO2012174946A1 (zh) 2011-06-21 2012-04-25 软件自动测试的方法及系统

Country Status (2)

Country Link
CN (1) CN102214140B (zh)
WO (1) WO2012174946A1 (zh)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214140B (zh) * 2011-06-21 2017-02-15 中兴通讯股份有限公司 软件自动测试的方法及系统
CN104077216B (zh) * 2013-03-28 2018-04-27 腾讯科技(深圳)有限公司 软件测试方法及测试装置
CN104683386B (zh) * 2013-11-26 2019-01-04 腾讯科技(深圳)有限公司 可定制响应的桩服务实现方法及装置
CN105634838A (zh) * 2014-10-28 2016-06-01 中兴通讯股份有限公司 用于协议栈表管理的测试方法、装置及系统
CN106874176B (zh) * 2015-12-14 2021-04-27 创新先进技术有限公司 智能测试方法和装置
CN105893249A (zh) * 2015-12-31 2016-08-24 乐视网信息技术(北京)股份有限公司 一种软件测试方法及装置
EP3479248A4 (en) * 2016-06-29 2019-12-18 Synopsys, Inc. AUTOMATED HTTP USER FLOW SIMULATOR
CN107870854B (zh) * 2016-09-27 2020-06-30 北京京东尚科信息技术有限公司 图表库数据准确性测试方法和测试装置
CN107908544A (zh) * 2017-08-21 2018-04-13 中国平安人寿保险股份有限公司 一种用例测试方法及终端设备
CN110213119B (zh) * 2018-03-07 2022-02-22 财付通支付科技有限公司 测试桩生成方法、测试系统、测试方法及设备
CN115333984B (zh) * 2022-08-17 2023-10-31 卡斯柯信号有限公司 一种安全协议通信性能测试系统及方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873626A (zh) * 2005-06-01 2006-12-06 中兴通讯股份有限公司 一种自动生成桩和驱动函数的单元测试系统及方法
CN102043716A (zh) * 2010-12-24 2011-05-04 南京联创科技集团股份有限公司 基于业务驱动的软件自动化测试方法
CN102214140A (zh) * 2011-06-21 2011-10-12 中兴通讯股份有限公司 软件自动测试的方法及系统

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050188275A1 (en) * 2004-02-03 2005-08-25 Maly John W. Systems and methods for error tracking and recovery in an expectation-based memory agent checker
CN100456865C (zh) * 2004-08-12 2009-01-28 华为技术有限公司 一种通用自动化测试装置及方法
CN101620565B (zh) * 2008-07-04 2012-05-09 福建升腾资讯有限公司 终端系统的功能自动化测试方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873626A (zh) * 2005-06-01 2006-12-06 中兴通讯股份有限公司 一种自动生成桩和驱动函数的单元测试系统及方法
CN102043716A (zh) * 2010-12-24 2011-05-04 南京联创科技集团股份有限公司 基于业务驱动的软件自动化测试方法
CN102214140A (zh) * 2011-06-21 2011-10-12 中兴通讯股份有限公司 软件自动测试的方法及系统

Also Published As

Publication number Publication date
CN102214140A (zh) 2011-10-12
CN102214140B (zh) 2017-02-15

Similar Documents

Publication Publication Date Title
WO2012174946A1 (zh) 软件自动测试的方法及系统
WO2016206505A1 (zh) 自动化测试系统及测试方法
WO2019129022A1 (zh) 一种设备的故障处理方法、装置及系统
CN106155844B (zh) 一种web服务器的自恢复方法和自恢复系统
US8732694B2 (en) Method and system for performing services in server and client of client/server architecture
JP5198154B2 (ja) 障害監視システム及びデバイスと監視装置並びに障害監視方法
WO2011076058A1 (zh) 分布式数据库升级的方法、升级处理装置及升级控制装置
WO2021057605A1 (zh) 设备管理方法、装置、系统、设备及存储介质
CN101938374A (zh) 一种系统性能监控及告警方法和系统
CN112134754A (zh) 压力测试方法、装置、网络设备及存储介质
CN110620798B (zh) Ftp连接的控制方法、系统、设备和存储介质
CN103297477B (zh) 一种数据采集上报系统及数据处理方法和代理服务器
CN106059787A (zh) 一种小型机服务器状态的获取方法及装置
CN113986501A (zh) 实时数据库api无中断调用方法、系统、存储介质及服务器
CN101077015A (zh) 指示配置状态
CN104158906A (zh) 一种服务器代理操控系统及操控方法
CN116775376A (zh) 处理NVMe盘链路故障的方法、系统、设备和存储介质
CN112087341B (zh) 基于多通道补偿的通信方法、系统、电子设备及存储介质
CN112073236B (zh) 堆叠系统的故障处理方法、框式交换机、堆叠系统及介质
CN107526670A (zh) 服务自动监控方法、电子设备、计算机存储介质
US20120005315A1 (en) Method and server for transmitting large object
JP5502051B2 (ja) ソフトウェア・アプリケーション制御管理オブジェクトにおけるステップの実行結果を処理する方法
CN102546252B (zh) 升级网元的方法、装置及网络管理系统
CN109446013A (zh) 存储设备测试方法、存储设备测试系统及存储介质
CN116566810A (zh) 一种基于Spring MVC框架的系统异常处理方法、装置和设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12801827

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12801827

Country of ref document: EP

Kind code of ref document: A1