WO2019161619A1 - Automatic interface test method and apparatus, and device and computer-readable storage medium - Google Patents

Automatic interface test method and apparatus, and device and computer-readable storage medium Download PDF

Info

Publication number
WO2019161619A1
WO2019161619A1 PCT/CN2018/084310 CN2018084310W WO2019161619A1 WO 2019161619 A1 WO2019161619 A1 WO 2019161619A1 CN 2018084310 W CN2018084310 W CN 2018084310W WO 2019161619 A1 WO2019161619 A1 WO 2019161619A1
Authority
WO
WIPO (PCT)
Prior art keywords
script
template
test
script template
test case
Prior art date
Application number
PCT/CN2018/084310
Other languages
French (fr)
Chinese (zh)
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 WO2019161619A1 publication Critical patent/WO2019161619A1/en

Links

Images

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/3684Test management for test design, e.g. generating new test cases
    • 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/3692Test management for test results analysis

Definitions

  • the present application relates to the field of computer data processing, and in particular, to an interface automatic test method, apparatus, device, and computer readable storage medium.
  • Interface testing is generally used for interactive development between multiple systems, or for application development with multiple subsystems. Interface testing is applicable to the underlying framework systems and central service systems that serve other systems. It mainly tests the externally provided interfaces of these systems to verify their correctness and stability.
  • the interface automation test framework in the prior art has high requirements on the scripting ability of the user and is inefficient to use. For example, it is necessary to write a large number of repeated similar function program codes, which causes problems such as high maintenance cost and low test efficiency. Therefore, how to implement automated testing to solve the defects of the prior art that the user scripting ability is high has become a technical problem to be solved.
  • the present application provides an interface automatic test method, device, device and computer readable storage medium, which aims to solve the problem of high interface test and maintenance cost and low test efficiency.
  • the present application provides an interface automation test method, including: generating a test case according to a preset test case description structure; acquiring a test task list corresponding to the test case; and sequentially performing the test task list corresponding to the test task list Testing the task to generate an execution result; generating a test report based on the execution result.
  • the present invention provides an interface automation test apparatus, including:
  • a use case generating unit configured to generate a test case according to a preset test case description structure
  • a task obtaining unit configured to obtain a test task list corresponding to the test case
  • a result generating unit configured to sequentially execute a test task corresponding to the test task list to generate an execution result
  • a report generating unit configured to generate a test report according to the execution result.
  • the present application further provides a computer device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor executes the The above interface automatic test method is implemented in the program.
  • the present application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, the computer program comprising program instructions, when executed by a processor The processor executes the above interface automation test method.
  • a test case is generated according to a preset test case description structure, and a test report can be generated according to the test result obtained by executing the test task corresponding to the test case, which can reduce the maintenance cost of the interface test and improve the interface. Test the efficiency of the work.
  • FIG. 1 is a schematic flowchart of an interface automatic testing method according to an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application
  • FIG. 4 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application.
  • FIG. 6 is a schematic block diagram of an interface automatic testing apparatus according to an embodiment of the present application.
  • FIG. 7 is a schematic block diagram of a use case generating unit of an interface automatic testing device according to an embodiment of the present disclosure
  • FIG. 8 is a schematic block diagram of a first determining unit of an interface automatic testing device according to an embodiment of the present disclosure
  • FIG. 9 is a schematic block diagram of a first processing unit of an interface automatic testing device according to an embodiment of the present disclosure.
  • FIG. 10 is a schematic block diagram of a report generating unit of an interface automatic testing device according to an embodiment of the present application.
  • FIG. 11 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • An interface is the point of interaction between a system and a system or between modules and modules in the system.
  • the interface test is mainly used to detect the data interaction, delivery, and logical function of the interaction point.
  • the interface test essentially sends a Request message to the server to request the interface to be tested, and receives the Response packet returned by the server response.
  • the Response packet analyzes whether the function of the interface to be tested is correctly implemented.
  • FIG. 1 is a schematic flowchart diagram of an interface automatic testing method according to an embodiment of the present application.
  • the interface automation test method can be applied to terminals such as servers, desktop computers, laptop computers, tablet computers, personal digital assistants (PDAs), smart phones (such as Android mobile phones, IOS mobile phones, etc.).
  • terminals such as servers, desktop computers, laptop computers, tablet computers, personal digital assistants (PDAs), smart phones (such as Android mobile phones, IOS mobile phones, etc.).
  • PDAs personal digital assistants
  • smart phones such as Android mobile phones, IOS mobile phones, etc.
  • the method includes steps S110-S140.
  • S110 Generate a test case according to a preset test case description structure.
  • the test case description structure includes an interface call structure and an interface control structure.
  • the interface call structure is used to describe the input parameters required for the test interface to invoke the execution action;
  • the interface control structure is used to describe the control logic invoked by the test interface.
  • the control type of the interface control structure includes but is not limited to a loop control structure, a condition execution structure, a delay control structure, a registration variable structure, and an assertion control structure.
  • the loop control structure is configured to describe a number of times the sequential execution of the test interface performs an action
  • the condition control structure is configured to describe a precondition of the test interface calling an execution action
  • the registration variable is used for storing
  • the test interface invokes the result of executing the action for use in subsequent test cases
  • the assertion control structure is used to describe the test result generated after the test interface invokes the execution action.
  • the interface control structure of each control type corresponds to a unique control identifier.
  • the identifier corresponding to the loop control structure is retries; the identifier corresponding to the condition control structure is until; the identifier corresponding to the delay control structure is delay; the identifier corresponding to the registered variable structure is register; the identifier corresponding to the assertion control structure For assert.
  • test case description structure includes a script template
  • the script template includes a parameter input interface and a preset code segment
  • the test case is generated according to the preset test case description structure in step S110, including steps S111-S114.
  • test case description structures correspond to different preset code segments.
  • the preset test case description structure is an interface call structure
  • the preset code segment corresponding to the interface call structure may be:
  • the parameter input interface corresponding to the interface call structure is set after "name:".
  • the parameter input interface is a text input box for the user to input corresponding parameter information in the text input box according to the preset code segment.
  • test case description structure further includes a template candidate frame for displaying the script template, and determining whether the script template is in an active state in step S111 includes steps S1111-S1115.
  • S1111 Obtain a character input by a user through the template candidate box.
  • a template candidate box may be set in each line, and the template candidate box may be used to obtain a character input by the user, and display a preset code segment matching the character according to the acquired character.
  • S1112 Obtain a script template that matches the character according to the character input by the user.
  • the script template that matches the character according to the character input by the user may specifically be:
  • the script template is determined as a script template that matches the character.
  • Each script template corresponds to a unique template identifier.
  • the template identifier of the script template corresponding to the interface control structure may be the interface control structure corresponding control identifier.
  • the interface control structure is a loop control structure
  • the template identifier of the script template corresponding to the loop control structure is a control identifier corresponding to the loop control structure, that is, the template identifier is “retries”.
  • the template character is preferentially displayed in the template candidate box.
  • the preferred display methods include, but are not limited to, a top display, a highlight display, and the like.
  • the script template displayed in the template candidate box is clicked, it is determined that the script template is selected.
  • the script template matched by the character input by the user is automatically detected by acquiring the character input by the user, and the script template is displayed in the template candidate box for the user to select. Quickly capture script templates for improved input efficiency.
  • the script template includes a parameter input interface and a preset code segment. If the script template is in an active state, a preset code segment corresponding to the script template and a parameter input interface corresponding to the script template are generated.
  • the parameter input interface can be used to receive a script parameter input by the user, and the script input parameter corresponding to the preset code segment can be obtained through the parameter input interface.
  • FIG. 4 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, the test case is generated according to the preset code segment and the script parameter in step S114, including steps S1141-S1143.
  • the parameter input interface is a null value, it indicates that the parameter input interface does not receive the script parameter input by the user.
  • S1142 Delete the script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment.
  • S1143 Generate a test case according to the remaining preset code segments and script parameters corresponding to the remaining preset code segments.
  • the test case may be saved in a preset test directory by using a script file, and the file format of the script file may be a YAML format. By searching the YAML format file in the preset test directory, the corresponding test case can be quickly obtained.
  • the implementation of the embodiment of the present application effectively avoids the problem that the test case is caused by the redundant script template, and improves the speed and accuracy of the test case writing.
  • a test case may include one or more test tasks.
  • Each test task is marked by a preset task identifier, which can be set to the leftmost side of the first row of each test task to achieve differentiation of different test tasks and improve the speed of identifying test tasks.
  • the task identifier can be "-".
  • the test task list corresponding to the test case can be obtained by loading a script file that saves the test case and identifying a preset task identifier.
  • test case description structure is an interface call structure
  • the test task generated by the interface call structure is an interface call task
  • the interface call task is used to call an input parameter required for executing the action.
  • the test case description structure is an interface control structure
  • the test task generated by the interface control structure is an interface control task
  • the interface control task is used to perform a control action according to the corresponding control logic.
  • the corresponding script file can be obtained and loaded.
  • the test task corresponding to the test task list may be executed in sequence according to the order of the task identifiers, and the test tasks are sequentially executed in the order from top to bottom.
  • FIG. 5 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, generating a test report according to the execution result in step S140, including steps S141-S142.
  • the success rate of the execution result is obtained by acquiring the total number of executions of the test task and the number of successful executions of the test task, and dividing the number of successful executions by the total number of executions.
  • a first test report is generated; and if the success rate is greater than or equal to a preset first threshold, a second test report is generated.
  • the first threshold can be 90%. If the success rate is less than 90%, the first test report generated is a test failure. If the success rate is greater than or equal to 90%, the generated second test report is the test success.
  • FIG. 6 is a schematic block diagram of an interface automatic testing device according to an embodiment of the present application.
  • the interface automation test apparatus 100 includes a use case generation unit 110, a task acquisition unit 120, a result generation unit 130, and a report generation unit 140.
  • the test case description structure includes an interface call structure and an interface control structure.
  • the interface call structure is used to describe the input parameters required for the test interface to invoke the execution action;
  • the interface control structure is used to describe the control logic invoked by the test interface.
  • the control type of the interface control structure includes but is not limited to a loop control structure, a condition execution structure, a delay control structure, a registration variable structure, and an assertion control structure.
  • the loop control structure is configured to describe a number of times the sequential execution of the test interface performs an action
  • the condition control structure is configured to describe a precondition of the test interface calling an execution action
  • the registration variable is used for storing
  • the test interface invokes the result of executing the action for use in subsequent test cases
  • the assertion control structure is used to describe the test result generated after the test interface invokes the execution action.
  • the interface control structure of each control type corresponds to a unique control identifier.
  • the identifier corresponding to the loop control structure is retries; the identifier corresponding to the condition control structure is until; the identifier corresponding to the delay control structure is delay; the identifier corresponding to the registered variable structure is register; the identifier corresponding to the assertion control structure For assert.
  • the use case generating unit 110 is configured to generate a test case according to a preset test case description structure.
  • FIG. 7 is a schematic block diagram of a use case generating unit of an interface automatic testing device according to an embodiment of the present application.
  • the test case description structure includes a script template
  • the script template includes a parameter input interface and a preset code segment
  • the use case generating unit 110 includes a first determining unit 111, a first obtaining unit 112, and a second acquiring unit. 113 and the first processing unit 114.
  • test case description structures correspond to different preset code segments.
  • the preset test case description structure is an interface call structure
  • the preset code segment corresponding to the interface call structure may be:
  • the parameter input interface corresponding to the interface call structure is set after "name:".
  • the parameter input interface is a text input box for the user to input corresponding parameter information in the text input box according to the preset code segment.
  • the first determining unit 111 is configured to determine whether the script template is in an active state.
  • FIG. 8 is a schematic block diagram of a first determining unit 111 of an interface automatic testing device according to an embodiment of the present application.
  • the test case description structure further includes a template candidate frame for displaying a script template, where the first determining unit 111 includes a third obtaining unit 1111, a fourth obtaining unit 1112, a display unit 1113, and a second determining unit. 1114 and a second processing unit 1115.
  • the third obtaining unit 1111 is configured to acquire a character input by the user by using the template candidate box.
  • a template candidate box may be set in each line, and the template candidate box may be used to obtain a character input by the user, and display a preset code segment matching the character according to the acquired character.
  • the fourth obtaining unit 1112 is configured to acquire a script template that matches the character according to the character input by the user.
  • the script template that matches the character according to the character input by the user may specifically be:
  • the script template is determined as a script template matching the character.
  • Each script template corresponds to a unique template identifier.
  • the template identifier of the script template corresponding to the interface control structure may be the interface control structure corresponding control identifier.
  • the interface control structure is a loop control structure
  • the template identifier of the script template corresponding to the loop control structure is a control identifier corresponding to the loop control structure, that is, the template identifier is “retries”.
  • the display unit 1113 is configured to display the script template matching the character in the template candidate box.
  • the template character is preferentially displayed in the template candidate box.
  • the preferred display methods include, but are not limited to, a top display, a highlight display, and the like.
  • the second determining unit 1114 is configured to determine whether the script template displayed in the template candidate box is selected.
  • the script template displayed in the template candidate box is clicked, it is determined that the script template is selected.
  • the second processing unit 1115 is configured to determine that the selected script template is in an active state if the script template displayed in the template candidate box is selected.
  • the script template matched by the character input by the user is automatically detected by acquiring the character input by the user, and the script template is displayed in the template candidate box for the user to select. Quickly capture script templates for improved input efficiency.
  • the first obtaining unit 112 is configured to acquire a preset code segment corresponding to the script template if the script template is in an activated state.
  • the script template includes a parameter input interface and a preset code segment. If the script template is in an active state, a preset code segment corresponding to the script template and a parameter input interface corresponding to the script template are generated.
  • the second obtaining unit 113 is configured to acquire, by using the parameter input interface, a script parameter corresponding to the preset code segment.
  • the parameter input interface can be used to receive a script parameter input by the user, and the script input parameter corresponding to the preset code segment can be obtained through the parameter input interface.
  • the first processing unit 114 is configured to generate a test case according to the preset code segment and the script parameter.
  • FIG. 9 is a schematic block diagram of a first processing unit 114 of an interface automatic testing device according to an embodiment of the present application. Further, the first processing unit 114 includes a fifth obtaining unit 1141, a deleting unit 1142, and a third processing unit 1143.
  • the fifth obtaining unit 1141 is configured to acquire a script template whose parameter input interface is a null value.
  • the parameter input interface is a null value, it indicates that the parameter input interface does not receive the script parameter input by the user.
  • the deleting unit 1142 is configured to delete a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment.
  • the third processing unit 1143 is configured to generate a test case according to the remaining preset code segments and the script parameters corresponding to the remaining preset code segments.
  • the test case may be saved in a preset test directory by using a script file, and the file format of the script file may be a YAML format. By searching the YAML format file in the preset test directory, the corresponding test case can be quickly obtained.
  • the implementation of the embodiment of the present application effectively avoids the problem that the test case is caused by the redundant script template, and improves the speed and accuracy of the test case writing.
  • the task obtaining unit 120 is configured to obtain a test task list corresponding to the test case.
  • a test case may include one or more test tasks.
  • Each test task is marked by a preset task identifier, which can be set to the leftmost side of the first row of each test task to achieve differentiation of different test tasks and improve the speed of identifying test tasks.
  • the task identifier can be "-".
  • the test task list corresponding to the test case can be obtained by loading a script file that saves the test case and identifying a preset task identifier.
  • the result generating unit 130 is configured to sequentially execute the test task corresponding to the test task list to generate an execution result.
  • test case description structure is an interface call structure
  • the test task generated by the interface call structure is an interface call task
  • the interface call task is used to call an input parameter required for executing the action.
  • the test case description structure is an interface control structure
  • the test task generated by the interface control structure is an interface control task
  • the interface control task is used to perform a control action according to the corresponding control logic.
  • the corresponding script file can be obtained and loaded.
  • the test task corresponding to the test task list may be executed in sequence according to the order of the task identifiers, and the test tasks are sequentially executed in the order from top to bottom.
  • the report generating unit 140 is configured to generate a test report according to the execution result.
  • FIG. 10 is a schematic block diagram of a report generating unit 140 of an interface automatic testing device according to an embodiment of the present application. Further, the report generation unit 140 includes a sixth acquisition unit 141 and a fourth processing unit 142.
  • a sixth obtaining unit 141 configured to acquire a success rate of the execution result
  • the success rate of the execution result is obtained by acquiring the total number of executions of the test task and the number of successful executions of the test task, and dividing the number of successful executions by the total number of executions.
  • the fourth processing unit 142 is configured to generate a corresponding test report according to the success rate of the execution result.
  • a first test report is generated; and if the success rate is greater than or equal to a preset first threshold, a second test report is generated.
  • the first threshold can be 90%. If the success rate is less than 90%, the first test report generated is a test failure. If the success rate is greater than or equal to 90%, the generated second test report is the test success.
  • the above apparatus 100 can be implemented in the form of a computer program that can be run on a computer device as shown in FIG.
  • FIG. 11 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • the computer device 500 device can be a terminal.
  • the terminal can be a communication-enabled electronic device such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
  • the computer device 500 includes a processor 520, a memory, and a network interface 550 that are coupled by a system bus 510, where the memory can include a non-volatile storage medium 530 and an internal memory 540.
  • the non-volatile storage medium 530 can store an operating system 531 and a computer program 532.
  • the processor 520 can be caused to perform an interface automated test method.
  • the processor 520 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
  • the internal memory 540 provides an environment for the operation of a computer program in a non-volatile storage medium that, when executed by the processor 520, causes the processor 520 to perform an interface automated test method.
  • the network interface 550 is used for network communication, such as sending assigned tasks and the like. It will be understood by those skilled in the art that the schematic block diagram of the computer device is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device 500 to which the solution of the present application is applied.
  • the specific computer device 500 More or fewer components than those shown in the figures may be included, or some components may be combined, or have different component arrangements.
  • the processor 520 is configured to run the program code stored in the memory to implement a function of: generating a test case according to a preset test case description structure; acquiring a test task list corresponding to the test case; and sequentially performing the Testing a test task corresponding to the task list to generate an execution result; generating a test report according to the execution result.
  • the test case description structure includes a script template
  • the script template includes a parameter input interface and a preset code segment
  • the processor 520 performs the step of generating a test case according to the preset test case description structure.
  • the script template is in an active state
  • the preset code segment corresponding to the script template is obtained, and the pre-preparation is obtained through the parameter input interface.
  • the test case description structure further includes a template candidate box for displaying a script template
  • the processor 520 performs the following steps when performing the step of determining whether the script template is in an active state: Obtaining a character input by the user by using the template candidate box; acquiring a script template matching the character according to the character input by the user; displaying the script template matching the character in the template candidate a box is determined to determine whether the script template displayed in the template candidate box is selected; if the script template displayed in the template candidate box is selected, it is determined that the selected script template is in an active state.
  • the processor 520 when performing the step of generating a test case according to the preset code segment and the script parameter, specifically performs the following steps: acquiring a script template whose parameter input interface is a null value; a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment; according to the remaining preset code segment and the remaining preset
  • the script parameters corresponding to the code segment generate test cases.
  • the processor 520 when performing the step of generating a test report according to the execution result, specifically performs the following steps: acquiring a success rate of the execution result; and correspondingly generating a success rate according to the execution result Test report.
  • the processor 520 may be a central processing unit (CPU), and the processor 520 may also be other general-purpose processors, a digital signal processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc.
  • the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the schematic block diagram of the computer device 500 does not constitute a limitation to the computer device 500, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • a computer readable storage medium is stored, the computer readable storage medium storing a computer program, wherein the computer program comprises program instructions.
  • the interface automatic test method of the embodiment of the present application is implemented when the program instruction is executed by a processor.
  • the computer readable storage medium may be any medium that can store program code, such as a USB flash drive, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
  • program code such as a USB flash drive, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

