Test script playback method and device, storage medium and electronic device

By backing up and restoring the initialization data of the test script in the automated test platform, combined with the use of preset recording scripts, cross-platform recording and playback of test scripts is realized, solving the problem that test scripts can only be recorded and played on a single platform in the existing technology. Problem, improving the flexibility and efficiency of testing.

CN119512812APending Publication Date: 2025-02-25QINGDAO HAIER TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411462533.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

The test scripts of the existing automated test platform can only be recorded and played back on a single platform, and cannot meet the testing needs of cross-platform and multi-terminal convergence, resulting in reduced testing efficiency and coverage.

Method used

By backing up the relevant initialization data into the database before the test script is recorded, recording cross-platform test cases using preset recording scripts, and restoring initialization data on the target platform for cross-platform playback.

Benefits of technology

Cross-platform recording and playback test scripts are realized, improving the flexibility of recording and playback of test scripts, and solving the limitations of single platform recording and playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512812A_ABST
    Figure CN119512812A_ABST
Patent Text Reader

Abstract

The invention discloses a test script playback method and device, a storage medium and an electronic device, and relates to the technical field of smart home, the test script playback method comprises the following steps: backing up initialization data related to a to-be-recorded test script into a database; a first operation and a second operation are recorded through a preset recording script to obtain the test script, the first operation is a test operation executed by a target object on a recording platform, and the second operation is a test operation executed by the target object on an associated platform of the recording platform; and recovering the initialized data from the database to a target platform in which the test script needs to be played back, and playing back the test script on the target platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart home technology, and more specifically, to a method and device for replaying a test script, a storage medium, and an electronic device. Background Art

[0002] Traditional automated testing platforms are usually designed to record and replay test scripts only in a specific environment. This design is based on the consideration of environmental consistency and test case specificity. For example, if a set of test cases (i.e., test scripts) is recorded on the APP side using an automated testing tool, these test cases can only be replayed and verified on the same APP, but cannot be executed on the mini program or the Web side. Similarly, if the test case is recorded on the Web side, it can only be replayed on the Web side and cannot be crossed to the APP or mini program. This limitation has hindered the widespread application and flexibility of automated testing to a certain extent, especially in multi-terminal fusion and data-driven testing scenarios. In addition, when recording scripts, existing automated testing platforms often only focus on the operations and responses on the page, but ignore the synchronous storage and recovery of key data such as backend services, logging, MQ messages, and database status, resulting in false positives or missed tests when test cases are executed in different environments due to inconsistent data status.

[0003] Therefore, the test scripts of automated testing can only be recorded and played back on a single platform, which has limitations and cannot meet the cross-platform and multi-terminal integrated testing requirements in modern software development, reducing the efficiency and coverage of testing.

[0004] Regarding the related technologies, the test scripts of automated testing can only be recorded and played back on a single platform, which has limitations and other problems, and no effective solution has been proposed yet.

