Application program testing method and device, equipment, storage medium and program product
By recording and detecting the application traffic and detecting the operation instructions, and generating test scripts, the test accuracy problems caused by manual operations in the prior art are solved, and a more efficient and accurate testing process is achieved.
Patent Information
- Application Number
- CN202411180959.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-17
AI Technical Summary
In the prior art, the production of software test scripts relies on manual operations, which makes it difficult to ensure the accuracy of the test and is greatly affected by the skills and experience of script debuggers.
By recording and detecting the application traffic, the first and second test scripts are generated, and the application is tested based on these scripts, reducing human intervention and improving the accuracy of the test.
A comprehensive testing of the application is achieved, improving the accuracy and efficiency of the test, reducing human intervention, and ensuring the accuracy and reliability of the test script.
Smart Images

Figure CN119149412A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, storage medium and program product for testing an application. Background Art
[0002] With the rapid development of computer technology, various software applications are becoming more and more frequent. In order to ensure the normal operation of the software, various tests are usually performed on the software during the software development phase. In the test scenario, test cases are generally used to produce corresponding test scripts. At present, the production of test scripts is usually manual, that is, for new test cases that have never been built, they are usually assigned to script debuggers for construction, so that the script debuggers can manually write the corresponding test scripts using the new test cases. Since the skills and experience of each script debugger vary, it is also difficult to ensure the quality of the produced test scripts, resulting in poor test accuracy of the test scripts. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for testing an application program, which can effectively improve the testing accuracy of the application program.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application embodiment provides a method for testing an application program, including:
[0006] Recording the traffic of the application to obtain the traffic generated by the application during operation, and generating a first test script based on the traffic;
[0007] Detecting an operation instruction executed by the application on the data source during the traffic recording process, and generating a second test script based on the operation instruction;
[0008] Based on the first test script and the second test script, the application is tested. An embodiment of the present application provides a testing device for an application, comprising:
[0009] A traffic recording module, used to record traffic of an application program, obtain traffic generated by the application program during operation, and generate a first test script based on the traffic;
[0010] A detection module, used to detect the operation instructions executed by the application on the data source during the traffic recording process, and generate a second test script based on the operation instructions;
[0011] A testing module is used to test the application based on the first test script and the second test script.
[0012] An embodiment of the present application provides an electronic device, including:
[0013] A memory for storing computer executable instructions or computer programs;
[0014] The processor is used to implement the application program testing method provided in the embodiment of the present application when executing the computer executable instructions or computer program stored in the memory.
[0015] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for causing a processor to execute the application program testing method provided by the embodiment of the present application.
[0016] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the test method of the application program described above in the embodiment of the present application.
[0017] The embodiments of the present application have the following beneficial effects:
[0018] By recording the traffic of the application, the traffic generated by the application during operation is obtained, and based on the traffic, a first test script is generated, and the operation instructions executed by the application on the data source during the traffic recording process are detected, and based on the operation instructions, a second test script is generated; based on the first test script and the second test script, the application is tested. In this way, by generating the first test script and the second test script based on the recorded traffic and operation instructions, the running functions of the traffic and operation instructions of the application can be fully tested, so that the first test script and the second test script can test the application in two dimensions of traffic and operation instructions, and at the same time, the application is tested by recording, thereby effectively reducing human intervention, so that the application is tested in two dimensions of traffic and operation instructions, thereby effectively improving the test accuracy of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a schematic diagram of the architecture of a test system for an application program provided in an embodiment of the present application;
[0020] Figure 2 is a structural diagram of an electronic device for generating a test script provided in an embodiment of the present application;
[0021] Figure 3 This is a flow chart of the application testing method provided in the embodiment of the present application. Figure 1 ;
[0022] Figure 4 This is a flow chart of the application testing method provided in the embodiment of the present application. Figure 2 ;
[0023] Figure 5 It is a schematic diagram of the principle of the testing method of the application provided in the embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0025] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0026] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0028] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0029] 1) Testing script: A document or code that contains a series of specific test instructions designed to be executed by automated testing tools. The main purpose of a test script is to verify whether the functions, performance, and other characteristics of the software meet the expected requirements. Test scripts are usually written by testers to ensure that the software can run normally under various conditions. The importance of maintainability and reusability of test scripts lies in that they can reduce redundant work in the testing process and improve testing efficiency. When writing test scripts, attention should be paid to abstracting operations that may appear in multiple testing processes as targets so that these operations can be reused in different test scenarios. Test scripts can be created manually, automatically generated by test automation tools, or programmed using programming languages. In practical applications, test scripts often combine these methods to improve testing efficiency and quality.
[0030] 2) Application: In computer science and software engineering, it refers to a software program designed for a specific purpose that can provide specific functions or services to users. Applications usually run on an operating system and can be a single program or a collection of programs that work together to provide complex business functions. Applications can be divided into many types, including but not limited to: Desktop Applications: Run on the operating system of a personal computer or similar device, such as word processing software, spreadsheet software, image editing software, etc. Mobile Applications: Designed specifically for mobile devices such as smartphones or tablets, such as social media applications, games, navigation software, etc. Web Applications: Provide services through the Internet and users access them through a browser, such as online banking, email services, online shopping websites, etc. Enterprise Applications: Software designed for enterprises or organizations to manage business processes, such as customer relationship management (CRM) systems, enterprise resource planning (ERP) systems, etc. System Applications: Programs that are tightly integrated with the operating system and are used to manage hardware resources or provide system-level services, such as device drivers, operating system core components, etc. Embedded Applications: Software embedded in other devices, such as car navigation systems, smart TVs, home appliances, etc. Applications are usually written by software developers using programming languages and development tools. They can be provided in source code form or compiled binary files. The design and development of applications need to consider user needs, interface design, data processing, security, performance and maintainability.
[0031] 3) Traffic Recording: It is a technical means of monitoring and capturing network data traffic. It involves real-time or offline monitoring and recording of network communication traffic. In the context of applications, traffic recording usually refers to capturing network packets generated by applications during operation, including requests and responses. The purposes of traffic recording are varied, including: Performance analysis: By recording the network traffic generated by the application, performance indicators such as network latency and data transmission speed can be analyzed to optimize the performance of the application. Debugging and troubleshooting When an application has network problems, traffic recording can help developers check network requests and responses to find out where the problem lies. Security auditing: Traffic recording can be used to detect and prevent network attacks and analyze whether the application leaks sensitive information. Compliance checking: Some industries need to comply with specific data protection and privacy regulations. Traffic recording can help companies ensure that the network communication of applications complies with these regulatory requirements. User behavior analysis: By analyzing the network traffic generated when users interact with applications, you can understand the user's usage habits and provide a basis for product improvement and marketing. Traffic recording is usually implemented using specialized tools and software that can capture network traffic in real time or capture packets as network traffic passes through. The recorded data can be used for subsequent analysis and learning to improve the quality and service level of the application.
[0032] 4) Data Operation Recording: It is a technical means to capture the details of the operation of the application on the data source during the running process. This recording usually records the data access and manipulation of the application for subsequent analysis, debugging or performance optimization. Operation instruction recording involves the following steps: Start recording: When the application receives the command to start recording, the operation instruction recording tool starts working and prepares to record all the operation instructions of the application on the data source (such as database, file system, API, etc.). Operation instruction capture: During the recording process, the tool will capture all read and write operations of the application on the data source, including SQL queries, file access, API calls, etc. These operations may include database operations such as insert, update, delete, query, etc. Stop recording: When the command to stop recording is received, the recording tool stops capturing operation instructions and saves the recorded operation instruction records. Analyze recorded data: The recorded data is saved in a file or database and can be analyzed later. This data can be used to reproduce the execution path of the application, analyze performance problems, or for testing and verification. Operational instruction determination: During the traffic recording process, if the application performs operational instructions on the data source, these operations will be recorded and can be used to determine the actual operational instructions performed by the application during the recording. Operational instruction recording is very important for understanding how the application interacts with the data source, especially when you need to diagnose performance issues, debug errors, or perform integration testing.
[0033] 5) In response to: used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or have a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.
[0034] 6) Traffic: refers to the traffic generated by the application during operation, which refers to the amount of data transmission generated during the data exchange between the application and the external system (such as servers, databases, other applications or Internet services) when performing its functions. This traffic can be divided into the following types: Request traffic: Requests sent by the application to the external system in order to obtain information or perform operations. For example, a mobile application requests user data on the server, or a web application sends a query request to the back-end database. Response traffic: Data returned by the external system in response to the received request. For example, the user information returned by the server to the mobile application, or the query results returned by the database to the web application. Upload traffic: Data transmission from the application to the external system, such as users uploading files, photos or videos through the application. Download traffic: Data transmission from the external system to the application, such as the application downloading updates or content from the server. Real-time traffic: Data exchanged in real time between the application and the external system, which is very common in real-time communication applications (such as instant messaging, video conferencing). The following are several specific situations that generate these traffic: API calls: Applications communicate with servers or other services through APIs (application programming interfaces) to obtain or send data. Data synchronization: An application may need to synchronize data with a remote database to ensure that locally stored data is up to date. Content distribution: For example, a streaming service sends video or audio content to a user's player. Status updates: For example, a social media application may constantly get new messages or updates from a server. The traffic generated by an application typically includes the following information: Data size: The amount of data transferred, usually in bytes. Data type: The type of data transferred, such as text, pictures, videos, etc. Traffic direction: Whether the data is uploaded or downloaded. Traffic source / destination: The source address and destination address of the data. Timestamp: The time when the data transfer occurs. The traffic generated by an application is an important indicator for evaluating its performance, efficiency, and security. By monitoring the traffic, developers and testers can identify potential performance bottlenecks, security issues, or unnecessary network activities.
[0035] 7) Data Source: refers to any source or collection of sources that provide data, which can be used for various purposes such as analysis, processing, storage or display. Data sources can be in many forms and types, including but not limited to: Database: Database is one of the most common data sources. It can store structured data, such as tables in relational databases, or unstructured data, such as documents in document databases. File system: Files in the file system can also be used as data sources, including text files, CSV files, Excel files, JSON files, etc. API: Application programming interface (API) provides a standardized way to access data, which can be public or private, such as RESTful API or SOAP service. Log files: Log files generated by systems or applications are also data sources. They can provide detailed information about the operation of systems or applications. Social media platforms: Data obtained from social media platforms, such as Weibo, Facebook, Twitter, etc., are also common forms of data sources. Sensor data: Data from various sensors, such as temperature sensors, humidity sensors, GPS locators, etc., can be used as data sources to collect environmental or geographic location information. Third-party services: Many third-party services provide data, such as Google Analytics, Amazon Web Services, Salesforce, etc. They provide various data services, such as user behavior analysis, storage services, customer relationship management (CRM), etc. The choice of data source depends on the needs of the user and the purpose of the data. When processing data, it may be necessary to integrate multiple data sources together for comprehensive analysis and reporting. The management and processing of data sources usually involves data extraction, transformation, and loading (ETL) processes, as well as the assessment and maintenance of data quality.
[0036] During the implementation of the embodiments of the present application, the applicant discovered that the related technology has the following problems:
[0037] With the rapid development of computer technology, various software applications are becoming more and more frequent. In order to ensure the normal operation of the software, various tests are usually performed on the software during the software development phase. In the test scenario, test cases are generally used to produce corresponding test scripts. At present, the production of test scripts is usually manual, that is, for new test cases that have never been built, they are usually assigned to script debuggers for construction, so that the script debuggers can manually write the corresponding test scripts using the new test cases. Since the skills and experience of each script debugger vary, it is also difficult to ensure the quality of the produced test scripts, resulting in poor test accuracy of the test scripts.
[0038] Embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for testing an application, which can effectively improve the testing accuracy of the application. An exemplary application of the testing system for the application provided in embodiments of the present application is described below.
[0039] See also Figure 1 , Figure 1 It is a schematic diagram of the architecture of the test system 100 for the application provided in an embodiment of the present application. The terminal (terminal 400 is shown as an example) is connected to the server 200 via the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.
[0040] The terminal 400 is used for the user to use the client 410 and display the test script on the graphical interface 410-1 (the graphical interface 410-1 is shown as an example). The terminal 400 and the server 200 are connected to each other via a wired or wireless network.
[0041] In some embodiments, the server 200 may be an independent physical server, or a server cluster or business system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart TV, a smart watch, a car terminal, etc., but is not limited thereto. The electronic device provided in the embodiment of the present application may be implemented as a terminal or as a server. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiment of the present application.
[0042] In some embodiments, the server 200 records the traffic of the application, obtains the traffic generated by the application during operation, and sends the traffic to the terminal 400. The terminal 400 generates a first test script and a second test script for testing the application based on the operation instructions and the traffic, and tests the application based on the first test script and the second test script.
[0043] In other embodiments, the terminal 400 records the traffic of the application, obtains the traffic generated by the application during operation, and sends the traffic to the server 200. The server 200 generates a first test script and a second test script for testing the application based on the operation instructions and the traffic, and performs test operation instructions on the application based on the first test script and the second test script.
[0044] In other embodiments, the embodiments of the present application can be implemented with the aid of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or a local area network to achieve data computing, storage, processing, and sharing.
[0045] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources.
[0046] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device 500 for generating a test script provided in an embodiment of the present application, wherein: Figure 2 The electronic device 500 shown may be Figure 1 The server 200 or the terminal 400 in Figure 2 The electronic device 500 shown includes: at least one processor 430, a memory 450, and at least one network interface 420. The various components in the electronic device 500 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 2 Various buses are labeled as bus system 440 .
[0047] The processor 430 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0048] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 430.
[0049] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0050] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0051] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0052] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include: Bluetooth, Wireless Fidelity (WiFi), and Universal Serial Bus (USB).
[0053] In some embodiments, the application program testing device provided in the embodiments of the present application may be implemented in a software manner. Figure 2 The test device 455 of the application program stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a traffic recording module 4551, a detection module 4552, and a test module 4553. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.
[0054] In other embodiments, the testing device for the application provided in the embodiments of the present application can be implemented in hardware. As an example, the testing device for the application provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the testing method for the application provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), or other electronic components.
[0055] In some embodiments, the terminal or server can implement the test method of the application provided in the embodiment of the present application by running a computer program or a computer executable instruction. For example, the computer program can be a native program (e.g., a dedicated script generator) or a software module in the operating system, for example, a test module that can be embedded in any program (such as an instant messaging client, an album program, an electronic map client, a navigation client); for example, it can be a local (Native) application (APP, Application), that is, a program that needs to be installed in the operating system to run. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0056] The testing method of the application provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the server or terminal provided in the embodiment of the present application.
[0057] See also Figure 3 , Figure 3 This is a flow chart of the application testing method provided in the embodiment of the present application. Figure 1 , will combine Figure 3 Steps 101 to 105 are shown for illustration. The application testing method provided in the embodiment of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. The following description will be given using the server alone as an example.
[0058] In step 101, traffic of an application is recorded to obtain traffic generated during the operation of the application.
[0059] In some embodiments, traffic recording is a technical means of monitoring and capturing network data traffic, which involves real-time or offline monitoring and recording of network communication traffic. In the context of applications, traffic recording generally refers to capturing network packets generated by applications during operation, including requests and responses. Traffic recording has a variety of purposes, including: Performance analysis: By recording the network traffic generated by applications, performance indicators such as network latency and data transmission speed can be analyzed to optimize the performance of applications. Debugging and troubleshooting When an application has network problems, traffic recording can help developers check network requests and responses to find out where the problem lies. Security auditing: Traffic recording can be used to detect and prevent network attacks and analyze whether applications leak sensitive information. Compliance checking: Some industries need to comply with specific data protection and privacy regulations, and traffic recording can help companies ensure that the network communications of applications comply with these regulatory requirements. User behavior analysis: By analyzing the network traffic generated when users interact with applications, users' usage habits can be understood, providing a basis for product improvement and marketing. Traffic recording is usually implemented using specialized tools and software that can capture network traffic in real time or capture packets as network traffic passes through. The recorded data can be used for subsequent analysis and learning to improve the quality and service level of applications.
[0060] In some embodiments, the traffic generated by the application during operation refers to the traffic generated by the application during operation, which refers to the amount of data transmission generated during the data exchange between the application and the external system (such as a server, database, other applications or Internet services) when performing its functions. This traffic can be divided into the following types: Request traffic: a request sent by the application to the external system in order to obtain information or perform an operation. For example, a mobile application requests user data on the server, or a web application sends a query request to the back-end database. Response traffic: data returned by the external system in response to the received request. Such as user information returned by the server to the mobile application, or query results returned by the database to the web application. Upload traffic: data transmission from the application to the external system, such as users uploading files, photos or videos through the application. Download traffic: data transmission from the external system to the application, such as the application downloading updates or content from the server. Real-time traffic: data exchanged in real time between the application and the external system, which is very common in real-time communication applications (such as instant messaging, video conferencing). The following are several specific situations that generate these traffic: API calls: applications communicate with servers or other services through APIs (application programming interfaces) to obtain or send data. Data synchronization: An application may need to synchronize data with a remote database to ensure that locally stored data is up to date. Content distribution: For example, a streaming service sends video or audio content to a user's player. Status updates: For example, a social media application may constantly get new messages or updates from a server. The traffic generated by an application typically includes the following information: Data size: The amount of data transferred, usually in bytes. Data type: The type of data transferred, such as text, pictures, videos, etc. Traffic direction: Whether the data is uploaded or downloaded. Traffic source / destination: The source address and destination address of the data. Timestamp: The time when the data transfer occurs. The traffic generated by an application is an important indicator for evaluating its performance, efficiency, and security. By monitoring the traffic, developers and testers can identify potential performance bottlenecks, security issues, or unnecessary network activities.
[0061] In some embodiments, see Figure 4 , Figure 4 This is a flow chart of the application testing method provided in the embodiment of the present application. Figure 2 , Figure 3 The step 101 shown may be performed by Figure 4 Steps 1011 to 1012 are implemented as shown.
[0062] In step 1011, during the running of the application, in response to a start recording instruction for the application, traffic of the application is recorded.
[0063] In some embodiments, the start recording instruction for the application may be triggered by the tester on the background management platform. During the process of traffic recording, the running application may or may not generate traffic. During the process of traffic recording, in response to the stop recording instruction for the application, and the application generates traffic during the process of traffic recording, the recorded traffic is determined as the traffic generated by the application during its operation, that is, the traffic generated by the application between the response time point of the start recording instruction and the response time point of the stop recording instruction.
[0064] In step 1012, in response to a stop recording instruction for the application, and the application generates traffic during the process of recording the traffic, the recorded traffic is determined as the traffic generated by the application during operation.
[0065] In some embodiments, first, the response to the start recording instruction: When the application receives the instruction to start recording, it needs to initialize the recording mechanism internally, which may include allocating the necessary memory to store traffic data, setting up a packet capturer, or calling the corresponding API to start monitoring traffic. The application also needs to ensure that it has permission to perform network monitoring, which may require user consent or operating system-level permissions. Traffic recording process: During the recording process, the application will continue to monitor network activities. It can capture outbound and inbound packets and record relevant information such as packet size, sending and receiving time, protocol type, etc. In order not to affect the normal operation of the application and network performance, the recording process is usually performed in the most efficient way possible. Response to the stop recording instruction: When receiving the stop recording instruction, the application needs to stop the previous recording activity. This may involve calling an API to close the packet capturer, release the allocated memory resources, and save the recording data. Determination of recorded traffic: After stopping the recording, the application will analyze the previously captured data to determine the traffic generated by the application during operation. This may include calculating the total amount of data, data transmission rate, and traffic usage patterns. For some applications, traffic data may need to be further processed, such as excluding non-business logic related traffic (such as system updates, etc.) to more accurately reflect the actual usage of the application. Result output: Finally, the application may output the analysis results to the user, such as displaying traffic usage on an interface, or exporting the data to a format that can be further analyzed. Throughout the process, the application needs to ensure that its behavior complies with relevant laws and regulations and user privacy protection requirements.
[0066] In this way, by responding to the start recording command, the application can monitor and record network traffic data in real time, provide users with real-time data analysis and feedback, and accurately obtain the network usage of the application. By analyzing the recorded traffic data, the application can calculate the total traffic consumption of the application during operation, thereby effectively improving the accuracy of the determined traffic.
[0067] In some embodiments, in response to the start recording instruction, prompt information is sent to the application so that the application outputs the prompt information.
[0068] In some embodiments, the prompt information is used to prompt to perform an interactive operation on the application so that the application generates the traffic.
[0069] In some embodiments, since an application may generate traffic when performing interactive operations, a prompt message may be sent to the application in response to the start recording instruction so that the application outputs the prompt message, prompting the application to perform interactive operations on the application so that the application generates the traffic.
[0070] In some embodiments, the application receives a user's instruction to start recording, which is usually done through a user interface (UI) or a command line interface (CLI). In order to notify the application to start recording traffic, a prompt message is sent to itself from within the application. This prompt message is an instruction that tells the application to start capturing network traffic data. After receiving the prompt message, the application will start the internal data capture mechanism, which may involve initializing the network detection module, setting up a packet sniffer, etc. The application will output the prompt message to the user so that the user knows that the traffic recording has been started. This can be achieved by displaying information in the user interface, playing a sound prompt, or through a log file. The purpose of the prompt message is to notify the user that he can start interacting with the application, such as using the application to send or receive data packets, so that the application can start recording the generated network traffic. During the user's interaction with the application, the application will generate network traffic, which will be captured and recorded by the application's monitoring mechanism for subsequent analysis.
[0071] In this way, the prompt information guides the user to perform necessary interactive operations to ensure that the application can generate the expected traffic. This helps users better cooperate with the application to complete the traffic recording task. The application outputs prompt information to let users know when to start interacting, which can ensure that the recorded traffic data is accurate and complete, reflecting the network activities when the user actually uses the application. Through the prompt information, users can feel the humanized design of the application, which improves the user experience and makes the traffic recording process more friendly and easy to operate. Allowing users to control the start and end of traffic recording improves the flexibility of traffic recording. Users can record as needed without worrying about unnecessary data being captured. The output of prompt information provides preparation for subsequent data analysis. Users can parse and understand the recorded traffic data based on the prompt information, so as to make more accurate decisions.
[0072] In some embodiments, in response to the stop recording instruction, and the application does not generate traffic during the process of performing the traffic recording, traffic recording failure information is output.
[0073] In some embodiments, the traffic recording failure information is used to prompt the application to re-record the traffic.
[0074] In some embodiments, in response to a stop recording instruction, the traffic recording for the application is stopped, and the application may not generate traffic between the response time point of the start recording instruction and the response time point of the stop recording instruction. Since the operation instructions executed by the application during the traffic recording process are triggered by the generated traffic, when the application does not generate traffic between the response time point of the start recording instruction and the response time point of the stop recording instruction, the application will not execute operation instructions during the traffic recording process, and the corresponding test script cannot be generated for this recording. Therefore, it is necessary to re-record the traffic of the application, and a traffic recording failure message can be output to prompt the application to re-record the traffic.
[0075] In this way, when the stop recording command is issued and the application does not generate any traffic, timely output of traffic recording failure information can help users quickly understand that there is a problem with the recording process and avoid users waiting for a long time without results. Outputting traffic recording failure information can let users know why the recording failed, whether it is because the application is not running, network problems or other reasons. This helps users diagnose the problem and take appropriate solutions. If the application stops recording without generating traffic, outputting failure information can prevent users from mistakenly believing that traffic data has been obtained, thereby avoiding making decisions based on wrong data. By prompting to re-record, it can be ensured that users can restart traffic recording after the problem is resolved, thereby achieving application test stability.
[0076] In step 102, a first test script is generated based on the traffic.
[0077] In some embodiments, the above step 102 can be implemented in the following manner: obtaining the interactive operations performed on the application during the traffic recording process, and generating a first test script based on the interactive operations and the traffic.
[0078] In some embodiments, the interactive operation performed on the application during the traffic recording process is used to trigger the application to generate traffic. The interactive operation is the reason why the application generates traffic. The above-mentioned first test script is used to test the traffic function of the application. In some embodiments, the recorded traffic data is analyzed to identify all network requests of the application (including HTTP requests such as GET and POST). Extract key parameters from each request, such as the requested URL, request method, request header, request body, response data, etc. Organize the requests into sequences according to the order of user operations to ensure that the test script can be executed in the correct order. Select a suitable scripting language or test framework, such as Python, Java, Shell script or a dedicated test script language. Create a template for the test script, including setting up the environment, introducing necessary libraries, defining variables, etc. Write a script to simulate the user's operation based on the analyzed interactive operations and traffic data. Construct the same request as that during recording in the script, including URL, method, header and body. For each request, check whether the response meets expectations, such as status code, returned data content, etc. Add loops and conditional judgments as needed to handle complex business logic. Execute the script, check for errors or places that do not meet expectations, and debug. Make sure the script covers all necessary operations and paths. Perform performance testing to verify the stability and efficiency of the script under high traffic. Replace hard-coded values with parameters to use different inputs in different test scenarios. Add exception handling mechanisms to ensure that the script can handle errors correctly instead of breaking directly. Add logging functions to facilitate tracking and debugging of problems that occur during script execution.
[0079] In step 103, the operation instructions executed by the application on the data source during the traffic recording process are detected.
[0080] In some embodiments, the operation instructions generally refer to a series of processing and conversion activities on data, which are intended to extract useful information from the data, convert the data format, or calculate and analyze the data. The operation instructions can be interpreted as the specific operations performed by the application during the traffic recording process, and these operation instructions may include: Data capture: The application captures network traffic data packets, including the content of the data packet, the data source and destination address, the port number, the transmission time and other information. Data parsing: The application analyzes the captured data packets and parses out useful information, such as the requested URL, the size of the transmitted data, HTTP header information, etc. Data filtering: The application may filter out non-business-related data, such as system updates, diagnostic data, etc., and only focus on traffic directly related to the application function. Data recording: The application records the parsed and filtered data, usually stored in a file, database or memory for subsequent analysis or reporting. Data conversion: The application may need to convert the captured data from one format to another format to adapt to different analysis tools or report formats.
[0081] In some embodiments, the above step 103 can be implemented in the following manner: during the operation of the application, in response to a start recording instruction for the application, an operation instruction for the application is recorded; in response to a stop recording instruction for the application, and during the process of recording the operation instruction, the application executes an operation instruction on the data source, and the recorded operation instruction is determined as the operation instruction executed by the operation instruction application on the data source during the traffic recording process.
[0082] In some embodiments, operation instruction recording is a technical means to capture the details of the operation of the application on the data source during the running process of the application. This recording is usually to record the data access of the application for subsequent analysis, debugging or performance optimization. Operation instruction recording involves the following steps: Start recording: When the application receives the instruction to start recording, the operation instruction recording tool starts working and prepares to record all operation instructions of the application on the data source (such as database, file system, API, etc.). Operation instruction capture: During the recording process, the tool will capture all read and write operations of the application on the data source, including SQL queries, file access, API calls, etc. These operations may include database operations such as insert, update, delete, query, etc. Stop recording: When the instruction to stop recording is received, the recording tool stops capturing operation instructions and saves the operation instruction records obtained by recording. Analyze recorded data: The recorded data is saved in a file or database and can be analyzed later. This data can be used to reproduce the execution path of the application, analyze performance problems, or be used for testing and verification. Operation instruction determination: During the traffic recording process, if the application executes operation instructions on the data source, these operations will be recorded and can be used to determine the operation instructions actually executed by the application during the recording. Operational recording is very important for understanding how your application interacts with data sources, especially when you need to diagnose performance issues, debug errors, or do integration testing.
[0083] In some embodiments, during the operation of the application, in response to a start recording instruction for the application, operation instruction recording and traffic recording can be performed on the application at the same time; in response to a stop recording instruction for the application, and during the process of recording the operation instructions, the application executes operation instructions on the data source, the recorded operation instructions are determined as the operation instructions executed by the operation instruction application on the data source during the process of recording the traffic.
[0084] In some embodiments, the traffic generated by the application during operation may trigger the application to execute operation instructions on the data source, or may not trigger the application to execute operation instructions on the data source. The application's execution of operation instructions on the data source requires the application to generate traffic during operation.
[0085] In this way, by responding to the start and stop recording instructions, the application can automatically record the operation instructions, thereby improving the recording efficiency. The application can record the operation instructions, which can provide users with detailed traffic usage and specific operation instructions executed by the application during operation. Since the traffic generated by the application during operation may trigger the application to execute the operation instructions for the data source, or may not trigger the application to execute the operation instructions for the data source, by responding to the start recording instruction for the application, the operation instruction recording and traffic recording are performed synchronously. When the application generates traffic during operation and the application executes the operation instructions for the data source during the recording of the operation instructions, the traffic and operation instructions used to generate the test script are obtained, thereby effectively ensuring the comprehensiveness of the test script.
[0086] In some embodiments, in response to a stop recording instruction for the application, and the application does not execute an operation instruction for a data source during the recording of the operation instruction, the first test script tests the application based on the first test script.
[0087] In some embodiments, the reason why the application does not execute the operation instruction on the data source during the process of recording the operation instruction may be that the application does not generate traffic during the process of recording the operation instruction, or that the application generates traffic during the process of recording the operation instruction, but the generated traffic does not trigger the application to execute the operation instruction.
[0088] In some embodiments, the traffic generated by the application during its operation may or may not trigger the application to execute operation instructions on the data source, and the application's execution of operation instructions on the data source requires the application to generate traffic during its operation, in response to a stop recording instruction for the application, and the application did not execute operation instructions on the data source during the recording of the operation instructions, and the application generated traffic during the recording of the operation instructions, a first test script is generated based on the traffic.
[0089] In this way, by recording the operation instructions executed by the application, the specific operation instructions executed by the application on the data source during operation can be traced and analyzed, which helps to gain a deeper understanding of the behavior of the application. When the application executes the operation instructions, these operation instructions can be captured and recorded, ensuring the integrity of the operation instruction recording, and the results of data analysis will not be affected by the omission of operation instructions. The recording of operation instructions can provide a basis for the performance optimization of the application. By analyzing the type and frequency of operation instructions, developers can perform targeted performance tuning.
[0090] In step 104, a second test script is generated based on the operation instruction.
[0091] In some embodiments, the above step 104 may be implemented in the following manner: generating a second test script based on the interactive operation and the operation instruction.
[0092] In some embodiments, the interactive operations performed on the application during the traffic recording process are used to trigger the application to generate traffic, and the interactive operations are the reason why the application generates traffic.
[0093] In some embodiments, understand the business logic and data flow of the application, including the data addition, deletion, modification and query (CRUD) operations, and clarify the test objectives of the test script, such as testing the correctness, performance, security and exception handling capabilities of specific operation instructions. Generate test data according to test requirements, which should cover various scenarios that the application may encounter. Use automated testing tools (such as Selenium, Appium, etc.) to record user operations. If the recording tool does not support or requires more fine-grained control, manually define the operation steps, including clicks, input, selections, submissions, etc. Select a suitable automated testing framework, such as JUnit, TestNG, pytest, etc. According to the defined operation steps, write scripts to simulate user operation instructions. Set the preconditions for the test, such as logging in to an account, setting browser configuration, etc. Write code to simulate user input and click operations. Check whether the results of the operation instructions are consistent with expectations, including the data status in the database, the display information on the page, etc. Parameterize the test data so that different test data can be read from external files or databases. Use data-driven testing to allow test scripts to run on different test data sets. Ensure that the test script can handle various abnormal situations, such as network interruptions, data conflicts, etc. Test the boundary conditions of the test data to ensure that the application can handle boundary conditions correctly. Break down the scripts into reusable modules so that they can be reused in different test scenarios. Add detailed logging to track the test execution process and debug problems. Optimize the execution efficiency of the script to reduce unnecessary waiting and delays. Execute the script in the test environment to test the operation instruction functions of the application. Analyze the test results to ensure that all test cases pass and the test results are as expected. Update the test scripts regularly to adapt to changes in the application. Integrate the test scripts into the CI / CD process to ensure continuous verification of the operation instruction functions.
[0094] In step 105, the application is tested based on the first test script and the second test script.
[0095] In some embodiments, a test script is a document or code that contains a series of specific test instructions, which are intended to be executed by automated testing tools. The main purpose of a test script is to verify whether the functions, performance and other characteristics of the software meet the expected requirements. Test scripts are usually written by testers to ensure that the software can run normally under various conditions. The importance of the maintainability and reusability of test scripts lies in that they can reduce redundant work in the testing process and improve testing efficiency. When writing test scripts, it should be noted that operations that may appear in multiple testing processes are abstracted as targets so that these operations can be reused in different testing scenarios. Test scripts can be created manually, automatically generated by test automation tools, or programmed using programming languages. In practical applications, test scripts are often combined with these methods to improve the efficiency and quality of testing.
[0096] In some embodiments, the first test script and the second test script are used to test the traffic function of the application, and the second test script is used to test the operation function of the application.
[0097] In some embodiments, the above step 105 can be implemented as follows: in response to a first test instruction for the application, based on the first test script and the second test script, the application is tested to obtain a first test result of the application; if the first test result indicates that the application has failed the test, the application is repaired to obtain a repaired application.
[0098] In some embodiments, the real-time test instructions of the above application can be triggered by a tester or generated at a preset frequency. By generating real-time test instructions, the test of the application is triggered, thereby ensuring the functional stability of the application.
[0099] In some embodiments, the first test result of the application is used to indicate whether the application has passed the real-time test. When the first test result of the application indicates that the application has passed the real-time test, it means that there are no functional problems with the application during the real-time test, and the application can continue to run.
[0100] In some embodiments, when the first test result of the application indicates that the application has failed the real-time test, then there is a functional problem with the application when performing the real-time test. At this time, the application can be repaired to obtain an updated application that can pass the real-time test. The application can be replaced by the updated application to continue running, thereby ensuring the functional stability of the application.
[0101] In some embodiments, the test script includes a first test script and a second test script. The above-mentioned real-time testing of the application based on the first test script and the second test script to obtain the first test result of the application can be achieved in the following ways: based on the first test script, a traffic test is performed on the application to obtain a second test result; based on the second test script, an operation test is performed on the application to obtain a third test result; based on the second test result and the third test result, the first test result of the application is determined.
[0102] In this way, by responding to real-time test instructions, the application can be tested immediately instead of waiting for the scheduled test time, which can find and solve problems more quickly and improve testing efficiency. If the first test result shows that the application fails the test, the developer can immediately fix the application, which helps to shorten the repair cycle and speed up product release. Real-time testing reduces the need for manual testing, thereby reducing testing costs, especially for large-scale applications, which can save a lot of manpower and time resources. Frequent real-time testing can help developers find and solve quality problems in a timely manner, improve the quality of the final product, and reduce the introduction of defects. Through real-time testing based on test scripts, the test process can be automated and standardized, reducing human errors and improving test consistency.
[0103] In some embodiments, the first test script includes the traffic obtained by the application performing the traffic recording, and the interactive operations performed on the application during the process of performing the traffic recording.
[0104] In some embodiments, the above-mentioned flow test on the application based on the first test script to obtain the second test result can be achieved in the following manner: based on the interactive operation, running the application, and recording the test flow generated by the application in response to the interactive operation; if the test flow and the flow are the same, then the second test result that the application passes the flow test is obtained; if the flow comparison result indicates that the test flow and the flow are different, then the second test result that the application fails the flow test is obtained.
[0105] In some embodiments, the traffic comparison result is used to indicate whether the test traffic and the traffic are the same, the test traffic is generated by the application during the traffic test, the traffic is generated by the application during the traffic recording, and the traffic and the test traffic are generated by the application for the same interactive operation in different time periods.
[0106] In some embodiments, the traffic is generated by the application during the process of traffic recording. The above traffic can be the standard traffic generated by the application for interactive operations. When the traffic comparison result indicates that the test traffic and the traffic are the same, it means that the test traffic is the standard traffic. Then, the test result can be determined as the application passing the traffic test.
[0107] In some real-time streams, the above-mentioned traffic is generated by the application during the process of traffic recording. Regardless of whether the traffic is the standard traffic generated by the application, when the traffic comparison result indicates that the test traffic and the traffic are the same, it means that with the passage of time, the traffic generated by the application for interactive operations has not changed, then the function of the application for traffic has not changed, then the test result can be determined as the application has passed the traffic test.
[0108] As an example, the traffic of the application is recorded in time period A, and the traffic of the application is tested in time period B. The application generates traffic in time period A and generates test traffic in time period B. Since the traffic and test traffic are generated by the application in different time periods for the same interactive operation, by comparing whether the traffic and test traffic are the same, if the test traffic and traffic are the same, it means that the traffic generated by the application in different time periods is the same. Therefore, it means that the function of the application has not changed over time, and the second test result can be determined as the application has passed the traffic test. If the test traffic and traffic are not the same, it means that the traffic generated by the application in different time periods is not the same. Therefore, it means that the function of the application has changed over time, and the second test result can be determined as the application has not passed the traffic test.
[0109] In this way, by recording the test traffic generated by the application in response to interactive operations, automated testing can be achieved, reducing the need for manual testing and improving testing efficiency. By comparing the test traffic with the normal traffic, it is possible to verify whether the traffic behavior of the application under a specific interactive operation is consistent with the normal traffic, ensuring that the application performs stably under various circumstances. Through traffic comparison, an accurate second test result can be obtained to determine whether the application has passed the traffic test, reducing the error of human judgment. The results of the traffic test can be used as one of the standards for application performance and functional testing, which helps to establish and maintain the standardization of the test process. If the traffic comparison results show that the test traffic is different from the normal traffic, developers can quickly identify the problems with the application and make targeted repairs. Traffic testing helps ensure that the behavior of the application during user use is as expected, ensuring the consistency and stability of the user experience.
[0110] In some embodiments, the second test script includes operation instructions executed by the application during the traffic recording process, and interactive operations performed on the application during the traffic recording process.
[0111] In some embodiments, the above-mentioned operation test of the application based on the second test script to obtain the third test result can be achieved in the following manner: based on the interactive operation, running the application, and recording the test operation instructions executed by the application in response to the interactive operation; if the operation instruction and the test operation instruction are the same, then the third test result indicating that the application passes the operation test is obtained; if the operation comparison result indicates that the operation instruction and the test operation instruction are different, then the third test result indicating that the application fails the operation test is obtained.
[0112] In some embodiments, the operation comparison result is used to indicate whether the operation instruction and the test operation instruction are the same. The test operation instruction is generated by the application during the operation test. The operation instruction is generated by the application during the operation instruction recording. The operation instruction and the test operation instruction are generated by the application for the same interactive operation in different time periods.
[0113] In some embodiments, the operation instruction is generated by the application during the process of recording the operation instruction. The above operation instruction can be a standard operation instruction generated by the application for interactive operations. When the operation instruction comparison result indicates that the test operation instruction and the operation instruction are the same, it means that the test operation instruction is the standard operation instruction, and the test result can be determined as the application passing the operation instruction test.
[0114] In some real-time streams, the above-mentioned operation instructions are generated by the application during the process of recording the operation instructions. Regardless of whether the operation instructions are standard operation instructions generated by the application, when the operation instruction comparison result indicates that the test operation instructions and the operation instructions are the same, it means that with the passage of time, the operation instructions generated by the application for the interactive operation have not changed, then the function of the application for the operation instructions has not changed, then the test result can be determined as the application passes the operation instruction test.
[0115] As an example, the operation instructions of the application are recorded in time period A, and the operation instructions of the application are tested in time period B. The application generates operation instructions in time period A and generates test operation instructions in time period B. Since the operation instructions and the test operation instructions are generated by the application for the same interactive operation in different time periods, by comparing whether the test operation instructions and the operation instructions are the same, if the test operation instructions and the operation instructions are the same, it means that the operation instructions generated by the application in different time periods are the same. Therefore, it means that the function of the application has not changed over time, and the third test result can be determined as the application has passed the operation test. If the test operation instructions and the operation instructions are not the same, it means that the operation instructions generated by the application in different time periods are not the same. Therefore, it means that the function of the application has changed over time, and the third test result can be determined as the application has not passed the operation test.
[0116] In this way, through the automated testing process based on interactive operations, it is possible to ensure that the application testing process is efficient and repeatable, reducing the workload of manual testing. By recording the test operation instructions executed by the application in response to the interactive operation and comparing them, accurate third-party test results can be obtained, reducing the error of human judgment. By comparing the actual operation instructions with the test operation instructions, it is possible to verify whether the behavior of the application under a specific interactive operation is consistent with expectations, ensuring the stability and reliability of the application. If the operation comparison results show that the actual operation instructions are different from the test operation instructions, developers can quickly locate and fix the problem, shortening the time to solve the problem. By ensuring that the application performs consistently under various interactive operations, the user experience can be improved and user dissatisfaction caused by abnormal application behavior can be reduced. Regular operation testing can help developers discover and fix potential problems in the application and improve the overall quality of the application.
[0117] In some embodiments, determining the first test result of the application based on the second test result and the third test result can be achieved in the following manner: if the second test result indicates that the application passes the flow test, and the third test result indicates that the application passes the operation test, then a first test result is obtained indicating that the application passes the test; if the second test result indicates that the application fails the flow test, or the third test result indicates that the application fails the operation test, then a first test result is obtained indicating that the application fails the test.
[0118] In some embodiments, if the second test result indicates that the application passes the traffic test, and the third test result indicates that the application passes the operation test, the first test result is determined as the application passes the real-time test, that is, when the application passes both the operation test and the traffic test, the first test result is determined as the application passes the real-time test.
[0119] In some embodiments, if the second test result indicates that the application has not passed the traffic test, and the third test result indicates that the application has passed the operation test, the first test result is determined as the application has not passed the real-time test.
[0120] In some embodiments, if the second test result indicates that the application has passed the traffic test and the third test result indicates that the application has not passed the operation test, the first test result is determined as the application has not passed the real-time test.
[0121] In some embodiments, if the second test result indicates that the application has not passed the traffic test, and the third test result indicates that the application has not passed the operation test, the first test result is determined as the application has not passed the real-time test.
[0122] In this way, by recording the traffic of the application, the traffic generated by the application during operation is obtained, and based on the traffic, a first test script is generated, and the operation instructions executed by the application on the data source during the traffic recording process are detected, and based on the operation instructions, a second test script is generated; based on the first test script and the second test script, the application is tested. In this way, by generating the first test script and the second test script based on the recorded traffic and operation instructions, the operation functions of the traffic and operation instructions of the application can be fully tested, so that the first test script and the second test script can test the application in two dimensions of traffic and operation instructions, and at the same time, the application is tested by recording, thereby effectively reducing human intervention, so that the application is tested in two dimensions of traffic and operation instructions, thereby effectively improving the accuracy of the application test.
[0123] The following is an explanation of an exemplary application of the present invention in an actual application testing scenario.
[0124] Application testing refers to a series of checks and evaluations of software applications, with the purpose of verifying and confirming whether the application's functions, performance, security and user experience meet expectations and requirements. Application testing can include unit testing, integration testing, system testing, performance testing, security testing, compatibility testing, user acceptance testing and other types. During the application testing process, testers will design and execute test cases based on the application's requirements documents, design documents and user manuals, simulate the user's actual usage scenarios, perform various inputs and operations on the application, and check whether the application's response and output meet expectations. In addition, application testing may also include evaluations of the application's interface, functions, operating procedures, data processing and other aspects to ensure that the application can run stably in actual use, meet user needs, and meet predetermined performance and quality standards. Application testing is an important part of the software development process. It can help the development team discover and fix defects and problems in the application, improve the reliability and stability of the application, and thus provide users with better quality and more satisfactory software products.
[0125] A test script is a document or code that contains a series of specific test instructions that are designed to be executed by automated testing tools. The main purpose of a test script is to verify whether the functionality, performance, and other characteristics of the software meet the expected requirements. Test scripts are usually written by testers to ensure that the software can run properly under various conditions. The importance of maintainability and reusability of test scripts lies in that they can reduce redundant work in the testing process and improve testing efficiency. When writing test scripts, attention should be paid to abstracting operations that may appear in multiple testing processes as targets so that these operations can be reused in different test scenarios. Test scripts can be created manually, automatically generated by test automation tools, or programmed using programming languages. In practical applications, test scripts often combine these methods to improve the efficiency and quality of testing.
[0126] The application testing method provided by the embodiment of the present application solves the problem that most scripts generated on the market cannot be directly executed and need to be modified and supplemented. This technology can solve the problem of perfecting the entire process from data preparation, test execution, and post-execution response assertion and data assertion without missing any verification points. The script management visualization function is added, and there is no need to modify the script code. The assertion comparison and filtering configuration can be performed on the page, and the expected result changes of network requests and database expected results can be modified, reducing the cost of script maintenance and management.
[0127] In some embodiments, see Figure 5 , Figure 5It is a schematic diagram of the principle of the test method of the application provided in the embodiment of the present application. For the module management platform, the user first configures the interface recording information: configures the management center through the console management platform page, adds the configuration information of the corresponding environment and application, mainly including interface recording filtering, and the recording plug-in configuration involved. The user configures the sql recording information: the module management adds the database recording information configuration management function, which is mainly used to store the mysql database address port account password information of the corresponding environment, and the database that needs to be specified for recording, and the table data that needs to be excluded from recording. The user adds or modifies the test environment database recording information configuration through the console page. One-click deployment mounts the recording agent to the java application: the user uses the Jenkins one-click deployment tool to download the sandboxrepeater version to the test server, obtain the java application process number that needs to be recorded, and execute the sandbox attach command for dynamic insertion to enhance the code. Modify the database configuration to enable the Binglog function, specify the database that needs to be recorded according to the configuration, restart the database, and ensure that the Binglog log of the corresponding database can be obtained during recording. Start recording and perform functional testing: The sandbox startup process will load the repeater-moudle module. In the secondary development repeater-moudle module, database recording configuration reading and modified http plug-in initialization are added. After loading, the online module page of the module management platform shows the addition of the corresponding environment application mounting information, and the online connection status is turned on. Then the user manually executes the functional test case. Select recording traffic and generate scripts: After the test task executes the test case, the online traffic module of the console management platform displays the recorded data information. View the details to see the recorded interface request message, response results and the difference results before and after the modification, addition and deletion of the MySQL recording table. After the test is completed, the environment is frozen in the online module of the module management platform. After freezing, the recording is no longer monitored. Then batch select the traffic that needs to generate scripts and execute script generation. JVM-Sandbox-Repeater console secondary development automated test script generator. After the user completes the test, click Generate Script and stop recording. The data change events in the network traffic MySQLBinglog recorded by the JVM-Sandbox-Repeater tool will be parsed, and the automated test class will be generated to the automated project. According to the parsing results, the test Java class under the TestNG test framework is generated through the preset Freemarker template. Each method of this class represents a test case. These methods include precondition base data execution, network request, post-request response result assertion and post-request change data assertion.
[0128] In some embodiments, see Figure 5, the sandbox dynamically inserts the relay module into the JVM process of the already running test java project, the relay module pulls the configuration information, initializes the message broadcast service, loads the plug-in, and the plug-in activates the plug-in according to the configuration information to obtain the application's request and sub-calls and results. Network recording message delivery, recording message delivery, Http-Plugin plug-in secondary development before event, intercepting the network traffic of the target JAVA application, backing up the data before the interface execution as the base data storage and then releasing it, and recording the network traffic of the target Java application in real time, including HTTP requests, responses, and any data transmitted over the network. At the same time, in this event, connect to the MYSQL database through BinaryLogClient to monitor the MySQL log, capture all data change events, including adding, modifying, and deleting operations and binding the request traffic to the console storage. Detection is turned on to detect the application's operation instructions for the database, and add a shutdown of the binglog listening thread in the return event to end the listening interception.
[0129] In some embodiments, the tester puts the generated script into the testng automation framework and uses the TestNG framework to execute the generated test script. During the execution process, SQL statements are executed and network interfaces are called. Verify whether the execution results meet expectations. Use the assertion method of the module framework to compare whether the return result of the current execution call is consistent with the expected return value of the recorded storage interface, and whether the database result of the current network execution change is consistent with the database result of the recorded storage. The Console management platform adds an overdue result management module. When there are changes in subsequent codes or assertion checks are inconsistent, or some fields change randomly and cannot be executed, this module can be used to edit the configuration of response field and database field check filters, and view, edit and modify expected results, so that it can iteratively update the script to ensure script stability.
[0130] In some embodiments, see Figure 5, add data backup before execution to complete the bottom data logic, and ensure that the data before each use case is executed is consistent with that during recording. Secondary development of JVM-Sandbox-Repeate, modify the logic of the before event of the http-pulugin plug-in, intercept the HttpServletRequest network traffic of the target JAVA application, and store the mysql database data as the bottom data on ftp before the backup interface is executed, and then release it, and record the network traffic of the target Java application in real time, including HTTP requests, responses, and any data transmitted over the network. At the same time, in this event, enable BinaryLogClient to connect to the MYSQL database to monitor the MySQL log, capture all data change events, including adding, modifying, and deleting operations and binding them to the request traffic, and call the console management platform interface to store data when conditions are met. In the return event, broadcast the recorded network traffic information to the console management platform, and add and close the binglog listening thread to end the listening interception. After recording, online traffic displays the recorded network request information. The details page adds MySQL recording details display. The content will display the database table field values before the change and the field values of the corresponding database change table after the request, which is convenient for testers to check whether the recording is correct. After confirmation, the script is executed to generate and parse the recorded database information into the expected database result, and the response result of the recorded interface is stored as the expected result of the interface. During the execution of the generated script, the stored expected result information will be used for interface response assertion and database assertion, solving the problem of missing database assertions in the generated automated script and incomplete manually written assertions. Add the script management visualization function, which can be used to configure assertion filtering on the page, modify the expected result changes of network requests and the expected results of the database, and reduce the cost of script maintenance and management.
[0131] In this way, by recording the traffic of the application, the traffic generated by the application during operation is obtained, and the operation instructions executed by the application during the traffic recording process are obtained, and based on the traffic and operation instructions, a test script for testing the application is generated. In this way, through the test script generated based on the recorded traffic and operation instructions, the running functions of the traffic and operation instructions of the application can be fully tested, so that the test script can test the application in two dimensions of traffic and operation instructions, and at the same time, the application is tested by recording, thereby effectively reducing human intervention, so that the generated test script is more accurate, thereby effectively improving the test accuracy of the test script.
[0132] It is understandable that in the embodiments of the present application, data related to traffic, etc. is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0133] The following continues to describe an exemplary structure of the application program testing device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2 As shown, the software modules in the test device 455 of the application stored in the memory 450 may include: a traffic recording module, used to record the traffic of the application to obtain the traffic generated by the application during operation; a detection module, used to detect the operation instructions executed by the operation instruction application on the data source during the traffic recording process; a test module, used to generate a test script for testing the application based on the traffic and the operation instructions.
[0134] In some embodiments, the acquisition module is further used to acquire the interactive operations performed on the application during the traffic recording process, and generate the first test script based on the interactive operations and the traffic. The acquisition module is further used to acquire the interactive operations performed on the application during the traffic recording process, and generate the second test script based on the interactive operations and the operation instructions.
[0135] In some embodiments, the above-mentioned test module is used to respond to a first test instruction for the application, test the application based on the first test script and the second test script, and obtain a first test result of the application; if the first test result indicates that the application fails the test, the application is repaired to obtain a repaired application.
[0136] In some embodiments, the above-mentioned test module is also used to perform a traffic test on the application based on the first test script to obtain a second test result; perform an operation test on the application based on the second test script to obtain a third test result; and determine the first test result of the application based on the second test result and the third test result.
[0137] In some embodiments, the above-mentioned test module is also used to run the application based on the interactive operation, and record the test traffic generated by the application in response to the interactive operation; if the test traffic is the same as the traffic, a second test result is obtained that the application passes the traffic test; if the test traffic is different from the traffic, a second test result is obtained that the application fails the traffic test.
[0138] In some embodiments, the above-mentioned test module is also used to run the application based on the interactive operation, and record the test operation instructions executed by the application in response to the interactive operation; if the operation instruction and the test operation instruction are the same, a third test result is obtained that the application passes the operation test; if the operation instruction and the test operation instruction are different, a third test result is obtained that the application fails the operation test.
[0139] In some embodiments, the above-mentioned test module is also used to obtain a first test result that the application passes the test if the second test result indicates that the application passes the flow test and the third test result indicates that the application passes the operation test; if the second test result indicates that the application fails the flow test, or the third test result indicates that the application fails the operation test, then a first test result that the application fails the test is obtained.
[0140] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the test method of the application program described above in the embodiment of the present application.
[0141] The present application embodiment provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the processor will be caused to execute the test method of the application provided by the present application embodiment, for example, Figure 3 Shown is the testing methodology for the application.
[0142] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEP ROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various electronic devices including one or any combination of the above memories.
[0143] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0144] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0145] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0146] In summary, the embodiments of the present application have the following beneficial effects:
[0147] (1) By recording the traffic of the application, the traffic generated by the application during operation is obtained, and the operation instructions executed by the application during the traffic recording process are obtained, and based on the traffic and the operation instructions, a test script for testing the application is generated. In this way, through the test script generated based on the recorded traffic and operation instructions, the running functions of the traffic and operation instructions of the application can be fully tested, so that the test script can test the application in two dimensions of traffic and operation instructions, and at the same time, the application is tested by recording, thereby effectively reducing human intervention, so that the generated test script is more accurate, thereby effectively improving the test accuracy of the test script.
[0148] (2) By responding to the start recording command, the application can monitor and record network traffic data in real time, provide users with real-time data analysis and feedback, and accurately obtain the network usage of the application. By analyzing the recorded traffic data, the application can calculate the total traffic consumption of the application during operation, thereby effectively improving the accuracy of the determined traffic.
[0149] (3) Prompt information guides users to perform necessary interactive operations to ensure that the application can generate the expected traffic. This helps users better cooperate with the application to complete the traffic recording task. The application outputs prompt information to let users know when to start interacting, which ensures that the recorded traffic data is accurate and complete, reflecting the network activities when users actually use the application. Through prompt information, users can feel the humanized design of the application, which improves the user experience and makes the traffic recording process more friendly and easy to operate. Allowing users to control the start and end of traffic recording improves the flexibility of traffic recording. Users can record as needed without worrying about unnecessary data being captured. The output of prompt information provides preparation for subsequent data analysis. Users can parse and understand the recorded traffic data based on the prompt information, thereby making more accurate decisions.
[0150] (5) When the stop recording command is issued and the application does not generate any traffic, timely output of traffic recording failure information can help users quickly understand that there is a problem with the recording process and avoid users waiting for a long time without results. Outputting traffic recording failure information can let users know why the recording failed, whether it is because the application is not running, network problems or other reasons. This helps users diagnose the problem and take appropriate solutions. If the application stops recording without generating traffic, outputting failure information can prevent users from mistakenly believing that traffic data has been obtained, thereby avoiding making decisions based on erroneous data. By prompting to re-record, it can ensure that users can restart traffic recording after the problem is solved, thereby achieving application test stability.
[0151] (6) By responding to the start and stop recording instructions, the application can automatically record the operation instructions, thereby improving the recording efficiency. The application can record the operation instructions, so as to provide users with detailed traffic usage and specific operation instructions executed by the application during operation. Since the traffic generated by the application during operation may trigger the application to execute the operation instructions for the data source, or may not trigger the application to execute the operation instructions for the data source, by responding to the start recording instruction for the application, the operation instruction recording and traffic recording are performed synchronously. When the application generates traffic during operation and the application executes the operation instructions for the data source during the recording of the operation instructions, the traffic and operation instructions used to generate the test script are obtained, thereby effectively ensuring the comprehensiveness of the test script.
[0152] (7) By recording the operation instructions executed by the application, the specific operation instructions executed by the application on the data source during operation can be traced and analyzed, which helps to gain a deeper understanding of the behavior of the application. When the application executes the operation instructions, these operation instructions can be captured and recorded, ensuring the integrity of the operation instruction recording, and the results of data analysis will not be affected by the omission of operation instructions. The recording of operation instructions can provide a basis for optimizing the performance of the application. By analyzing the type and frequency of operation instructions, developers can perform targeted performance tuning.
[0153] (8) By responding to real-time test instructions, the application can be tested immediately instead of waiting for the scheduled test time, which can identify and resolve problems more quickly and improve testing efficiency. If the first test result indicates that the application has failed the test, the developer can immediately fix the application, which helps to shorten the repair cycle and speed up product release. Real-time testing reduces the need for manual testing, thereby reducing testing costs, especially for large-scale applications, which can save a lot of manpower and time resources. Frequent real-time testing can help developers find and resolve quality problems in a timely manner, improve the quality of the final product, and reduce the introduction of defects. Through real-time testing based on test scripts, the test process can be automated and standardized, reducing human errors and improving test consistency.
[0154] (9) By recording the test traffic generated by the application in response to interactive operations, automated testing can be achieved, reducing the need for manual testing and improving testing efficiency. By comparing the test traffic with the normal traffic, it is possible to verify whether the traffic behavior of the application under a specific interactive operation is consistent with the normal traffic, ensuring that the application performs stably under various circumstances. By comparing the traffic, an accurate second test result can be obtained to determine whether the application has passed the traffic test, reducing the error of human judgment. The results of the traffic test can be used as one of the standards for application performance and functional testing, which helps to establish and maintain the standardization of the test process. If the traffic comparison results show that the test traffic is different from the normal traffic, the developer can quickly identify the problems with the application and make targeted repairs. Traffic testing helps ensure that the behavior of the application during user use meets expectations, ensuring the consistency and stability of the user experience.
[0155] (10) Through the automated testing process based on interactive operations, the application testing process can be ensured to be efficient and repeatable, reducing the workload of manual testing. By recording the test operation instructions executed by the application in response to the interactive operation and comparing them, accurate third-party test results can be obtained, reducing the error of human judgment. By comparing the actual operation instructions with the test operation instructions, it can be verified whether the behavior of the application under a specific interactive operation is consistent with expectations, ensuring the stability and reliability of the application. If the operation comparison results show that the actual operation instructions are different from the test operation instructions, the developer can quickly locate and fix the problem, shortening the time to solve the problem. By ensuring that the application performs consistently under various interactive operations, the user experience can be improved and user dissatisfaction caused by abnormal application behavior can be reduced. Regular operation testing can help developers discover and fix potential problems in the application and improve the overall quality of the application.
[0156] (11) By recording the traffic of the application, the traffic generated by the application during operation is obtained, and the operation instructions executed by the application during the traffic recording process are obtained, and based on the traffic and the operation instructions, a test script for testing the application is generated. In this way, through the test script generated based on the recorded traffic and operation instructions, the running functions of the traffic and operation instructions of the application can be fully tested, so that the test script can test the application in two dimensions of traffic and operation instructions, and at the same time, the application is tested by recording, thereby effectively reducing human intervention, so that the generated test script is more accurate, thereby effectively improving the test accuracy of the test script.
[0157] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for testing an application, characterized in that: The method comprises: Recording the traffic of the application to obtain the traffic generated by the application during operation, and generating a first test script based on the traffic; Detecting an operation instruction executed by the application on the data source during the traffic recording process, and generating a second test script based on the operation instruction; The application is tested based on the first test script and the second test script.
2. The method according to claim 1, characterized in that The generating a first test script based on the traffic includes: Acquire the interactive operation performed on the application during the traffic recording process, and generate the first test script based on the interactive operation and the traffic; The generating a second test script based on the operation instruction comprises: The interactive operations performed on the application during the traffic recording process are obtained, and the second test script is generated based on the interactive operations and the operation instructions.
3. The method according to claim 1, characterized in that The testing of the application based on the first test script and the second test script includes: In response to a first test instruction for the application, the application is tested based on the first test script and the second test script to obtain a first test result of the application; If the first test result indicates that the application program has failed the test, the application program is repaired to obtain a repaired application program.
4. The method according to claim 3, characterized in that The step of testing the application based on the first test script and the second test script to obtain a first test result of the application includes: Based on the first test script, a flow test is performed on the application to obtain a second test result; Based on the second test script, perform an operation test on the application to obtain a third test result; Based on the second test result and the third test result, a first test result of the application is determined.
5. The method according to claim 4, characterized in that The step of performing a flow test on the application based on the first test script to obtain a second test result includes: Based on the interactive operation, running the application, and recording the test traffic generated by the application in response to the interactive operation; If the test flow rate is the same as the flow rate, a second test result is obtained that the application program passes the flow test; If the test flow is different from the flow, a second test result is obtained, indicating that the application fails the flow test.
6. The method according to claim 4, characterized in that The step of performing an operation test on the application based on the second test script to obtain a third test result includes: Based on the interactive operation, running the application, and recording the test operation instructions executed by the application in response to the interactive operation; If the operation instruction is the same as the test operation instruction, obtaining a third test result that the application program passes the operation test; If the operation instruction and the test operation instruction are different, a third test result is obtained that the application fails the operation test.
7. The method according to claim 4, characterized in that The determining, based on the second test result and the third test result, a first test result of the application program, comprises: If the second test result indicates that the application has passed the flow test, and the third test result indicates that the application has passed the operation test, then a first test result indicating that the application has passed the test is obtained; If the second test result indicates that the application fails the traffic test, or the third test result indicates that the application fails the operation test, then a first test result is obtained indicating that the application fails the test.
8. A testing device for an application, characterized in that: The device comprises: A traffic recording module, used to record traffic of an application program, obtain traffic generated by the application program during operation, and generate a first test script based on the traffic; A detection module, used to detect the operation instructions executed by the application on the data source during the traffic recording process, and generate a second test script based on the operation instructions; A testing module is used to test the application based on the first test script and the second test script.
9. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions or computer programs; A processor, configured to implement the method for testing the application program according to any one of claims 1 to 7 when executing the computer executable instructions or computer program stored in the memory.
10. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed by a processor, the test method of the application program according to any one of claims 1 to 7 is implemented.
11. A computer program product comprising a computer program or computer executable instructions, characterized in that: When the computer program or computer executable instructions are executed by a processor, the test method of the application program according to any one of claims 1 to 7 is implemented.