An automatic interface test method and apparatus, and a device and a computer-readable storage medium. The method comprises: generating a test case according to a preset test case description structure (S110); acquiring a test task list corresponding to the test case (S120); sequentially executing test tasks corresponding to the test task list to generate an execution result (S130); and generating a test report according to the execution result (S140). By means of the implementation of the present method, the maintenance costs of interface test can be reduced, and the work efficiency of interface test can be increased.

Description

接口自动化测试方法、装置、设备及计算机可读存储介质Interface automation test method, device, device and computer readable storage medium
本申请要求于2018年2月24日提交中国专利局、申请号为201810156599.6、发明名称为“接口自动化测试方法、装置、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201810156599.6, entitled "Interface Automation Test Method, Apparatus, Apparatus, and Computer Readable Storage Medium", filed on February 24, 2018, the entire contents of which are incorporated herein by reference. This is incorporated herein by reference.
技术领域Technical field
本申请涉及计算机数据处理领域,尤其涉及一种接口自动化测试方法、装置、设备及计算机可读存储介质。The present application relates to the field of computer data processing, and in particular, to an interface automatic test method, apparatus, device, and computer readable storage medium.
背景技术Background technique
接口测试一般会用于多系统间交互开发,或者拥有多个子系统的应用系统开发的测试。接口测试适用于为其他系统提供服务的底层框架系统和中心服务系统,主要测试这些系统对外部提供的接口,验证其正确性和稳定性。Interface testing is generally used for interactive development between multiple systems, or for application development with multiple subsystems. Interface testing is applicable to the underlying framework systems and central service systems that serve other systems. It mainly tests the externally provided interfaces of these systems to verify their correctness and stability.
现有技术中的接口自动化测试框架对用户的脚本编写能力要求较高且使用效率低,例如需要编写大量重复的类似功能程序代码,造成了维护成本高且测试效率低下等问题。因此,如何实现自动化测试以解决现有技术对用户脚本编写能力要求较高等缺陷,已成为亟待解决的技术问题。The interface automation test framework in the prior art has high requirements on the scripting ability of the user and is inefficient to use. For example, it is necessary to write a large number of repeated similar function program codes, which causes problems such as high maintenance cost and low test efficiency. Therefore, how to implement automated testing to solve the defects of the prior art that the user scripting ability is high has become a technical problem to be solved.
发明内容Summary of the invention
本申请提供了一种接口自动化测试方法、装置、设备及计算机可读存储介质,旨在解决接口测试维护成本高和测试效率低的问题。The present application provides an interface automatic test method, device, device and computer readable storage medium, which aims to solve the problem of high interface test and maintenance cost and low test efficiency.
第一方面,本申请提供了一种接口自动化测试方法,其包括:根据预设的测试用例描述结构生成测试用例;获取所述测试用例对应的测试任务列表;依次执行所述测试任务列表对应的测试任务,以生成执行结果;根据所述执行结果生成测试报告。In a first aspect, the present application provides an interface automation test method, including: generating a test case according to a preset test case description structure; acquiring a test task list corresponding to the test case; and sequentially performing the test task list corresponding to the test task list Testing the task to generate an execution result; generating a test report based on the execution result.
第二方面,本发明提供了一种接口自动化测试装置,其包括:In a second aspect, the present invention provides an interface automation test apparatus, including:
用例生成单元,用于根据预设的测试用例描述结构生成测试用例;a use case generating unit, configured to generate a test case according to a preset test case description structure;
任务获取单元,用于获取所述测试用例对应的测试任务列表;a task obtaining unit, configured to obtain a test task list corresponding to the test case;
结果生成单元,用于依次执行所述测试任务列表对应的测试任务,以生成执行结果;a result generating unit, configured to sequentially execute a test task corresponding to the test task list to generate an execution result;
报告生成单元,用于根据所述执行结果生成测试报告。a report generating unit, configured to generate a test report according to the execution result.
第三方面,本申请又提供了一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现上述接口自动化测试方法。In a third aspect, the present application further provides a computer device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor executes the The above interface automatic test method is implemented in the program.
第四方面,本申请还提供了一种计算机可读存储介质,其中所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述接口自动化测试方法。In a fourth aspect, the present application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, the computer program comprising program instructions, when executed by a processor The processor executes the above interface automation test method.
实施本申请实施例,通过根据预设的测试用例描述结构生成测试用例,并根据执行测试用例对应的测试任务所得到的测试结果,即可生成测试报告,可降低接口测试的维护成本以及提升接口测试的工作效率。By implementing the embodiment of the present application, a test case is generated according to a preset test case description structure, and a test report can be generated according to the test result obtained by executing the test task corresponding to the test case, which can reduce the maintenance cost of the interface test and improve the interface. Test the efficiency of the work.
附图说明DRAWINGS
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the description of the embodiments will be briefly described below. Obviously, the drawings in the following description are some embodiments of the present application, For the ordinary technicians, other drawings can be obtained based on these drawings without any creative work.
图1为本申请一实施例提供的一种接口自动化测试方法的流程示意图;1 is a schematic flowchart of an interface automatic testing method according to an embodiment of the present application;
图2为本申请一实施例提供的一种接口自动化测试方法的子流程示意图;2 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application;
图3为本申请一实施例提供的一种接口自动化测试方法的子流程示意图;FIG. 3 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application;
图4为本申请一实施例提供的一种接口自动化测试方法的子流程示意图;4 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application;
图5为本申请一实施例提供的一种接口自动化测试方法的子流程示意图;FIG. 5 is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application;
图6为本申请一实施例提供的一种接口自动化测试装置的示意性框图;FIG. 6 is a schematic block diagram of an interface automatic testing apparatus according to an embodiment of the present application;
图7为本申请一实施例提供的一种接口自动化测试装置的用例生成单元示意性框图;FIG. 7 is a schematic block diagram of a use case generating unit of an interface automatic testing device according to an embodiment of the present disclosure;
图8为本申请一实施例提供的一种接口自动化测试装置的第一判断单元示意性框图;FIG. 8 is a schematic block diagram of a first determining unit of an interface automatic testing device according to an embodiment of the present disclosure;
图9为本申请一实施例提供的一种接口自动化测试装置的第一处理单元示意性框图;FIG. 9 is a schematic block diagram of a first processing unit of an interface automatic testing device according to an embodiment of the present disclosure;
图10为本申请一实施例提供的一种接口自动化测试装置的报告生成单元示意性框图;FIG. 10 is a schematic block diagram of a report generating unit of an interface automatic testing device according to an embodiment of the present application;
图11为本申请一实施例提供的一种计算机设备的示意性框图。FIG. 11 is a schematic block diagram of a computer device according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。The terminology used herein is for the purpose of describing particular embodiments and is not intended to be limiting. As used in the specification and the appended claims, the claims
接口是指系统与系统之间或系统中的模块与模块之间的交互点。接口测试主要用于检测交互点的数据交互、传递以及逻辑功能是否正确,接口测试本质上是发送一个Request报文给服务端请求待测试接口,并接收服务端响应返回的Response报文,基于该Response报文分析该待测试接口的功能是否正确实现。An interface is the point of interaction between a system and a system or between modules and modules in the system. The interface test is mainly used to detect the data interaction, delivery, and logical function of the interaction point. The interface test essentially sends a Request message to the server to request the interface to be tested, and receives the Response packet returned by the server response. The Response packet analyzes whether the function of the interface to be tested is correctly implemented.
请参照图1,其为本申请一实施例提供的一种接口自动化测试方法的流程示意图。该接口自动化测试方法可应用于服务器、台式电脑、手提电脑、平板电脑、个人数字助理(PDA)、智能手机(如Android手机、IOS手机等)等终端中。具体地,该方法包括步骤S110-S140。Please refer to FIG. 1 , which is a schematic flowchart diagram of an interface automatic testing method according to an embodiment of the present application. The interface automation test method can be applied to terminals such as servers, desktop computers, laptop computers, tablet computers, personal digital assistants (PDAs), smart phones (such as Android mobile phones, IOS mobile phones, etc.). Specifically, the method includes steps S110-S140.
S110,根据预设的测试用例描述结构生成测试用例。S110: Generate a test case according to a preset test case description structure.
具体地,测试用例描述结构包括接口调用结构以及接口控制结构。其中,所述接口调用结构用于描述测试接口调用执行动作所需的输入参数;所述接口控制结构用于描述测试接口所调用的控制逻辑。Specifically, the test case description structure includes an interface call structure and an interface control structure. The interface call structure is used to describe the input parameters required for the test interface to invoke the execution action; the interface control structure is used to describe the control logic invoked by the test interface.
其中,接口控制结构的控制类型包括但不限于循环控制结构、条件执行结构、延时控制结构、注册变量结构以及断言控制结构。具体地,所述循环控制结构用于描述所述测试接口的循序调用执行动作的次数;所述条件控制结构用于描述所述测试接口调用执行动作的前置条件;所述注册变量用于存储所述测试接口调用执行动作后的结果,以便于后续其他测试用例中使用;所述断言控 制结构用于描述所述测试接口调用执行动作后所生成的测试结果。The control type of the interface control structure includes but is not limited to a loop control structure, a condition execution structure, a delay control structure, a registration variable structure, and an assertion control structure. Specifically, the loop control structure is configured to describe a number of times the sequential execution of the test interface performs an action; the condition control structure is configured to describe a precondition of the test interface calling an execution action; the registration variable is used for storing The test interface invokes the result of executing the action for use in subsequent test cases; the assertion control structure is used to describe the test result generated after the test interface invokes the execution action.
每一个控制类型的接口控制结构对应唯一的控制标识符。例如,循环控制结构对应的标识符为retries;条件控制结构对应的标识符为until;延时控制结构对应的标识符为delay;注册变量结构对应的标识符为register;断言控制结构对应的标识符为assert。The interface control structure of each control type corresponds to a unique control identifier. For example, the identifier corresponding to the loop control structure is retries; the identifier corresponding to the condition control structure is until; the identifier corresponding to the delay control structure is delay; the identifier corresponding to the registered variable structure is register; the identifier corresponding to the assertion control structure For assert.
具体请参照图2,其为本申请一实施例提供的一种接口自动化测试方法的子流程示意图。进一步地,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,步骤S110中的根据预设的测试用例描述结构生成测试用例,包括步骤S111-S114。For details, please refer to FIG. 2 , which is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, the test case description structure includes a script template, the script template includes a parameter input interface and a preset code segment, and the test case is generated according to the preset test case description structure in step S110, including steps S111-S114.
具体实施中,不同的测试用例描述结构对应不同的预设代码段。例如,若该预设的测试用例描述结构为接口调用结构,该接口调用结构对应的预设代码段可以为:In a specific implementation, different test case description structures correspond to different preset code segments. For example, if the preset test case description structure is an interface call structure, the preset code segment corresponding to the interface call structure may be:
include:Include:
name:Name:
对应地,该接口调用结构对应的参数输入界面设置于“name:”后面。该参数输入界面为文本输入框,以供用户根据所述预设代码段在所述文本输入框中输入相对应的参数信息。Correspondingly, the parameter input interface corresponding to the interface call structure is set after "name:". The parameter input interface is a text input box for the user to input corresponding parameter information in the text input box according to the preset code segment.
S111,判断所述脚本模板是否处于激活状态。S111. Determine whether the script template is in an active state.
具体请参照图3,其为本申请一实施例提供的一种接口自动化测试方法的子流程示意图。进一步地,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,步骤S111中的判断所述脚本模板是否处于激活状态,包括步骤S1111-S1115。For details, please refer to FIG. 3 , which is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, the test case description structure further includes a template candidate frame for displaying the script template, and determining whether the script template is in an active state in step S111 includes steps S1111-S1115.
S1111,通过所述模板备选框获取用户输入的字符。S1111: Obtain a character input by a user through the template candidate box.
具体实施中,可在每一行设置一个模板备选框,该模板备选框可用于获取用户输入的字符,并根据所获取的字符向用户展示与该字符相匹配的预设代码段。In a specific implementation, a template candidate box may be set in each line, and the template candidate box may be used to obtain a character input by the user, and display a preset code segment matching the character according to the acquired character.
S1112,根据所述用户输入的字符获取与所述字符相匹配的脚本模板。S1112: Obtain a script template that matches the character according to the character input by the user.
具体实施中,根据所述用户输入的字符检测与所述字符相匹配的脚本模板具体可以为:In a specific implementation, the script template that matches the character according to the character input by the user may specifically be:
判断所述脚本模板对应的模板标识符是否包含所述用户输入的字符;Determining whether the template identifier corresponding to the script template includes the character input by the user;
若所述脚本模板对应的模板标识符包含所述用户输入的字符,将该脚本模板确定为与所述字符相匹配的脚本模板。And if the template identifier corresponding to the script template includes the character input by the user, the script template is determined as a script template that matches the character.
其中,每一个脚本模板对应唯一一个模板标识符。若该测试用例描述结构为接口控制结构,该接口控制结构对应的脚本模板的模板标识符可以是该接口控制结构对应控制标识符。例如,该接口控制结构为循环控制结构,则该循环控制结构对应的脚本模板的模板标识符为循环控制结构对应的控制标识符,即该模板标识符为“retries”。Each script template corresponds to a unique template identifier. If the test case description structure is an interface control structure, the template identifier of the script template corresponding to the interface control structure may be the interface control structure corresponding control identifier. For example, the interface control structure is a loop control structure, and the template identifier of the script template corresponding to the loop control structure is a control identifier corresponding to the loop control structure, that is, the template identifier is “retries”.
若所述用户输入的字符为“r”,通过将该字符“r”与所有的模板标识符逐一匹配,判断是否存在含有字符“r”的模板标识符,若存在含有字符“r”的模板标识符,将含有字符“r”的模板标识符对应的脚本模板确定为与所述字符相匹配的脚本模板。If the character input by the user is "r", by matching the character "r" with all the template identifiers one by one, it is determined whether there is a template identifier containing the character "r", and if there is a template containing the character "r" An identifier that determines a script template corresponding to a template identifier containing the character "r" as a script template that matches the character.
S1113,将所述与所述字符相匹配的脚本模板展示于所述模板备选框。S1113: Display the script template matching the character in the template candidate box.
具体实施中,若模板标识符的首位字符与所述用户输入的字符相同,则将该模板字符优先展示于模板备选框。优先展示的方式包括但不限于置顶显示、高亮显示等。In a specific implementation, if the first character of the template identifier is the same as the character input by the user, the template character is preferentially displayed in the template candidate box. The preferred display methods include, but are not limited to, a top display, a highlight display, and the like.
S1114,判断所述展示于所述模板备选框的脚本模板是否被选中。S1114. Determine whether the script template displayed in the template candidate box is selected.
具体实施中,若展示于所述模板备选框的脚本模板被点击则确定该脚本模板被选中。In a specific implementation, if the script template displayed in the template candidate box is clicked, it is determined that the script template is selected.
S1115,若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。S1115: If the script template displayed in the template candidate box is selected, determining that the selected script template is in an active state.
实施本申请实施例,通过获取用户输入的字符,自动检测与用户输入的字符相匹配的脚本模板,并将该脚本模板展示于模板备选框中,以供用户选择。可实现快速获取脚本模板,提高输入效率。By implementing the embodiment of the present application, the script template matched by the character input by the user is automatically detected by acquiring the character input by the user, and the script template is displayed in the template candidate box for the user to select. Quickly capture script templates for improved input efficiency.
S112,若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段。S112. If the script template is in an active state, obtain a preset code segment corresponding to the script template.
具体实施中,所述脚本模板包括参数输入界面以及预设代码段。若所述脚本模板处于激活状态,则生成该脚本模板对应的预设代码段以及该脚本模板对应的参数输入界面。In a specific implementation, the script template includes a parameter input interface and a preset code segment. If the script template is in an active state, a preset code segment corresponding to the script template and a parameter input interface corresponding to the script template are generated.
S113,通过所述参数输入界面获取与所述预设代码段对应的脚本参数。S113. Obtain a script parameter corresponding to the preset code segment by using the parameter input interface.
具体实施中,该参数输入界面可用于接收用户输入的脚本参数,通过该参 数输入界面可获取用户输入的与所述预设代码段对应的脚本参数。In a specific implementation, the parameter input interface can be used to receive a script parameter input by the user, and the script input parameter corresponding to the preset code segment can be obtained through the parameter input interface.
S114,根据所述预设代码段以及脚本参数生成测试任务。S114. Generate a test task according to the preset code segment and the script parameter.
具体请参照图4,其为本申请一实施例提供的一种接口自动化测试方法的子流程示意图。进一步地,步骤S114中的根据所述预设代码段以及脚本参数生成测试用例,包括步骤S1141-S1143。For details, please refer to FIG. 4 , which is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, the test case is generated according to the preset code segment and the script parameter in step S114, including steps S1141-S1143.
S1141,获取所述参数输入界面为空值的脚本模板。S1141: Obtain a script template that the parameter input interface is a null value.
具体地,若所述参数输入界面为空值,表明该参数输入界面没有接收到用户输入的脚本参数。Specifically, if the parameter input interface is a null value, it indicates that the parameter input interface does not receive the script parameter input by the user.
S1142,删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数。S1142: Delete the script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment.
S1143,根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。S1143: Generate a test case according to the remaining preset code segments and script parameters corresponding to the remaining preset code segments.
具体实施中,所述测试用例可以通过脚本文件的形式保存于预设的测试目录中,该脚本文件的文件格式可以为YAML格式。通过搜索该预设的测试目录中的YAML格式文件,可快速获取到对应的测试用例。In a specific implementation, the test case may be saved in a preset test directory by using a script file, and the file format of the script file may be a YAML format. By searching the YAML format file in the preset test directory, the corresponding test case can be quickly obtained.
实施本申请实施例,有效避免了因多余脚本模板造成测试用例出错的问题,提高了测试用例编写的速度以及准确性。The implementation of the embodiment of the present application effectively avoids the problem that the test case is caused by the redundant script template, and improves the speed and accuracy of the test case writing.
S120,获取所述测试用例对应的测试任务列表。S120. Obtain a test task list corresponding to the test case.
具体实施中,一个测试用例可包括一个或者一个以上的测试任务。每一个测试任务通过预设的任务标识符进行标记,该任务标识符可设置于每一个测试任务的第一行最左侧,以实现对不同测试任务的区分并提高识别测试任务的速度。该任务标识符可以为“-”。通过加载保存有该测试用例的脚本文件,并识别预设的任务标识符,可获取所述测试用例对应的测试任务列表。In a specific implementation, a test case may include one or more test tasks. Each test task is marked by a preset task identifier, which can be set to the leftmost side of the first row of each test task to achieve differentiation of different test tasks and improve the speed of identifying test tasks. The task identifier can be "-". The test task list corresponding to the test case can be obtained by loading a script file that saves the test case and identifying a preset task identifier.
S130,依次执行所述测试任务列表对应的测试任务,以生成执行结果。S130. Perform a test task corresponding to the test task list in sequence to generate an execution result.
其中,根据不同类型的测试用例描述结构会生成不同类型的测试任务。若测试用例描述结构为接口调用结构,该接口调用结构对应生成的测试任务为接口调用任务,该接口调用任务用于调用执行动作所需的输入参数。若测试用例描述结构为接口控制结构,该接口控制结构对应生成的测试任务为接口控制任务,该接口控制任务用于根据对应的控制逻辑执行控制动作。Among them, describing the structure according to different types of test cases will generate different types of test tasks. If the test case description structure is an interface call structure, the test task generated by the interface call structure is an interface call task, and the interface call task is used to call an input parameter required for executing the action. If the test case description structure is an interface control structure, the test task generated by the interface control structure is an interface control task, and the interface control task is used to perform a control action according to the corresponding control logic.
具体实施中,通过加载保存有测试用例的脚本文件,例如通过搜索该预设 的测试目录中的YAML格式文件,并根据检索相对应的文件名,以获取得到并加载对应的脚本文件,即可获得所述测试用例对应的测试任务列表。依次执行所述测试任务列表对应的测试任务可具体为根据所述任务标识符的排列顺序,按照从上到下的顺序依次执行所述测试任务。In a specific implementation, by loading a script file that saves a test case, for example, by searching for a YAML format file in the preset test directory, and acquiring a corresponding script file according to the corresponding file name, the corresponding script file can be obtained and loaded. Obtain a test task list corresponding to the test case. The test task corresponding to the test task list may be executed in sequence according to the order of the task identifiers, and the test tasks are sequentially executed in the order from top to bottom.
S140,根据所述执行结果生成测试报告。S140. Generate a test report according to the execution result.
具体请参照图5,其为本申请一实施例提供的一种接口自动化测试方法的子流程示意图。进一步地,步骤S140中的根据所述执行结果生成测试报告,包括步骤S141-S142。For details, please refer to FIG. 5 , which is a schematic diagram of a sub-flow of an interface automatic testing method according to an embodiment of the present application. Further, generating a test report according to the execution result in step S140, including steps S141-S142.
S141,获取所述执行结果的成功率。S141. Acquire a success rate of the execution result.
具体实施中,通过获取测试任务的总执行次数以及该测试任务的成功执行次数,并将成功执行次数与总执行次数相除即可获得所述执行结果的成功率。In a specific implementation, the success rate of the execution result is obtained by acquiring the total number of executions of the test task and the number of successful executions of the test task, and dividing the number of successful executions by the total number of executions.
S142,根据所述执行结果的成功率生成相对应的测试报告。S142. Generate a corresponding test report according to the success rate of the execution result.
具体实施中,若该成功率低于预设的第一阈值,生成第一测试报告;若该成功率大于或者等于预设的第一阈值,生成第二测试报告。例如,该第一阈值可以为90%。若成功率低于90%,生成的第一测试报告为测试失败。若成功率大于或者等于90%,生成的第二测试报告为测试成功。In a specific implementation, if the success rate is lower than a preset first threshold, a first test report is generated; and if the success rate is greater than or equal to a preset first threshold, a second test report is generated. For example, the first threshold can be 90%. If the success rate is less than 90%, the first test report generated is a test failure. If the success rate is greater than or equal to 90%, the generated second test report is the test success.
请参照图6,其为本申请一实施例提供的一种接口自动化测试装置的示意性框图。该接口自动化测试装置100包括用例生成单元110、任务获取单元120、结果生成单元130以及报告生成单元140。Please refer to FIG. 6 , which is a schematic block diagram of an interface automatic testing device according to an embodiment of the present application. The interface automation test apparatus 100 includes a use case generation unit 110, a task acquisition unit 120, a result generation unit 130, and a report generation unit 140.
具体地,测试用例描述结构包括接口调用结构以及接口控制结构。其中,所述接口调用结构用于描述测试接口调用执行动作所需的输入参数;所述接口控制结构用于描述测试接口所调用的控制逻辑。Specifically, the test case description structure includes an interface call structure and an interface control structure. The interface call structure is used to describe the input parameters required for the test interface to invoke the execution action; the interface control structure is used to describe the control logic invoked by the test interface.
其中,接口控制结构的控制类型包括但不限于循环控制结构、条件执行结构、延时控制结构、注册变量结构以及断言控制结构。具体地,所述循环控制结构用于描述所述测试接口的循序调用执行动作的次数;所述条件控制结构用于描述所述测试接口调用执行动作的前置条件;所述注册变量用于存储所述测试接口调用执行动作后的结果,以便于后续其他测试用例中使用;所述断言控制结构用于描述所述测试接口调用执行动作后所生成的测试结果。The control type of the interface control structure includes but is not limited to a loop control structure, a condition execution structure, a delay control structure, a registration variable structure, and an assertion control structure. Specifically, the loop control structure is configured to describe a number of times the sequential execution of the test interface performs an action; the condition control structure is configured to describe a precondition of the test interface calling an execution action; the registration variable is used for storing The test interface invokes the result of executing the action for use in subsequent test cases; the assertion control structure is used to describe the test result generated after the test interface invokes the execution action.
每一个控制类型的接口控制结构对应唯一的控制标识符。例如,循环控制结构对应的标识符为retries;条件控制结构对应的标识符为until;延时控制结构 对应的标识符为delay;注册变量结构对应的标识符为register;断言控制结构对应的标识符为assert。The interface control structure of each control type corresponds to a unique control identifier. For example, the identifier corresponding to the loop control structure is retries; the identifier corresponding to the condition control structure is until; the identifier corresponding to the delay control structure is delay; the identifier corresponding to the registered variable structure is register; the identifier corresponding to the assertion control structure For assert.
用例生成单元110,用于根据预设的测试用例描述结构生成测试用例。The use case generating unit 110 is configured to generate a test case according to a preset test case description structure.
具体请参照图7,其为本申请一实施例提供的一种接口自动化测试装置的用例生成单元示意性框图。进一步地,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,所述用例生成单元110包括第一判断单元111、第一获取单元112、第二获取单元113以及第一处理单元114。For details, please refer to FIG. 7 , which is a schematic block diagram of a use case generating unit of an interface automatic testing device according to an embodiment of the present application. Further, the test case description structure includes a script template, the script template includes a parameter input interface and a preset code segment, and the use case generating unit 110 includes a first determining unit 111, a first obtaining unit 112, and a second acquiring unit. 113 and the first processing unit 114.
具体实施中,不同的测试用例描述结构对应不同的预设代码段。例如,若该预设的测试用例描述结构为接口调用结构,该接口调用结构对应的预设代码段可以为:In a specific implementation, different test case description structures correspond to different preset code segments. For example, if the preset test case description structure is an interface call structure, the preset code segment corresponding to the interface call structure may be:
include:Include:
name:Name:
对应地,该接口调用结构对应的参数输入界面设置于“name:”后面。该参数输入界面为文本输入框,以供用户根据所述预设代码段在所述文本输入框中输入相对应的参数信息。Correspondingly, the parameter input interface corresponding to the interface call structure is set after "name:". The parameter input interface is a text input box for the user to input corresponding parameter information in the text input box according to the preset code segment.
第一判断单元111,用于判断所述脚本模板是否处于激活状态。The first determining unit 111 is configured to determine whether the script template is in an active state.
具体请参照图8,其为本申请一实施例提供的一种接口自动化测试装置的第一判断单元111示意性框图。进一步地,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,所述第一判断单元111包括第三获取单元1111、第四获取单元1112、展示单元1113、第二判断单元1114以及第二处理单元1115。For details, please refer to FIG. 8 , which is a schematic block diagram of a first determining unit 111 of an interface automatic testing device according to an embodiment of the present application. Further, the test case description structure further includes a template candidate frame for displaying a script template, where the first determining unit 111 includes a third obtaining unit 1111, a fourth obtaining unit 1112, a display unit 1113, and a second determining unit. 1114 and a second processing unit 1115.
第三获取单元1111,用于通过所述模板备选框获取用户输入的字符。The third obtaining unit 1111 is configured to acquire a character input by the user by using the template candidate box.
具体实施中,可在每一行设置一个模板备选框,该模板备选框可用于获取用户输入的字符,并根据所获取的字符向用户展示与该字符相匹配的预设代码段。In a specific implementation, a template candidate box may be set in each line, and the template candidate box may be used to obtain a character input by the user, and display a preset code segment matching the character according to the acquired character.
第四获取单元1112,用于根据所述用户输入的字符获取与所述字符相匹配的脚本模板。The fourth obtaining unit 1112 is configured to acquire a script template that matches the character according to the character input by the user.
具体实施中,根据所述用户输入的字符检测与所述字符相匹配的脚本模板具体可以为:In a specific implementation, the script template that matches the character according to the character input by the user may specifically be:
判断所述脚本模板对应的模板标识符是否包含所述用户输入的字符。Determining whether the template identifier corresponding to the script template includes the character input by the user.
若所述脚本模板对应的模板标识符包含所述用户输入的字符,将该脚本模 板确定为与所述字符相匹配的脚本模板。If the template identifier corresponding to the script template contains the character input by the user, the script template is determined as a script template matching the character.
其中,每一个脚本模板对应唯一一个模板标识符。若该测试用例描述结构为接口控制结构,该接口控制结构对应的脚本模板的模板标识符可以是该接口控制结构对应控制标识符。例如,该接口控制结构为循环控制结构,则该循环控制结构对应的脚本模板的模板标识符为循环控制结构对应的控制标识符,即该模板标识符为“retries”。Each script template corresponds to a unique template identifier. If the test case description structure is an interface control structure, the template identifier of the script template corresponding to the interface control structure may be the interface control structure corresponding control identifier. For example, the interface control structure is a loop control structure, and the template identifier of the script template corresponding to the loop control structure is a control identifier corresponding to the loop control structure, that is, the template identifier is “retries”.
若所述用户输入的字符为“r”,通过将该字符“r”与所有的模板标识符逐一匹配,判断是否存在含有字符“r”的模板标识符,若存在含有字符“r”的模板标识符,将含有字符“r”的模板标识符对应的脚本模板确定为与所述字符相匹配的脚本模板。If the character input by the user is "r", by matching the character "r" with all the template identifiers one by one, it is determined whether there is a template identifier containing the character "r", and if there is a template containing the character "r" An identifier that determines a script template corresponding to a template identifier containing the character "r" as a script template that matches the character.
展示单元1113,用于将所述与所述字符相匹配的脚本模板展示于所述模板备选框。The display unit 1113 is configured to display the script template matching the character in the template candidate box.
具体实施中,若模板标识符的首位字符与所述用户输入的字符相同,则将该模板字符优先展示于模板备选框。优先展示的方式包括但不限于置顶显示、高亮显示等。In a specific implementation, if the first character of the template identifier is the same as the character input by the user, the template character is preferentially displayed in the template candidate box. The preferred display methods include, but are not limited to, a top display, a highlight display, and the like.
第二判断单元1114,用于判断所述展示于所述模板备选框的脚本模板是否被选中。The second determining unit 1114 is configured to determine whether the script template displayed in the template candidate box is selected.
具体实施中,若展示于所述模板备选框的脚本模板被点击则确定该脚本模板被选中。In a specific implementation, if the script template displayed in the template candidate box is clicked, it is determined that the script template is selected.
第二处理单元1115,用于若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。The second processing unit 1115 is configured to determine that the selected script template is in an active state if the script template displayed in the template candidate box is selected.
实施本申请实施例,通过获取用户输入的字符,自动检测与用户输入的字符相匹配的脚本模板,并将该脚本模板展示于模板备选框中,以供用户选择。可实现快速获取脚本模板,提高输入效率。By implementing the embodiment of the present application, the script template matched by the character input by the user is automatically detected by acquiring the character input by the user, and the script template is displayed in the template candidate box for the user to select. Quickly capture script templates for improved input efficiency.
第一获取单元112,用于若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段。The first obtaining unit 112 is configured to acquire a preset code segment corresponding to the script template if the script template is in an activated state.
具体实施中,所述脚本模板包括参数输入界面以及预设代码段。若所述脚本模板处于激活状态,则生成该脚本模板对应的预设代码段以及该脚本模板对应的参数输入界面。In a specific implementation, the script template includes a parameter input interface and a preset code segment. If the script template is in an active state, a preset code segment corresponding to the script template and a parameter input interface corresponding to the script template are generated.
第二获取单元113,用于通过所述参数输入界面获取与所述预设代码段对应 的脚本参数。The second obtaining unit 113 is configured to acquire, by using the parameter input interface, a script parameter corresponding to the preset code segment.
具体实施中,该参数输入界面可用于接收用户输入的脚本参数,通过该参数输入界面可获取用户输入的与所述预设代码段对应的脚本参数。In a specific implementation, the parameter input interface can be used to receive a script parameter input by the user, and the script input parameter corresponding to the preset code segment can be obtained through the parameter input interface.
第一处理单元114,用于根据所述预设代码段以及脚本参数生成测试用例。The first processing unit 114 is configured to generate a test case according to the preset code segment and the script parameter.
具体请参照图9,其为本申请一实施例提供的一种接口自动化测试装置的第一处理单元114示意性框图。进一步地,所述第一处理单元114包括第五获取单元1141、删除单元1142以及第三处理单元1143。For details, please refer to FIG. 9 , which is a schematic block diagram of a first processing unit 114 of an interface automatic testing device according to an embodiment of the present application. Further, the first processing unit 114 includes a fifth obtaining unit 1141, a deleting unit 1142, and a third processing unit 1143.
第五获取单元1141,用于获取所述参数输入界面为空值的脚本模板。The fifth obtaining unit 1141 is configured to acquire a script template whose parameter input interface is a null value.
具体地,若所述参数输入界面为空值,表明该参数输入界面没有接收到用户输入的脚本参数。Specifically, if the parameter input interface is a null value, it indicates that the parameter input interface does not receive the script parameter input by the user.
删除单元1142,用于删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数。The deleting unit 1142 is configured to delete a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment.
第三处理单元1143,用于根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。The third processing unit 1143 is configured to generate a test case according to the remaining preset code segments and the script parameters corresponding to the remaining preset code segments.
具体实施中,所述测试用例可以通过脚本文件的形式保存于预设的测试目录中,该脚本文件的文件格式可以为YAML格式。通过搜索该预设的测试目录中的YAML格式文件,可快速获取到对应的测试用例。In a specific implementation, the test case may be saved in a preset test directory by using a script file, and the file format of the script file may be a YAML format. By searching the YAML format file in the preset test directory, the corresponding test case can be quickly obtained.
实施本申请实施例,有效避免了因多余脚本模板造成测试用例出错的问题,提高了测试用例编写的速度以及准确性。The implementation of the embodiment of the present application effectively avoids the problem that the test case is caused by the redundant script template, and improves the speed and accuracy of the test case writing.
任务获取单元120,用于获取所述测试用例对应的测试任务列表。The task obtaining unit 120 is configured to obtain a test task list corresponding to the test case.
具体实施中,一个测试用例可包括一个或者一个以上的测试任务。每一个测试任务通过预设的任务标识符进行标记,该任务标识符可设置于每一个测试任务的第一行最左侧,以实现对不同测试任务的区分并提高识别测试任务的速度。该任务标识符可以为“-”。通过加载保存有该测试用例的脚本文件,并识别预设的任务标识符,可获取所述测试用例对应的测试任务列表。In a specific implementation, a test case may include one or more test tasks. Each test task is marked by a preset task identifier, which can be set to the leftmost side of the first row of each test task to achieve differentiation of different test tasks and improve the speed of identifying test tasks. The task identifier can be "-". The test task list corresponding to the test case can be obtained by loading a script file that saves the test case and identifying a preset task identifier.
结果生成单元130,用于依次执行所述测试任务列表对应的测试任务,以生成执行结果。The result generating unit 130 is configured to sequentially execute the test task corresponding to the test task list to generate an execution result.
其中,根据不同类型的测试用例描述结构会生成不同类型的测试任务。若测试用例描述结构为接口调用结构,该接口调用结构对应生成的测试任务为接口调用任务,该接口调用任务用于调用执行动作所需的输入参数。若测试用例 描述结构为接口控制结构,该接口控制结构对应生成的测试任务为接口控制任务,该接口控制任务用于根据对应的控制逻辑执行控制动作。Among them, describing the structure according to different types of test cases will generate different types of test tasks. If the test case description structure is an interface call structure, the test task generated by the interface call structure is an interface call task, and the interface call task is used to call an input parameter required for executing the action. If the test case description structure is an interface control structure, the test task generated by the interface control structure is an interface control task, and the interface control task is used to perform a control action according to the corresponding control logic.
具体实施中,通过加载保存有测试用例的脚本文件,例如通过搜索该预设的测试目录中的YAML格式文件,并根据检索相对应的文件名,以获取得到并加载对应的脚本文件,即可获得所述测试用例对应的测试任务列表。依次执行所述测试任务列表对应的测试任务可具体为根据所述任务标识符的排列顺序,按照从上到下的顺序依次执行所述测试任务。In a specific implementation, by loading a script file that saves a test case, for example, by searching for a YAML format file in the preset test directory, and acquiring a corresponding script file according to the corresponding file name, the corresponding script file can be obtained and loaded. Obtain a test task list corresponding to the test case. The test task corresponding to the test task list may be executed in sequence according to the order of the task identifiers, and the test tasks are sequentially executed in the order from top to bottom.
报告生成单元140,用于根据所述执行结果生成测试报告。The report generating unit 140 is configured to generate a test report according to the execution result.
具体请参照图10,其为本申请一实施例提供的一种接口自动化测试装置的报告生成单元140示意性框图。进一步地,报告生成单元140包括第六获取单元141以及第四处理单元142。For details, please refer to FIG. 10 , which is a schematic block diagram of a report generating unit 140 of an interface automatic testing device according to an embodiment of the present application. Further, the report generation unit 140 includes a sixth acquisition unit 141 and a fourth processing unit 142.
第六获取单元141,用于获取所述执行结果的成功率;a sixth obtaining unit 141, configured to acquire a success rate of the execution result;
具体实施中,通过获取测试任务的总执行次数以及该测试任务的成功执行次数,并将成功执行次数与总执行次数相除即可获得所述执行结果的成功率。In a specific implementation, the success rate of the execution result is obtained by acquiring the total number of executions of the test task and the number of successful executions of the test task, and dividing the number of successful executions by the total number of executions.
第四处理单元142,用于根据所述执行结果的成功率生成相对应的测试报告。The fourth processing unit 142 is configured to generate a corresponding test report according to the success rate of the execution result.
具体实施中,若该成功率低于预设的第一阈值,生成第一测试报告;若该成功率大于或者等于预设的第一阈值,生成第二测试报告。例如,该第一阈值可以为90%。若成功率低于90%,生成的第一测试报告为测试失败。若成功率大于或者等于90%,生成的第二测试报告为测试成功。In a specific implementation, if the success rate is lower than a preset first threshold, a first test report is generated; and if the success rate is greater than or equal to a preset first threshold, a second test report is generated. For example, the first threshold can be 90%. If the success rate is less than 90%, the first test report generated is a test failure. If the success rate is greater than or equal to 90%, the generated second test report is the test success.
上述装置100可以实现为一种计算机程序的形式,计算机程序可以在如图11所示的计算机设备上运行。The above apparatus 100 can be implemented in the form of a computer program that can be run on a computer device as shown in FIG.
请参阅图11,图11是本申请实施例提供的一种计算机设备的示意性框图。该计算机设备500设备可以是终端。该终端可以是智能手机、平板电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式设备等具有通信功能的电子设备。Referring to FIG. 11, FIG. 11 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 device can be a terminal. The terminal can be a communication-enabled electronic device such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
该计算机设备500包括通过系统总线510连接的处理器520、存储器和网络接口550,其中,存储器可以包括非易失性存储介质530和内存储器540。The computer device 500 includes a processor 520, a memory, and a network interface 550 that are coupled by a system bus 510, where the memory can include a non-volatile storage medium 530 and an internal memory 540.
该非易失性存储介质530可存储操作系统531和计算机程序532。该计算机程序532被执行时,可使得处理器520执行一种接口自动化测试方法。The non-volatile storage medium 530 can store an operating system 531 and a computer program 532. When the computer program 532 is executed, the processor 520 can be caused to perform an interface automated test method.
该处理器520用于提供计算和控制能力,支撑整个计算机设备500的运行。The processor 520 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
该内存储器540为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器520执行时,可使得处理器520执行一种接口自动化测试方法。The internal memory 540 provides an environment for the operation of a computer program in a non-volatile storage medium that, when executed by the processor 520, causes the processor 520 to perform an interface automated test method.
该网络接口550用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,该计算机设备的示意性框图仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 550 is used for network communication, such as sending assigned tasks and the like. It will be understood by those skilled in the art that the schematic block diagram of the computer device is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device 500 to which the solution of the present application is applied. The specific computer device 500 More or fewer components than those shown in the figures may be included, or some components may be combined, or have different component arrangements.
其中,所述处理器520用于运行存储在存储器中的程序代码,以实现如下功能:根据预设的测试用例描述结构生成测试用例;获取所述测试用例对应的测试任务列表;依次执行所述测试任务列表对应的测试任务,以生成执行结果;根据所述执行结果生成测试报告。The processor 520 is configured to run the program code stored in the memory to implement a function of: generating a test case according to a preset test case description structure; acquiring a test task list corresponding to the test case; and sequentially performing the Testing a test task corresponding to the task list to generate an execution result; generating a test report according to the execution result.
在一实施例中,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,处理器520在执行所述根据预设的测试用例描述结构生成测试用例的步骤时,具体执行如下步骤:判断所述脚本模板是否处于激活状态;若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段;通过所述参数输入界面获取与所述预设代码段对应的脚本参数;根据所述预设代码段以及脚本参数生成测试用例。In an embodiment, the test case description structure includes a script template, the script template includes a parameter input interface and a preset code segment, and the processor 520 performs the step of generating a test case according to the preset test case description structure. When the script template is in an active state, the preset code segment corresponding to the script template is obtained, and the pre-preparation is obtained through the parameter input interface. Setting a script parameter corresponding to the code segment; generating a test case according to the preset code segment and the script parameter.
在一实施例中,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,处理器520在执行所述判断所述脚本模板是否处于激活状态的步骤时,具体执行如下步骤:通过所述模板备选框获取用户输入的字符;根据所述用户输入的字符获取与所述字符相匹配的脚本模板;将所述与所述字符相匹配的脚本模板展示于所述模板备选框;判断所述展示于所述模板备选框的脚本模板是否被选中;若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。In an embodiment, the test case description structure further includes a template candidate box for displaying a script template, and the processor 520 performs the following steps when performing the step of determining whether the script template is in an active state: Obtaining a character input by the user by using the template candidate box; acquiring a script template matching the character according to the character input by the user; displaying the script template matching the character in the template candidate a box is determined to determine whether the script template displayed in the template candidate box is selected; if the script template displayed in the template candidate box is selected, it is determined that the selected script template is in an active state.
在一实施例中,处理器520在执行所述根据所述预设代码段以及脚本参数生成测试用例的步骤时,具体执行如下步骤:获取所述参数输入界面为空值的脚本模板;删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数;根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。In an embodiment, when performing the step of generating a test case according to the preset code segment and the script parameter, the processor 520 specifically performs the following steps: acquiring a script template whose parameter input interface is a null value; a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment; according to the remaining preset code segment and the remaining preset The script parameters corresponding to the code segment generate test cases.
在一实施例中,处理器520在执行所述根据所述执行结果生成测试报告的步骤时,具体执行如下步骤:获取所述执行结果的成功率;根据所述执行结果的成功率生成相对应的测试报告。In an embodiment, when performing the step of generating a test report according to the execution result, the processor 520 specifically performs the following steps: acquiring a success rate of the execution result; and correspondingly generating a success rate according to the execution result Test report.
应当理解,在本申请实施例中,处理器520可以是中央处理单元(Central Processing Unit,CPU),该处理器520还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that, in the embodiment of the present application, the processor 520 may be a central processing unit (CPU), and the processor 520 may also be other general-purpose processors, a digital signal processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
本领域技术人员可以理解,该计算机设备500的示意性框图并不构成对计算机设备500的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art will appreciate that the schematic block diagram of the computer device 500 does not constitute a limitation to the computer device 500, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
在本申请的另一实施例中提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,其中计算机程序包括程序指令。所述程序指令被处理器执行时实现本申请实施例的接口自动化测试方法。In another embodiment of the present application, a computer readable storage medium is stored, the computer readable storage medium storing a computer program, wherein the computer program comprises program instructions. The interface automatic test method of the embodiment of the present application is implemented when the program instruction is executed by a processor.
该计算机可读存储介质可以是U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The computer readable storage medium may be any medium that can store program code, such as a USB flash drive, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both, for clarity of hardware and software. Interchangeability, the composition and steps of the various examples have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods to implement the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present application.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The foregoing is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto, and any equivalents can be easily conceived by those skilled in the art within the technical scope disclosed in the present application. Modifications or substitutions are intended to be included within the scope of the present application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.