[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention

[0006] The embodiments of the present application provide a method and device, a storage medium and an electronic device for replaying a test script, so as to at least solve the problem in the related art that the test script of the automated test can only be recorded on a single platform and replayed on the single platform, which is a limitation.

[0007] According to one aspect of an embodiment of the present application, a method for test script playback is provided, including: backing up initialization data related to a test script to be recorded into a database; recording a first operation and a second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by a target object on a recording platform, and the second operation is a test operation performed by the target object on an associated platform of the recording platform; restoring the initialization data from the database to a target platform that needs to play back the test script, and playing back the test script on the target platform.

[0008] In an exemplary embodiment, backing up initialization data related to the test script to be recorded to a database includes: detecting initialization data related to the test script on the recording platform, wherein the initialization data includes at least: all database data related to the test script, a message queue related to the test script, and cache data related to the test script; and backing up the initialization data to the database in the dimension of the test script.

[0009] In an exemplary embodiment, the initialization data is backed up to the database in the dimension of the test script, including: identifying the use case name and primary key of the test script for the initialization data to obtain the data to be backed up; and backing up the data to be backed up to the database.

[0010] In an exemplary embodiment, a first operation and a second operation are recorded by a preset recording script to obtain the test script, including: determining the execution order of the first operation and the second operation; recording a third operation and operation data generated by the third operation in accordance with the execution order to obtain the test script, wherein the operation data includes at least: interface data called by the third operation, database tables and field data generated by the third operation, log records related to the third operation, and production and consumption of the third operation in a message queue corresponding to the test script, wherein the third operation includes: the first operation and the second operation.

[0011] In an exemplary embodiment, the initialization data is restored from the database to a target platform that needs to replay the test script, including: obtaining the initialization data corresponding to the test script to be replayed from the database through the script information of the test script to be replayed, wherein the script information includes at least one of the following: the use case name of the test script to be replayed, the primary key of the test script to be replayed; replacing the corresponding data of the initialization data on the target platform with the initialization data to restore the initialization data to the target platform.

[0012] In an exemplary embodiment, playing back the test script on the target platform includes: detecting the script execution environment of the target platform; and when it is determined that the script execution environment is consistent with the script recording environment of the recording platform, playing back the test script on the target platform.

[0013] In an exemplary embodiment, after the target platform plays back the test script, the method further includes: determining a playback result of the test script; and executing an alarm event when the playback result indicates a playback failure, wherein the alarm event is at least used to indicate that the test script and initialization data corresponding to the test script need to be verified.

[0014] According to another aspect of an embodiment of the present application, a device for replaying a test script is also provided, including: a backup module, used to back up initialization data related to the test script to be recorded into a database; a recording module, used to record a first operation and a second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on a recording platform, and the second operation is a test operation performed by the target object on an associated platform of the recording platform; a playback module, used to restore the initialization data from the database to a target platform that needs to replay the test script, and replay the test script on the target platform.

[0015] According to another aspect of the embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned test script playback method when running.

[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the test script playback method through the computer program.

[0017] According to another aspect of the embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method for replaying the test script is implemented.

[0018] Through this application, the initialization data related to the test script to be recorded is backed up to a database; the first operation and the second operation are recorded by a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on the associated platform of the recording platform; the initialization data is restored from the database to the target platform where the test script needs to be replayed, and the test script is replayed on the target platform. That is to say, by backing up the initialization data of the test script before recording the test script, recording the test script through a preset recording script that can perform cross-platform test case recording, and restoring the complete initialization data of the test script on the target platform, cross-platform recording of the test script and cross-platform playback of the recorded test script can be achieved. Therefore, the above technical solution is adopted to solve the problem that the test script of the automated test in the related technology can only be recorded on a single platform and replayed on the single platform, which has limitations; the flexibility of recording and replaying the test script is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0021] Figure 1 is a schematic diagram of a hardware environment of an optional test script playback method according to an embodiment of the present application;

[0022] Figure 2 is a flowchart of an optional test script playback method according to an embodiment of the present application;

[0023] Figure 3 It is a data backup schematic diagram of an optional test script playback method according to an embodiment of the present application;

[0024] Figure 4 It is a script recording schematic diagram of an optional test script playback method according to an embodiment of the present application;

[0025] Figure 5 It is a schematic diagram of a script file of an optional test script playback method according to an embodiment of the present application;

[0026] Figure 6is a script playback schematic diagram of an optional test script playback method according to an embodiment of the present application;

[0027] Figure 7 It is a structural block diagram of an optional test script playback device according to an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] According to one aspect of an embodiment of the present application, a method for replaying a test script is provided. The method for replaying a test script is widely used in smart home, smart home, smart home device ecology, smart home ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the method for replaying a test script can be applied to Figure 1 In the hardware environment shown in FIG. 1 , a plurality of terminal devices 102 and a server 104 are formed. Figure 1 As shown, the server 104 is connected to multiple terminal devices 102 via a network, and can be used to provide services (such as application services, etc.) for the terminals or clients installed on the terminals. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.

[0031] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.

[0032] In this embodiment, a method for replaying a test script is provided, including but not limited to being applied to a server associated with a recording platform and a playback platform. Figure 2 : is a flowchart of a method for replaying a test script according to an embodiment of the present application, the process comprising the following steps:

[0033] Step S202: backing up the initialization data related to the test script to be recorded into a database;

[0034] Specifically, initialization data related to the test script to be recorded on the recording platform of the test script may be backed up into a database.

[0035] Step S204: recording the first operation and the second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform;

[0036] It should be noted that the preset recording script allows for cross-platform test case recording;

[0037] Step S206: restore the initialization data from the database to the target platform where the test script needs to be replayed, and replay the test script on the target platform.

[0038] Through the above steps, the initialization data related to the test script to be recorded is backed up to the database; the first operation and the second operation are recorded by the preset recording script to obtain the test script, wherein the first operation is the test operation performed by the target object on the recording platform, and the second operation is the test operation performed by the target object on the associated platform of the recording platform; the initialization data is restored from the database to the target platform where the test script needs to be replayed, and the test script is replayed on the target platform. That is to say, by backing up the initialization data of the test script before recording the test script, recording the test script through a preset recording script that can perform cross-platform test case recording, and restoring the complete initialization data of the test script on the target platform, cross-platform recording of the test script and cross-platform playback of the recorded test script can be achieved. Therefore, the above technical solution solves the problem that the test script of the automated test in the related technology can only be recorded on a single platform and replayed on the single platform, which is limited; and improves the flexibility of recording and replaying the test script.

[0039] In an exemplary embodiment, backing up initialization data related to the test script to be recorded to a database includes: detecting initialization data related to the test script on the recording platform, wherein the initialization data includes at least: all database data related to the test script, a message queue related to the test script, and cache data related to the test script; and backing up the initialization data to the database in the dimension of the test script.

[0040] Furthermore, the initialization data is backed up to the database in the dimension of the test script, including: identifying the use case name and primary key of the test script for the initialization data to obtain the data to be backed up; and backing up the data to be backed up to the database.

[0041] In the initial stage of recording automated test scripts, the system needs to detect and save all initialization data related to the script. These data are not limited to changes caused by front-end operations, but also cover data from back-end databases, message queues (MQ), caches, and other aspects. Specifically, all initialization data related to the test script to be recorded will be identified and detected first, that is, all database data, messages in message queues, and cache data related to the test script to ensure full coverage of the environment status before the script is executed. The detected initialization data will be backed up in the dimension of the test script, that is, one-to-one corresponding to each test script. That is, for each test case, the system will save the complete data status before its execution, including the status of database tables and fields, messages in message queues, data in caches, etc.

[0042] When backing up data, metadata related to the test script is added to the detected initialization data, including the use case name (i.e. the name of the script) and the primary key (used to uniquely identify the test script). This is to establish a correspondence between the test script and the initialization data stored in the database, so that the correct data state can be restored during playback. Furthermore, the database used to store initialization data is specifically used to store data related to test scripts, and can support large-scale, multi-dimensional data storage, ensuring that data can be accurately backed up and restored even in cross-platform scenarios.

[0043] Therefore, before script recording, the embodiment of the present application can ensure that the accurate environment state at the time of recording can be restored when the script is played back by detecting and backing up the initialization data corresponding to the test script, which is crucial for the integrity and consistency of the test. At the same time, by adding the identification of the test script (i.e., the use case name and primary key) to the backup data, data management and traceability can be achieved, ensuring the correct recovery of data, thereby improving the accuracy and efficiency of the test.

[0044] In an exemplary embodiment, a first operation and a second operation are recorded by a preset recording script to obtain the test script, including: determining the execution order of the first operation and the second operation; recording a third operation and operation data generated by the third operation in accordance with the execution order to obtain the test script, wherein the operation data includes at least: interface data called by the third operation, database tables and field data generated by the third operation, log records related to the third operation, and production and consumption of the third operation in a message queue corresponding to the test script, wherein the third operation includes: the first operation and the second operation.

[0045] That is, record the various operations involved in the test process and integrate these operations and the data generated into a test script. The "first operation" and "second operation" here can be understood as the specific steps that need to be performed in the test case, including but not limited to operations on the APP side, operations on the mini program side, operations on the web side, etc.

[0046] Specifically, the recording process includes:

[0047] 1) Determine the order in which the operations should be performed. Before recording the script, you first need to clarify which operations are part of the test case and in what order these operations should be performed. This step ensures the logical coherence and repeatability of the test script.

[0048] 2) Recording operations and the data they generate. The recording of operation data at least includes:

[0049] Interface data: When an operation involves interaction with other systems or services, the called API interface and its parameters are recorded to ensure that the same interface calling environment can be simulated during playback.

[0050] Database table and field data: During the operation, if the database is read or written, the relevant table and field data will be saved, including the changes before and after the operation, so that it can be restored to the initial state during playback to verify the correctness of the data.

[0051] Logging: Records all log information generated during the operation, which is very helpful for troubleshooting and tracking the test process.

[0052] Production and consumption in message queues: When a message queue (such as MQ) is involved in the operation process, the producer and consumer information of the message will be recorded, including the message content and processing status, to ensure that the logic of message delivery can be correctly simulated during cross-platform playback.

[0053] Therefore, through this recording method, a test script containing rich test data and operation logic can be obtained, which not only covers the operations of a single platform, but also can record and replay complex operations involving back-end services and data management, greatly enhancing the reusability of test scripts and cross-platform testing capabilities.

[0054] In the playback phase, this test script can be used to test on different platforms. For example, if the script was originally recorded on the APP side, it can also be played back and verified on the mini program side or the web side without re-recording. This cross-platform playback capability greatly improves test efficiency, reduces duplication of work, and ensures consistency of the test environment through data initialization, avoiding test errors caused by environmental differences.

[0055] In an exemplary embodiment, the initialization data is restored from the database to a target platform that needs to replay the test script, including: obtaining the initialization data corresponding to the test script to be replayed from the database through the script information of the test script to be replayed, wherein the script information includes at least one of the following: the use case name of the test script to be replayed, the primary key of the test script to be replayed; replacing the corresponding data of the initialization data on the target platform with the initialization data to restore the initialization data to the target platform.

[0056] It is understandable that, when the initialization data stored in the database is identified by the test script's use case name and primary key, the initialization data can be obtained through at least one of the script and the primary key, and restored to the playback platform (equivalent to the target platform in the above embodiment). Optionally, the playback platform may be the recording platform of the test script to be played back, or may not be the recording platform of the test script to be played back.

[0057] In an exemplary embodiment, playing back the test script on the target platform includes: detecting the script execution environment of the target platform; and when it is determined that the script execution environment is consistent with the script recording environment of the recording platform, playing back the test script on the target platform.

[0058] In an optional embodiment, the script execution environment of the playback platform is detected, that is, it is determined whether the restored initialization data in the target platform is consistent with the initialization data stored in the database. If they are consistent, it is determined that the script execution environment is consistent with the script recording environment of the recording platform.

[0059] In another optional embodiment, before playing back the test script, the environment of the target platform is checked to confirm whether the environment meets the requirements for executing the recorded script. This is mainly because different platforms (such as app, applet, web end) may have different operating environments, including but not limited to operating system version, browser type, system configuration, API version, etc. The execution of the test script may depend on these environmental factors, so it is crucial to ensure that the environment is consistent before playback. After detecting the environmental information of the playback platform, this information is compared with the environmental information of the original recording platform. If it is found that the two environments are consistent or can be consistent through configuration, the system will consider that the playback environment meets the conditions and can continue to execute the test script playback. During the playback of the test script, the script will simulate the operations during recording, including front-end page operations, interface calls, database interactions, logging, and MQ message processing, etc., to verify whether the functions on the target platform are consistent with the recording platform.

[0060] Therefore, the embodiments of the present application can ensure the effectiveness and accuracy of the test scripts on different platforms, avoid test failures or inaccurate results due to environmental differences, and thus improve the efficiency and quality of automated testing. In addition, this detection mechanism also allows the same test script to be reused on multiple platforms, reducing the workload of repeated testing and speeding up the test cycle, which is particularly suitable for scenarios where functions are implemented on multiple terminals at the same time.