Claims (20)

  1. 一种接口自动化测试方法,其特征在于,包括:An interface automatic testing method, comprising:
    根据预设的测试用例描述结构生成测试用例;Generating test cases based on a preset test case description structure;
    获取所述测试用例对应的测试任务列表;Obtaining a test task list corresponding to the test case;
    依次执行所述测试任务列表对应的测试任务,以生成执行结果;Performing test tasks corresponding to the test task list in sequence to generate an execution result;
    根据所述执行结果生成测试报告。A test report is generated based on the execution result.
  2. 如权利要求1所述的方法,其特征在于,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,所述根据预设的测试用例描述结构生成测试用例,包括:The method according to claim 1, wherein the test case description structure comprises a script template, the script template includes a parameter input interface and a preset code segment, and the test case is generated according to a preset test case description structure. ,include:
    判断所述脚本模板是否处于激活状态;Determining whether the script template is in an active state;
    若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段;If the script template is in an active state, acquiring a preset code segment corresponding to the script template;
    通过所述参数输入界面获取与所述预设代码段对应的脚本参数;Obtaining, by the parameter input interface, a script parameter corresponding to the preset code segment;
    根据所述预设代码段以及脚本参数生成测试用例。A test case is generated based on the preset code segment and script parameters.
  3. 如权利要求2所述的方法,其特征在于,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,所述判断所述脚本模板是否处于激活状态,包括:The method of claim 2, wherein the test case description structure further comprises a template candidate box for displaying a script template, and determining whether the script template is in an active state comprises:
    通过所述模板备选框获取用户输入的字符;Obtaining characters input by the user through the template candidate box;
    根据所述用户输入的字符获取与所述字符相匹配的脚本模板;Obtaining a script template matching the character according to the character input by the user;
    将所述与所述字符相匹配的脚本模板展示于所述模板备选框;Displaying the script template matching the character in the template candidate box;
    判断所述展示于所述模板备选框的脚本模板是否被选中;Determining whether the script template displayed in the template candidate box is selected;
    若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。If the script template displayed in the template candidate box is selected, it is determined that the selected script template is in an active state.
  4. 如权利要求3所述的方法,其特征在于,所述根据所述预设代码段以及脚本参数生成测试用例,包括:The method of claim 3, wherein the generating the test case according to the preset code segment and the script parameter comprises:
    获取所述参数输入界面为空值的脚本模板;Obtaining a script template that the parameter input interface is a null value;
    删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数;Deleting a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment;
    根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。A test case is generated based on the remaining preset code segments and script parameters corresponding to the remaining preset code segments.
  5. 如权利要求1所述的方法,其特征在于,所述根据所述执行结果生成测试报告,包括:The method of claim 1, wherein the generating a test report based on the execution result comprises:
    获取所述执行结果的成功率;Obtaining a success rate of the execution result;
    根据所述执行结果的成功率生成相对应的测试报告。A corresponding test report is generated according to the success rate of the execution result.
  6. 一种接口自动化测试装置,其特征在于,包括:An interface automatic testing device, comprising:
    用例生成单元,用于根据预设的测试用例描述结构生成测试用例;a use case generating unit, configured to generate a test case according to a preset test case description structure;
    任务获取单元,用于获取所述测试用例对应的测试任务列表;a task obtaining unit, configured to obtain a test task list corresponding to the test case;
    结果生成单元,用于依次执行所述测试任务列表对应的测试任务,以生成执行结果;a result generating unit, configured to sequentially execute a test task corresponding to the test task list to generate an execution result;
    报告生成单元,用于根据所述执行结果生成测试报告。a report generating unit, configured to generate a test report according to the execution result.
  7. 如权利要求6所述的装置,其特征在于,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,所述用例生成单元包括:The apparatus according to claim 6, wherein the test case description structure comprises a script template, the script template includes a parameter input interface and a preset code segment, and the use case generating unit comprises:
    第一判断单元,用于判断所述脚本模板是否处于激活状态;a first determining unit, configured to determine whether the script template is in an active state;
    第一获取单元,用于若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段;a first acquiring unit, configured to acquire a preset code segment corresponding to the script template if the script template is in an activated state;
    第二获取单元,用于通过所述参数输入界面获取与所述预设代码段对应的脚本参数;a second acquiring unit, configured to acquire, by using the parameter input interface, a script parameter corresponding to the preset code segment;
    第一处理单元,用于根据所述预设代码段以及脚本参数生成测试用例。The first processing unit is configured to generate a test case according to the preset code segment and the script parameter.
  8. 如权利要求7所述的装置,其特征在于,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,所述第一判断单元包括:The apparatus according to claim 7, wherein the test case description structure further comprises a template candidate box for displaying a script template, the first determining unit comprising:
    第三获取单元,用于通过所述模板备选框获取用户输入的字符;a third acquiring unit, configured to acquire, by using the template candidate box, a character input by a user;
    第四获取单元,用于根据所述用户输入的字符获取与所述字符相匹配的脚本模板;a fourth acquiring unit, configured to acquire, according to the character input by the user, a script template that matches the character;
    展示单元,用于将所述与所述字符相匹配的脚本模板展示于所述模板备选框;a display unit, configured to display the script template matching the character in the template candidate box;
    第二判断单元,用于判断所述展示于所述模板备选框的脚本模板是否被选中;a second determining unit, configured to determine whether the script template displayed in the template candidate box is selected;
    第二处理单元,用于若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。The second processing unit is configured to determine that the selected script template is in an active state if the script template displayed in the template candidate box is selected.
  9. 如权利要求8所述的装置,其特征在于,所述第一处理单元包括:The apparatus of claim 8 wherein said first processing unit comprises:
    第五获取单元,用于获取所述参数输入界面为空值的脚本模板;a fifth acquiring unit, configured to acquire a script template that the parameter input interface is a null value;
    删除单元,用于删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数;a deleting unit, configured to delete a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment;
    第三处理单元,用于根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。And a third processing unit, configured to generate a test case according to the remaining preset code segments and the script parameters corresponding to the remaining preset code segments.
  10. 如权利要求6所述的装置,其特征在于,所述报告生成单元包括:The device according to claim 6, wherein the report generating unit comprises:
    第六获取单元,用于获取所述执行结果的成功率;a sixth obtaining unit, configured to obtain a success rate of the execution result;
    第四处理单元,用于根据所述执行结果的成功率生成相对应的测试报告。And a fourth processing unit, configured to generate a corresponding test report according to the success rate of the execution result.
  11. 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现以下步骤:A computer apparatus comprising a memory, a processor, and a computer program stored on the memory and operative on the processor, wherein the processor, when executing the program, implements the following steps:
    根据预设的测试用例描述结构生成测试用例;Generating test cases based on a preset test case description structure;
    获取所述测试用例对应的测试任务列表;Obtaining a test task list corresponding to the test case;
    依次执行所述测试任务列表对应的测试任务,以生成执行结果;Performing test tasks corresponding to the test task list in sequence to generate an execution result;
    根据所述执行结果生成测试报告。A test report is generated based on the execution result.
  12. 如权利要求11所述的计算机设备,其特征在于,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,所述根据预设的测试用例描述结构生成测试用例,包括:The computer device according to claim 11, wherein the test case description structure comprises a script template, the script template includes a parameter input interface and a preset code segment, and the test generates a test according to a preset test case description structure. Use cases, including:
    判断所述脚本模板是否处于激活状态;Determining whether the script template is in an active state;
    若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段;If the script template is in an active state, acquiring a preset code segment corresponding to the script template;
    通过所述参数输入界面获取与所述预设代码段对应的脚本参数;Obtaining, by the parameter input interface, a script parameter corresponding to the preset code segment;
    根据所述预设代码段以及脚本参数生成测试用例。A test case is generated based on the preset code segment and script parameters.
  13. 如权利要求12所述的计算机设备,其特征在于,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,所述判断所述脚本模板是否处于激活状态,包括:The computer device according to claim 12, wherein the test case description structure further comprises a template candidate box for displaying a script template, and determining whether the script template is in an active state comprises:
    通过所述模板备选框获取用户输入的字符;Obtaining characters input by the user through the template candidate box;
    根据所述用户输入的字符获取与所述字符相匹配的脚本模板;Obtaining a script template matching the character according to the character input by the user;
    将所述与所述字符相匹配的脚本模板展示于所述模板备选框;Displaying the script template matching the character in the template candidate box;
    判断所述展示于所述模板备选框的脚本模板是否被选中;Determining whether the script template displayed in the template candidate box is selected;
    若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。If the script template displayed in the template candidate box is selected, it is determined that the selected script template is in an active state.
  14. 如权利要求13所述的计算机设备,其特征在于,所述根据所述预设代码段以及脚本参数生成测试用例,包括:The computer device according to claim 13, wherein the generating the test case according to the preset code segment and the script parameter comprises:
    获取所述参数输入界面为空值的脚本模板;Obtaining a script template that the parameter input interface is a null value;
    删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数;Deleting a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment;
    根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。A test case is generated based on the remaining preset code segments and script parameters corresponding to the remaining preset code segments.
  15. 如权利要求11所述的计算机设备,其特征在于,所述根据所述执行结果生成测试报告,包括:The computer device according to claim 11, wherein the generating a test report according to the execution result comprises:
    获取所述执行结果的成功率;Obtaining a success rate of the execution result;
    根据所述执行结果的成功率生成相对应的测试报告。A corresponding test report is generated according to the success rate of the execution result.
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行以下操作:A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, the computer program comprising program instructions that, when executed by a processor, cause the processor to perform the following operations :
    根据预设的测试用例描述结构生成测试用例;Generating test cases based on a preset test case description structure;
    获取所述测试用例对应的测试任务列表;Obtaining a test task list corresponding to the test case;
    依次执行所述测试任务列表对应的测试任务,以生成执行结果;Performing test tasks corresponding to the test task list in sequence to generate an execution result;
    根据所述执行结果生成测试报告。A test report is generated based on the execution result.
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述测试用例描述结构包括脚本模板,所述脚本模板包括参数输入界面以及预设代码段,所述根据预设的测试用例描述结构生成测试用例,包括:The computer readable storage medium of claim 16, wherein the test case description structure comprises a script template, the script template comprising a parameter input interface and a preset code segment, the description according to a preset test case Structure generation test cases, including:
    判断所述脚本模板是否处于激活状态;Determining whether the script template is in an active state;
    若所述脚本模板处于激活状态,获取与所述脚本模板对应的预设代码段;If the script template is in an active state, acquiring a preset code segment corresponding to the script template;
    通过所述参数输入界面获取与所述预设代码段对应的脚本参数;Obtaining, by the parameter input interface, a script parameter corresponding to the preset code segment;
    根据所述预设代码段以及脚本参数生成测试用例。A test case is generated based on the preset code segment and script parameters.
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述测试用例描述结构还包括用于展示脚本模板的模板备选框,所述判断所述脚本模板是否处于激活状态,包括:The computer readable storage medium according to claim 17, wherein the test case description structure further comprises a template candidate box for displaying a script template, and determining whether the script template is in an active state comprises:
    通过所述模板备选框获取用户输入的字符;Obtaining characters input by the user through the template candidate box;
    根据所述用户输入的字符获取与所述字符相匹配的脚本模板;Obtaining a script template matching the character according to the character input by the user;
    将所述与所述字符相匹配的脚本模板展示于所述模板备选框;Displaying the script template matching the character in the template candidate box;
    判断所述展示于所述模板备选框的脚本模板是否被选中;Determining whether the script template displayed in the template candidate box is selected;
    若所述展示于所述模板备选框的脚本模板被选中,判定被选中的脚本模板处于激活状态。If the script template displayed in the template candidate box is selected, it is determined that the selected script template is in an active state.
  19. 如权利要求18所述的计算机可读存储介质,其特征在于,所述根据所述预设代码段以及脚本参数生成测试用例,包括:The computer readable storage medium of claim 18, wherein the generating the test case according to the preset code segment and the script parameter comprises:
    获取所述参数输入界面为空值的脚本模板;Obtaining a script template that the parameter input interface is a null value;
    删除所述参数输入界面为空值的脚本模板,以得出剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数;Deleting a script template whose parameter input interface is a null value, to obtain a remaining preset code segment and a script parameter corresponding to the remaining preset code segment;
    根据剩余的预设代码段以及与所述剩余的预设代码段对应的脚本参数生成测试用例。A test case is generated based on the remaining preset code segments and script parameters corresponding to the remaining preset code segments.
  20. 如权利要求16所述的计算机可读存储介质,其特征在于,所述根据所述执行结果生成测试报告,包括:The computer readable storage medium according to claim 16, wherein the generating a test report according to the execution result comprises:
    获取所述执行结果的成功率;Obtaining a success rate of the execution result;
    根据所述执行结果的成功率生成相对应的测试报告。A corresponding test report is generated according to the success rate of the execution result.