[0061] In an exemplary embodiment, after the target platform plays back the test script, the method further includes: determining a playback result of the test script; and executing an alarm event when the playback result indicates a playback failure, wherein the alarm event is at least used to indicate that the test script and initialization data corresponding to the test script need to be verified.

[0062] Obviously, the above-described embodiments are only a part of the embodiments of the present application, not all of the embodiments. In order to better understand the above-mentioned test script playback method, the above-mentioned process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:

[0063] The automated test scripts recorded in the related art cannot be recorded across platforms, cannot record data other than pages (log records, message queue (MQ) messages, databases, interfaces), cannot be played back across platforms, and do not include data initialization during the playback process, resulting in only recording use cases on a single end, and playing back the script on the end where the script was recorded.

[0064] The embodiments of the present application can support cross-platform recording, cross-platform playback, test data storage and initialization. Specifically:

[0065] 1) Test data initialization.

[0066] Before recording the script (equivalent to the automated test script or test script) in the embodiment of the present application, the data (i.e., initialization data) involved in the use case is saved and archived. Before the use case is played back, the initial data (i.e., initialization data) before the use case is executed is restored. Optionally, the data can also be saved after the use case is executed.

[0067] Specifically, before script recording, all database data involved in the use case (i.e., test script) (for example, for shopping-related test scripts, it can be product images and product inventory), MQ (for example, for shopping-related test scripts, it can be consumption messages triggered by the flow of logistics information nodes), and cache data (for example, for shopping-related test scripts, it can be the address that needs to be captured on the checkout page, which can be retrieved from the cache instead of the database in real time) are all saved to the database in the dimension of the test case. Before script playback, restore the data to the playback platform to ensure that the data during script playback and recording are consistent, and playback will not fail due to data problems.

[0068] Saving data in the database with the dimension of test cases means storing the relevant data of the test cases in the database so that they can be called and managed during the test process. The dimensions here can refer to the case name and primary key; they can also refer to different attributes or characteristics of the test case, such as test steps, expected results, test data, priority, status, etc. By saving data in the database with the dimension of test cases, you can better organize and manage test cases and improve test efficiency and quality.

[0069] 2)Cross-platform recording.

[0070] The automated testing platform records repeatedly executable script data (ie, the test script in the above embodiment).

[0071] Different from the recording of automated test scripts in related technologies that can only include front-end pages, the test scripts recorded in the embodiments of the present application will also include the following data recordings: 1) front-end page operations (can be different front-ends, apps, mini-programs, web terminals); 2) interface data called by the page; 3) database tables and field data stored in the warehouse; 4) log records involved in the code; 5) production and consumption of MQ messages;

[0072] That is, the recorded script does not only include a single front-end, but all the terminals (app, mini-program, web terminal), database, log, MQ, and cache involved in the same use case can be recorded in the script;

[0073] During the specific recording process, follow the use case steps (equivalent to the execution order), click the automation platform to verify the data that needs to be verified, and click the automation platform to save the data that needs to be saved, until the use case execution is completed and the recording is completed.

[0074] The above data (this data refers to the data generated during script recording) will all be saved during script recording to facilitate verification of data correctness during playback.

[0075] 3) Cross-platform playback.

[0076] The same business functions are reused on multiple apps, mini programs, and web terminals.

[0077] Before replaying the test script, restore the data saved before the test case is executed (that is, the initialization data of the test script to be replayed) in the system environment where the playback is located (that is, the system environment of the playback platform), and then click Script Replay.

[0078] Therefore, through the above initialization, recording, and playback operations, development efficiency, test quality, and cost can be improved. Specifically, the use of MOCK services can help developers develop and test without real services, thereby improving development efficiency; using MOCK services can help testers simulate the behavior and response of specific scenarios, thereby improving test quality; using MOCK services can reduce the cost of development and testing because it does not require the support of real services.

[0079] Furthermore, in the case where an automated test script that needs to be recorded is: searching for a specified product on the homepage, adding it to the shopping cart, and then placing an order, after placing the order, going to the merchant management platform to check the order status, and shipping the order, since the scenario test of this script may need to cover three app ends and two mini-program ends, the recorded script needs to be repeatedly tested and verified on five ends, and the premise of the use case, execution steps, and expected results are all consistent, the specific recording and playback process of this test script includes:

[0080] Step 1: If Figure 3 As shown, select the initialization data required by the test script, including database data, cache data, and MQ data; copy the initialization data to the database for backup, and indicate the use case name and primary key that use the initialization data.

[0081] Step 2: Script recording. Figure 4 As shown, the script is recorded in combination with the initialization data. The user executes the test operation (i.e., the third operation in the above embodiment) in the execution order on multiple platforms such as app, web, applet, database, API, etc. The preset recording script records the test operation and the generated test data, including: the called interface data, the generated database table and field data, the related log records, and the production and consumption of the third operation in the message queue corresponding to the test script.

[0082] The test operations of the recorded test cases and the corresponding test scripts are as follows: Figure 5 For example, the corresponding relationship is: the test operation is "open the single product page-buy now", and the corresponding test script is "open the app and log in, click the product card, and buy the motor immediately".

[0083] Step 3: Play back the script. Figure 6 As shown, the initialization data associated with the test script to be replayed is obtained from the database, restored to the replay platform, and then the script is replayed.

[0084] In summary, a complete use case in actual work requires front-end verification of generated data, background management to check whether the data is correct, database verification data, etc., and there will be different terminals, interfaces, background management, and database data verification. The existing automated testing platform can only verify the same terminal or interface, and cannot combine the two. The cross-platform automated testing method (i.e., the playback method of the above test case) provided by the embodiment of the present application can solve this problem, so that the automated testing script recorded at one end can be played back at different terminals through cross-platform automated testing, which greatly improves the test efficiency, improves the coverage of automated testing, and the test quality.

[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0086] In this embodiment, a device for replaying a test script is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0087] Figure 7 : is a structural block diagram of an optional test script playback device according to an embodiment of the present application, the device comprising:

[0088] A backup module 72, used to back up the initialization data related to the test script to be recorded into a database;

[0089] A recording module 74, configured to record the first operation and the second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform;

[0090] The playback module 76 is used to restore the initialization data from the database to the target platform where the test script needs to be played back, and play back the test script on the target platform.

[0091] Through the above-mentioned device, the initialization data related to the test script to be recorded is backed up to the database; the first operation and the second operation are recorded by the preset recording script to obtain the test script, wherein the first operation is the test operation performed by the target object on the recording platform, and the second operation is the test operation performed by the target object on the associated platform of the recording platform; the initialization data is restored from the database to the target platform where the test script needs to be replayed, and the test script is replayed on the target platform. That is to say, by backing up the initialization data of the test script before recording the test script, recording the test script through a preset recording script that can perform cross-platform test case recording, and restoring the complete initialization data of the test script on the target platform, cross-platform recording of the test script and cross-platform playback of the recorded test script can be achieved. Therefore, the above-mentioned technical solution solves the problem that the test script of the automated test in the related technology can only be recorded on a single platform and replayed on the single platform, which is limited; and improves the flexibility of recording and replaying the test script.

[0092] In an exemplary embodiment, the backup module 72 is also used to: detect the initialization data related to the test script on the recording platform, wherein the initialization data at least includes: all database data related to the test script, the message queue related to the test script, and the cache data related to the test script; and back up the initialization data to the database in the dimension of the test script.

[0093] In an exemplary embodiment, the backup module 72 is further used to: identify the use case name and primary key of the test script for the initialization data to obtain the data to be backed up; and back up the data to be backed up into the database.

[0094] In an exemplary embodiment, the recording module 74 is also used to: determine the execution order of the first operation and the second operation; record the third operation and the operation data generated by the third operation in accordance with the execution order to obtain the test script, wherein the operation data at least includes: interface data called by the third operation, database tables and field data generated by the third operation, log records related to the third operation, and production and consumption of the third operation in the message queue corresponding to the test script, wherein the third operation includes: the first operation and the second operation.