PCT/CN2018/084310 2018-02-24 2018-04-25 Automatic interface test method and apparatus, and device and computer-readable storage medium WO2019161619A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810156599.6A CN108388514B (en) 2018-02-24 2018-02-24 Interface automation test method, device, equipment and computer readable storage medium
CN201810156599.6 2018-02-24

Publications (1)

Publication Number Publication Date
WO2019161619A1 true WO2019161619A1 (en) 2019-08-29

Family

ID=63068478

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/084310 WO2019161619A1 (en) 2018-02-24 2018-04-25 Automatic interface test method and apparatus, and device and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN108388514B (en)
WO (1) WO2019161619A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022128469A1 (en) * 2020-12-15 2022-06-23 International Business Machines Corporation System testing infrastructure with hidden variable, hidden attribute, and hidden value detection

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026631B (en) * 2018-10-09 2024-03-26 顺丰科技有限公司 Automatic interface detection method, device and server
CN109783367B (en) * 2018-12-15 2023-10-27 中国平安人寿保险股份有限公司 Interface testing method, device, computer device and storage medium
CN109710532A (en) * 2018-12-28 2019-05-03 北京金山安全软件有限公司 Test case management method and device and electronic equipment
CN109783298A (en) * 2019-01-18 2019-05-21 上海磐启微电子有限公司 A kind of flexible controllable software-hardware synergism SoC verification method of process
CN110046088A (en) * 2019-02-19 2019-07-23 阿里巴巴集团控股有限公司 A kind of interface test method, device and equipment
CN110069735A (en) * 2019-03-20 2019-07-30 平安普惠企业管理有限公司 JS code is anti-to be repeatedly injected method, apparatus, computer equipment and storage medium
CN111104312A (en) * 2019-11-21 2020-05-05 苏州浪潮智能科技有限公司 Test case variable storage management method, system, terminal and storage medium
CN111199146B (en) * 2020-01-10 2023-09-26 深圳前海环融联易信息科技服务有限公司 Test report generation method, device, computer equipment and storage medium
CN112231210A (en) * 2020-10-13 2021-01-15 中移(杭州)信息技术有限公司 Test method, equipment and storage medium under network function virtualization environment
CN112286825A (en) * 2020-11-24 2021-01-29 北斗星通智联科技有限责任公司 Screen testing method and device for intelligent cabin and electronic equipment
CN113918395A (en) * 2021-09-29 2022-01-11 浪潮(山东)计算机科技有限公司 Test report generation method, device and medium
CN114448665A (en) * 2021-12-22 2022-05-06 天翼云科技有限公司 Method and device for detecting WEB application firewall rules and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834595A (en) * 2015-02-15 2015-08-12 网易(杭州)网络有限公司 Visual automatic test method and system
CN105335293A (en) * 2015-11-30 2016-02-17 努比亚技术有限公司 Automatic testing system and method based on parallel ports
CN106095673A (en) * 2016-06-07 2016-11-09 深圳市泰久信息系统股份有限公司 Automated testing method based on WEB interface and system
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107301122A (en) * 2017-05-10 2017-10-27 深圳市小牛在线互联网信息咨询有限公司 interface test method, device, storage medium and computer equipment
CN107506294A (en) * 2017-07-04 2017-12-22 深圳市小牛在线互联网信息咨询有限公司 Visualize automated testing method, device, storage medium and computer equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834595A (en) * 2015-02-15 2015-08-12 网易(杭州)网络有限公司 Visual automatic test method and system
CN105335293A (en) * 2015-11-30 2016-02-17 努比亚技术有限公司 Automatic testing system and method based on parallel ports
CN106095673A (en) * 2016-06-07 2016-11-09 深圳市泰久信息系统股份有限公司 Automated testing method based on WEB interface and system
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022128469A1 (en) * 2020-12-15 2022-06-23 International Business Machines Corporation System testing infrastructure with hidden variable, hidden attribute, and hidden value detection