[0095] In an exemplary embodiment, the playback module 76 is also used to: obtain the initialization data corresponding to the test script to be replayed from the database through the script information of the test script to be replayed, wherein the script information includes at least one of the following: the use case name of the test script to be replayed, the primary key of the test script to be replayed; replace the corresponding data of the initialization data on the target platform with the initialization data to restore the initialization data to the target platform.

[0096] In an exemplary embodiment, the playback module 76 is further used to: detect the script execution environment of the target platform; and when it is determined that the script execution environment is consistent with the script recording environment of the recording platform, play back the test script on the target platform.

[0097] In an exemplary embodiment, the device also includes an alarm module, which is used to: determine the playback result of the test script after the target platform plays back the test script; and execute an alarm event when the playback result indicates a playback failure, wherein the alarm event is at least used to indicate the need to verify the test script and the initialization data corresponding to the test script.

[0098] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0099] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0100] S1, backing up the initialization data related to the test script to be recorded into the database;

[0101] S2, recording the first operation and the second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform;

[0102] S3, restoring the initialization data from the database to the target platform where the test script needs to be replayed, and replaying the test script on the target platform.

[0103] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0104] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0105] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0106] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0107] S1, backing up the initialization data related to the test script to be recorded into the database;

[0108] S2, recording the first operation and the second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform;

[0109] S3, restoring the initialization data from the database to the target platform where the test script needs to be replayed, and replaying the test script on the target platform.

[0110] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0111] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0112] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0113] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.

[0114] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0115] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0116] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for replaying a test script, characterized in that: include: Back up the initialization data related to the test script to be recorded to the database; The first operation and the second operation are recorded by a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform; The initialization data is restored from the database to a target platform that needs to replay the test script, and the test script is replayed on the target platform.

2. The test script playback method according to claim 1, characterized in that: Back up the initialization data related to the test script to be recorded to the database, including: Detecting initialization data related to the test script on the recording platform, wherein the initialization data at least includes: all database data related to the test script, a message queue related to the test script, and cache data related to the test script; The initialization data is backed up to the database in the dimension of the test script.

3. The test script playback method according to claim 2, characterized in that: Backing up the initialization data to the database in the dimension of the test script includes: Identify the use case name and primary key of the test script for the initialization data to obtain the data to be backed up; The data to be backed up is backed up in the database.

4. The test script playback method according to claim 1, characterized in that: The first operation and the second operation are recorded by a preset recording script to obtain the test script, including: Determining an execution order of the first operation and the second operation; Record the third operation and the operation data generated by the third operation in the execution order to obtain the test script, wherein the operation data at least includes: interface data called by the third operation, database tables and field data generated by the third operation, log records related to the third operation, and production and consumption of the third operation in the message queue corresponding to the test script, wherein the third operation includes: the first operation and the second operation.

5. The test script playback method according to claim 1, characterized in that: Restoring the initialization data from the database to a target platform that needs to replay the test script includes: Acquiring the initialization data corresponding to the test script to be replayed from the database through the script information of the test script to be replayed, wherein the script information includes at least one of the following: the use case name of the test script to be replayed, and the primary key of the test script to be replayed; The initialization data is used to replace corresponding data of the initialization data on the target platform, so as to restore the initialization data to the target platform.

6. The test script playback method according to claim 1, characterized in that: Playing back the test script on the target platform includes: Detecting the script execution environment of the target platform; When it is determined that the script execution environment is consistent with the script recording environment of the recording platform, the test script is played back on the target platform.

7. The test script playback method according to claim 1, characterized in that: After the target platform plays back the test script, the method further includes: Determining a playback result of the test script; When the playback result indicates that the playback fails, an alarm event is executed, wherein the alarm event is at least used to indicate that the test script and initialization data corresponding to the test script need to be verified.

8. A device for replaying a test script, characterized in that: include: A backup module is used to back up the initialization data related to the test script to be recorded into a database; A recording module, configured to record the first operation and the second operation through a preset recording script to obtain the test script, wherein the first operation is a test operation performed by the target object on the recording platform, and the second operation is a test operation performed by the target object on a platform associated with the recording platform; A playback module is used to restore the initialization data from the database to a target platform where the test script needs to be played back, and to play back the test script on the target platform.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.