Also Published As

Publication number Publication date
CN108388514B (en) 2021-02-23
CN108388514A (en) 2018-08-10

Similar Documents

Publication Publication Date Title
WO2019161619A1 (en) Automatic interface test method and apparatus, and device and computer-readable storage medium
CN107193750B (en) Script recording method and device
US9824002B2 (en) Tracking of code base and defect diagnostic coupling with automated triage
CN109033772B (en) Verification information input method and device
US20160300044A1 (en) Anti-debugging method
WO2019214109A1 (en) Monitoring device and method for testing process, and computer readable storage medium
CN108170552B (en) Method, device and equipment for capturing Dump file
CN110955409B (en) Method and device for creating resources on cloud platform
US11169910B2 (en) Probabilistic software testing via dynamic graphs
CN114090113B (en) Method, device, equipment and storage medium for dynamically loading data source processing plug-in
CN111694684A (en) Abnormal construction method and device of storage equipment, electronic equipment and storage medium
CN114816772B (en) Debugging method, debugging system and computing device for application running based on compatible layer
CN112395194B (en) Method and device for accessing test platform
CN114218072A (en) Test script generation method and device, storage medium and computer equipment
CN111949510B (en) Test processing method, device, electronic equipment and readable storage medium
CN111859403A (en) Method and device for determining dependency vulnerability, electronic equipment and storage medium
CN110727537A (en) Method and device for uniformly processing response message, computer equipment and storage medium
CN113297088B (en) Test method, test device, electronic equipment and storage medium
CN113626332B (en) Debugging method, device, equipment, storage medium and computer program product
US20240104085A1 (en) Computer system and method for evaluating integrity and parsing of a file system and parsing implementation
CN111522737B (en) Automatic test verification method and device for front-end interface and storage medium
CN114064484A (en) Interface testing method and device, electronic equipment and readable storage medium
CN110737488A (en) MIPS platform-based method, device and equipment for printing embedded Linux application program background
CN115878460A (en) Regression testing method, device, computer equipment and storage medium
CN112527658A (en) Test case processing method and device for unit test

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: 18907009

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 27.11.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18907009

Country of ref document: EP

Kind code of ref document: A1