Webpage application test method and device, computer equipment, readable storage medium and program product
By executing test cases in parallel in multiple preset testing environments, the problem of inefficient testing efficiency in web applications in the prior art is solved, and a more efficient testing process is achieved.
Patent Information
- Application Number
- CN202411747970.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-21
AI Technical Summary
Existing web application testing methods are tested in a fixed environment, resulting in inefficient testing.
By obtaining the test data of the web application to be tested, calling the functional objects in the core function library, generating test cases based on operations, logs, and network function objects, and executing these test cases in parallel in multiple preset test environment configurations.
Improves the efficiency of web application testing, enables the execution of test cases in multiple test environments simultaneously, and shortens the test time.
Smart Images

Figure CN119669074A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a web application testing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of Internet technology, web applications have been integrated into people's daily lives. In order to improve the quality of web applications, it is necessary to improve the quality of the testing process of web applications. Currently, web application testing is usually performed in a fixed environment. However, web applications are diverse, and testing web applications in a fixed environment will reduce the testing efficiency of web applications.
[0003] Therefore, the current web application testing method has the defect of low testing efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a web application testing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve testing efficiency in response to the above technical problems.
[0005] In a first aspect, the present application provides a web application testing method, the method comprising:
[0006] Acquire test data corresponding to the web application to be tested, and call each function object in the core function library; each function object includes one or more of an operation function object, a log function object, and a network function object;
[0007] Generate each test case according to the test data and each of the functional objects; the test case includes each test item determined based on one or more of the operation functional object, the log functional object and the network functional object;
[0008] Determine, from each of the test cases, each target test case corresponding to each preset test environment configuration, and each execution strategy corresponding to each of the target test cases;
[0009] According to each of the execution strategies, corresponding target test cases are executed in each of the web applications configured in each of the preset test environments to obtain corresponding test results.
[0010] In one embodiment, generating each test case according to the test data and each functional object includes:
[0011] Determine operation data for the webpage application according to the test data, and generate an operation test item according to the operation function object in the function object and the operation data;
[0012] Determine network test data for the webpage application according to the test data, and generate network test items according to the network function object in the function object and the network test data;
[0013] Determine the level of the operation data or the network test item according to the matching results of the operation data and the network test item with the preset log level table respectively; the level includes a first level and a second level;
[0014] Determine a log record test item for the web application according to the log function object and the level; the log record test item includes a screenshot log test corresponding to the first level and a text log test corresponding to the second level;
[0015] The test cases are generated according to the operation test items, the network test items and the log record test items.
[0016] In one embodiment, the step of determining, from the test cases, target test cases corresponding to the preset test environment configurations and execution strategies corresponding to the target test cases includes:
[0017] For each of the preset test environment configurations, determine the test case directory, the number of test cases, and the test order according to the preset test environment configuration;
[0018] Determine, among each of the test cases in the test case catalog, each of the target test cases corresponding to the number of test cases;
[0019] An execution strategy corresponding to the preset test environment configuration is determined according to the test sequence.
[0020] In one of the embodiments, the preset test environment configuration includes a first preset hook file and a second preset hook file;
[0021] According to each of the execution strategies, executing corresponding target test cases in each of the web applications configured in each of the preset test environments to obtain corresponding test results includes:
[0022] For each web application configured in the preset test environment, executing the first preset hook file to obtain a first test result and a first web application;
[0023] According to the test sequence corresponding to the preset test environment configuration of the web application, executing each of the target test cases corresponding to the preset test environment configuration in the first web application to obtain a second test result and a second web application;
[0024] The second preset hook file is executed in the second web application to obtain a test result corresponding to the web application.
[0025] In one embodiment, the executing of the corresponding target test cases in the web applications configured in the preset test environments according to the execution strategies, and obtaining the corresponding test results, further comprises:
[0026] According to the test results, determine the execution order, execution success rate, text logs and screenshot logs corresponding to each of the target test cases;
[0027] A test report corresponding to the web application is displayed according to the execution order, the execution success rate, the text log and the screenshot log.
[0028] In one embodiment, displaying a test report corresponding to the web application according to the execution order, the execution success rate, the text log, and the screenshot log includes:
[0029] According to the execution orders and execution success rates corresponding to the target test cases, the identifiers corresponding to the target test cases, the first step execution information and the first execution success rate corresponding to the web application are displayed on the first page; the first step execution information represents the step execution information corresponding to all the target test cases; the first execution success rate represents the execution success rate corresponding to all the target test cases;
[0030] For each of the target test cases, determining a second page corresponding to the target test case according to the identifier corresponding to the target test case;
[0031] The second step execution information, the second execution success rate, the text log and the screenshot log corresponding to the test case are displayed on the second page; the second step execution information represents the step execution information corresponding to the target test case; the second execution success rate represents the execution success rate corresponding to the target test case.
[0032] In a second aspect, the present application provides a web application testing device, the device comprising:
[0033] An acquisition module is used to acquire test data corresponding to the web application to be tested, and call each function object in the core function library; each of the function objects includes one or more of an operation function object, a log function object and a network function object;
[0034] A generating module, configured to generate each test case according to the test data and each of the functional objects; the test case includes each test item determined based on one or more of the operation functional object, the log functional object and the network functional object;
[0035] A determination module, used to determine each target test case corresponding to each preset test environment configuration from each of the test cases, and each execution strategy corresponding to each of the target test cases;
[0036] The testing module is used to execute the corresponding target test cases in the web applications configured in the preset test environments according to the execution strategies to obtain corresponding test results.
[0037] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0039] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0040] The web application testing method, apparatus, computer equipment, computer-readable storage medium and computer program product obtain test data corresponding to the web application to be tested, call each function object in the core function library, generate each test case determined based on one or more of the operation function object, log function object and network function object according to the test data and each function object, and execute each corresponding target test case in each web application of each preset test environment configuration according to the execution strategy to obtain the corresponding test result. Compared with the traditional method of testing web applications in a fixed environment, this solution generates test cases for each environment configuration by combining each function object in the core function library, and executes the corresponding test cases in parallel in each test environment configuration, thereby improving the efficiency of web application testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 An application environment diagram of a web application testing method in an embodiment;
[0043] Figure 2 A schematic diagram of a flow chart of a web application testing method in one embodiment;
[0044] Figure 3 A structural diagram of a web application testing method in one embodiment;
[0045] Figure 4 A structural block diagram of a core library in an embodiment;
[0046] Figure 5 A schematic diagram of a flow chart of the steps of updating an operation function object in one embodiment;
[0047] Figure 6 A flowchart of test case generation steps in an embodiment;
[0048] Figure 7 A structural block diagram of a preset test environment configuration in an embodiment;
[0049] Figure 8 A schematic diagram of a flow chart of the steps of generating a preset test environment configuration in one embodiment;
[0050] Fig. 9 A structural block diagram of a test execution in one embodiment;
[0051] Fig.10 A flowchart of test execution steps in one embodiment;
[0052] Fig.11 A flowchart of test execution steps in another embodiment;
[0053] Fig.12 A structural block diagram of a test report in an embodiment;
[0054] Fig.13 A schematic flow chart of test report generation steps in one embodiment;
[0055] Fig.14 A schematic diagram of the structure of a test report page in an embodiment;
[0056] Fig.15 An architectural diagram of a web application testing method in one embodiment;
[0057] Fig.16 It is a flowchart of a web application testing method in another embodiment;
[0058] Fig.17 This is a schematic diagram of the interface of the test report main page in an embodiment;
[0059] Fig.18 A schematic diagram of an interface of a test report subpage in an embodiment;
[0060] Fig.19 This is a schematic diagram of an interface of a screenshot page in an embodiment;
[0061] Fig. 20 is a structural block diagram of a web application testing device in one embodiment;
[0062] Fig.21 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0064] The web application testing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown in the figure. Among them, the Git code platform communicates with the server through the network. The server includes multiple types of servers. During the test execution, the test cases are dispatched through the test server, and the test cases are dispatched through the multi-process of the Node node server to realize the parallel operation of the test cases. The test script establishes a connection with the Selenium server and sends a request to the Selenium server. Generally, at least two requests need to be sent to the server to execute commands or assertions. The first request is used to locate the page element, and then the next request is executed to perform the actual command or assertion on the given element. Based on this, the Selenium server drives the browser page to complete the test script content, that is, to complete the test case. Among them, the Selenium server is an automated testing tool that supports multiple browsers. It can simulate user operations, such as clicking, filling out forms, submitting, etc., for automated testing of web applications. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0065] In an exemplary embodiment, Figure 2 As shown, a web application testing method is provided, which is applied to Figure 1 The server in is taken as an example to illustrate, including the following steps S202 to S208.
[0066] in:
[0067] Step S202, obtaining test data corresponding to the web application to be tested, and calling each function object in the core function library; each function object includes one or more of an operation function object, a log function object and a network function object.
[0068] Among them, the web application to be tested can be a web application. This embodiment provides a front-end automated testing framework with strong ease of use, strong operability, strong functionality, and strong feedback, which solves the testing requirements for Web applications and the functional supplement and optimization for automated testing in terms of writing test cases, test configuration, test management execution, and viewing test results. It solves the problems of the existing front-end testing framework, such as the single test configuration method; the inability to reuse and parallel test test cases of the same business process under different test conditions; the lack of detailed records of the entire test process; and the lack of intuitive feedback on test results.
[0069] Among them, automated testing is a testing method that refers to the use of specific software to control the test process and compare the differences between the actual results and the expected results. By automating the test, the human testing behavior of the software can be converted into the behavior of the machine automatically performing the test, thereby replacing a large number of manual testing operations, so that the test can be carried out quickly and repeatedly. The server can perform automated testing on the web application to be tested. Figure 3 As shown, Figure 3 It is a structural flowchart of a web application testing method in an embodiment. After determining the overall framework architecture and the overall test process, the overall functional modules of the test framework are divided according to business requirements and automated testing requirements. This test framework is generally divided into four parts: a core library module, a test configuration module, a test management execution module, and a test report module. Among them, the core library module includes a core function library. The core function library includes one or more functional objects, for example, it may include one or more of an operation function object, a log function object, and a network function object, which are used to provide corresponding functions for the writing of test cases. Among them, the operation function object includes an assertion function and a command function.
[0070] The server can then obtain the test data corresponding to the web application to be tested, and call each function object in the core function library. The test data can be the test content of the web application, for example, clicking a certain position in the web application to enter a certain page.
[0071] Among them, the server can pre-build core function libraries, such as Figure 4 As shown, Figure 4 It is a structural flowchart of the core library in an embodiment. The core function library module mainly provides the required functions when writing test cases. According to the demand analysis of the core function library module, the core function library module needs to provide assertion function, command function, log function, screenshot function, context function, encapsulated element operation function and HTTP (Hypertext Transfer Protocol) test function for writing test cases. The core function library can be divided into six submodules, namely API (Application Programming Interface) module, log screenshot module, HTTP test function module, context module, encapsulation basic operation module and registration module.
[0072] Among them, the API module provides assertions and commands for writing test cases. Among them, assertions are expressed as some Boolean expressions, the value of the expression is true at a specific point in the program, and the command can be an operation action in the above-mentioned web application. The API module of the test case can be divided into: test execution assertion part, test execution command part, and WebDriver (web driver) protocol part. Among them, the test execution assertion part mainly provides an API for verifying the elements located on the page; the test execution command part mainly provides an API for operating the browser page; the WebDriver protocol part mainly provides an API for lower-level operations.
[0073] In order to meet the testing requirements of web applications, new assertions and commands need to be added. After the new assertions and commands are written, the newly added APIs need to be put into the library through the extension function of Nightwatch before they can be used. In addition, new operations need to be added based on the original APIs. Finally, all APIs are encapsulated to form a new API library, and test cases are written based on the new API library. Among them, Nightwatch is written in nodejs and is an end-to-end automated testing framework based on web-driven interfaces.
[0074] Specifically, Figure 5 As shown, Figure 5The flowchart of the operation function object update step in an embodiment is shown. For the update process of API function objects, the server can first write a new API to realize the creation of new assertions and commands, and configure the newly written API address to the extended assertion library address and extended command library address of the Nightwatch configuration file. The newly written API is thus added to the Nightwatch API. The server then uses the log screenshot module to perform secondary encapsulation of the API in Nightwatch, so that when the function object corresponding to each API is called and executed, there will be a log record, and new operations are added to some of the original APIs according to the website testing requirements. The encapsulation process includes all newly added APIs, thereby forming a new API library of assertion library and command library.
[0075] For the test case log module, the test case log module mainly provides log recording and screenshot log recording functions. The log module is divided into two parts: test operation log part and screenshot log part. The test operation log part provides six levels of log functions, namely prompt information, warning information, error information, debugging information, and platform information. The server can perform different levels of log recording by calling different levels of logs.
[0076] The screenshot log part is mainly divided into two aspects. On the one hand, it provides a screenshot log function to take screenshots of the browser page and store them in the test results. When encapsulating the API, the server calls the screenshot log part to take screenshots of key steps and record them. At the same time, when writing test cases, the server calls the screenshot log part to actively take screenshots and record them at the location where you want to take screenshots. On the other hand, the server can use Nightwatch's failure screenshot function to take screenshots of the browser page and save them in the screenshot folder when a test case fails or an error occurs.
[0077] The test case context module stores information such as the test environment of the current test execution in the context object. The context object is provided by the core function library module. After the test management execution module distributes test cases to each test environment, the context object is assigned before the test case is executed. The context object refers to the specific background in which the test case runs, including input data, dependent external services or resources, system status, etc. When the server writes a test case, it can obtain the test data of the web application in the current test environment through the test environment information in the context object.
[0078] The HTTP test module provides methods to test the website HTTP request process. The server builds HTTP requests, uses the assertion library and log module to verify and record the results of the request response, and supports testing of GET (get), POST (submit), PUT (update), DELETE (delete) and other requests.
[0079] The Encapsulated Basic Element Module encapsulates the element operations and their operation combinations that are frequently used in front-end testing, and records different logs in each operation by calling the log module. For example, in automated testing, controls on the page, such as buttons, text boxes, and hyperlinks, are often repeatedly operated. By encapsulating these elements, the server can simplify the test code and reduce maintenance costs. Testers can directly implement some basic element operations by calling the Encapsulated Basic Element Module without having to write them repeatedly, and at the same time, distinguish and record when performing the same operations on these elements.
[0080] The registration module registers each module in the core function library module to an object and provides it to testers for use. The core function library module is mainly used to write test cases. After registering each module through the registration module, the server only needs to call the registered object to use all methods in the core function library, which simplifies the grammatical rules for testers to write test cases.
[0081] Step S204, generating various test cases according to the test data and various functional objects; the test cases include various test items determined based on one or more of the operation functional objects, the log functional objects and the network functional objects.
[0082] The server may generate multiple test cases using the test data obtained above and each functional object in the core functional library. For example, the server determines each test item for the web application based on one or more of the operation functional object, log functional object, and network functional object in the core functional library to form multiple test cases.
[0083] Step S206, determining each target test case corresponding to each preset test environment configuration and each execution strategy corresponding to each target test case from each test case.
[0084] The server may also construct multiple preset test environment configurations in advance, and the preset test environment configurations may include environment configurations for testing web applications, and may also include configurations for running inside the server automated test framework. The environment configurations for testing web applications include user-defined configurations and configurations for command line options. Different preset test environment configurations may correspond to different test cases, and in different preset test environment configurations, the execution methods of the test cases are also different. The server may determine from each test case the target test cases corresponding to each preset test environment configuration, and the execution strategies corresponding to each target test case.
[0085] Step S208 , executing corresponding target test cases in respective web applications configured in respective preset test environments according to respective execution strategies, and obtaining corresponding test results.
[0086] Different test environment configurations may correspond to different execution strategies, and the execution strategy may be an execution strategy corresponding to a target test case. The server may execute each target test case corresponding to the corresponding preset test environment configuration in each web application of each preset test environment configuration based on each execution strategy corresponding to each preset test environment configuration, and obtain a corresponding test result. The test result may include the execution status of the target test case, etc. The server may execute each target test case in each preset test environment configuration in parallel.
[0087] In the above web application testing method, by obtaining the test data corresponding to the web application to be tested, calling each function object in the core function library, generating each test case determined based on one or more of the operation function object, the log function object and the network function object according to the test data and each function object, and executing the corresponding target test cases in each web application of each preset test environment configuration according to the execution strategy to obtain the corresponding test results. Compared with the traditional method of testing web applications in a fixed environment, this solution generates test cases for each environment configuration by combining each function object in the core function library, and executes the corresponding test cases in parallel in each test environment configuration, thereby improving the efficiency of web application testing.
[0088] In one embodiment, various test cases are generated according to test data and various function objects, including: determining operation data for a web application according to the test data, and generating operation test items according to the operation function object and the operation data in the function object; determining network test data for the web application according to the test data, and generating network test items according to the network function object and the network test data in the function object; determining the level of the operation data or the network test item according to the matching results of the operation data and the network test item with a preset log level table respectively; the level includes a first level and a second level; determining a log recording test item for the web application according to the log function object and the level; the log recording test item includes a screenshot log test corresponding to the first level and a text log test corresponding to the second level; and generating various test cases according to the operation test item, the network test item and the log recording test item.
[0089] In this embodiment, different test cases may have different functional tests for web applications. Including operation test items, network test items, log record test items, etc. The server can determine the operation data for the web application based on the test data, and generate the operation test items based on the operation function object and the operation data in the function object. Among them, the operation data represents the data formed by the operation of the web application, and the operation function object is the function object in the core function library. In addition, the server can determine the network test data for the web application based on the test data, such as HTTP test, etc. The server can generate the network test items based on the network function object and the network test data in the function object.
[0090] The server may also add a logging function to the test case, wherein the logging function includes multiple levels, and operations at different levels correspond to different logging methods. The server may determine the level of the operation data or network test item based on the matching results of the operation data and the network test item with the preset log level table. The levels include the first level and the second level.
[0091] The server can determine the log record test items for the web application according to the log function object and level. Among them, the log record test items include the screenshot log test corresponding to the first level and the text log test corresponding to the second level. That is, the server can perform one or more of text records and screenshot records on the log of the test process. The server can generate various test cases according to the operation test items, network test items and log record test items.
[0092] Specifically, Figure 6 As shown, Figure 6The flowchart of the test case generation step in an embodiment is shown in FIG. When writing a test case, the server first calls the context object in the core function library to obtain the test environment for the current test case execution. According to the context object, the test data required for this test is obtained from local files, external files and external web servers. Thus, the server can obtain the test execution command by calling the API module, simulate the user's operation on the page, and verify the consistency of the expected result displayed on the page and the actual test result, so as to form the operation data. Inside the API module, the server adds a log call in each API method to record each operation, and calls different levels of log functions according to the function of the operation and the operation execution, so that each operation is fully recorded when it is executed. For example, the server calls the screenshot log function in the key operation API to take a screenshot of the browser page when the current operation is in progress and record it; when the server needs to record information, the server calls the log module in the test case to record the operation or take a screenshot. When the server needs to operate some basic elements, the server calls the encapsulated basic element operation function, and calls the log function in the encapsulated basic element operation to log different elements. When the server needs to connect and test the HTTP request, the server calls the HTTP test function, and calls the log function in each HTTP test method to log the response result. By calling the functions provided by these core libraries, the server completes the writing of test cases and performs detailed logging in each operation step.
[0093] Through this embodiment, the server can use each function object in the core function library to generate a test case containing multiple test items, and then use each test case to test the web application, thereby improving the test efficiency of the web test.
[0094] In one embodiment, each target test case corresponding to each preset test environment configuration and each execution strategy corresponding to each target test case are determined from each test case, including: for each preset test environment configuration, determining a test case directory, the number of test cases and a test sequence according to the preset test environment configuration; in each test case in the test case directory, determining each target test case corresponding to the number of test cases; and determining the execution strategy corresponding to the preset test environment configuration according to the test sequence.
[0095] In this embodiment, different preset test environment configurations may correspond to different target test cases and different execution strategies. For each preset test environment configuration, the server may determine the test case directory, the number of test cases, and the test order according to the preset test environment configuration. Among them, the test case directory represents the storage directory of the target test cases corresponding to the preset test environment configuration, the number of test cases represents the number of target test cases, and the test order represents the execution order of the target test cases in the preset test environment configuration. The server may determine each target test case corresponding to the number of test cases in each test case in the test case directory, and determine the execution strategy corresponding to the preset test environment configuration according to the test order. Among them, the server may pre-build multiple preset test environment configurations.
[0096] Specifically, Figure 7 As shown, Figure 7 It is a structural block diagram of a preset test environment configuration in an embodiment. The configuration module can implement test configuration through two test configuration methods, and the server can also rewrite the Nightwatch configuration file in the framework. Therefore, the server divides the test configuration module into two functional sub-modules: the user test configuration part and the framework internal configuration. Among them, the user test configuration part provides two test configuration methods for testers. First, the server can perform test configuration by writing a test configuration file, and then the server can perform test configuration by entering configuration options and option values in the command line before executing the test. The server configures the configuration file address required for this test in the command line, and can select the test configuration file written by the user to complete the test configuration, forming a preset test environment configuration. Among them, the user test configuration part provides the test configuration options required for website testing, and sets the default test configuration option value. When the server does not detect the input of the corresponding test configuration option, the server runs with the default value.
[0097] For the internal configuration of the framework, the server mainly rewrote the Nightwatch configuration file. Since the test framework retains some functions in Nightwatch and expands on this basis, the server configures the functions in Nightwatch that need to be used within the test framework. Among them, the original functions that need to be used in the test framework of this embodiment include the screenshot function when the test fails and errors occur, the test tool function, the extended assertion library and the extended command library function, the Selenium server function, and the global hook function. The server can apply these functions to the test framework of this embodiment by rewriting the Nightwatch configuration file in the framework to achieve the underlying configuration of the test environment.
[0098] The specific process of configuring the preset test environment on the server can be as follows: Figure 8 As shown, Figure 8 A flowchart of the steps of generating a preset test environment configuration in an embodiment. The server can write a test configuration file, i.e., the preset test environment configuration mentioned above. In the test configuration file, the server can configure a test case execution directory, which is the storage address of all test cases executed in this test. Thus, the server can choose to configure other test conditions according to the test requirements. After the server writes the test configuration file, the server can detect and input configuration option information in the command line, configure the test configuration file address, obtain the test configuration file selected for this test, and then obtain other configuration option information according to the test requirements. Among them, the server can write multiple test configuration files. When entering the command line options, the server performs different test tasks by selecting different test configuration files. When certain test conditions need to be changed, the server only needs to modify the value of the file or directly enter the configuration options that need to be modified in the command line.
[0099] Through this embodiment, the server can pre-configure multiple preset test environment configurations and determine target test cases under different configurations, and then perform parallel testing under different test environment configurations based on different target test cases, thereby improving the efficiency of testing web applications.
[0100] In one embodiment, according to each execution strategy, corresponding target test cases are executed in each web application of each preset test environment configuration to obtain corresponding test results, including: for each web application of each preset test environment configuration, a first preset hook file is executed to obtain a first test result and a first web application; according to the test sequence corresponding to the preset test environment configuration of the web application, in the first web application, each target test case corresponding to the preset test environment configuration is executed to obtain a second test result and a second web application; and a second preset hook file is executed in the second web application to obtain a test result corresponding to the web application.
[0101] In this embodiment, each of the above-mentioned preset test environment configurations may also include a first preset hook file and a second preset hook file. The first preset hook file is also called a pre-run hook, which may be an operation that the server needs to perform on the web application before the target test case is executed. The first preset hook may include a custom hook pre-entered by the user, and may also include a global hook at the bottom layer of the server's test framework; the second preset hook file is also called a post-run hook, which may be an operation that the server needs to perform on the web application after the target test case is executed. The second preset hook may include a custom hook pre-entered by the user, and may also include a global hook at the bottom layer of the server's test framework. The server may perform tests under each preset test environment configuration based on the above-mentioned first preset hook file, target test case, and second preset hook file.
[0102] For example, for each web application with a preset test environment configuration, the server can execute the first preset hook file corresponding to the preset test environment configuration in the web application to obtain a first test result and a first web application. The first test result represents the execution result of the first preset hook file, and the first web application represents the web application after executing the first preset hook file. The server can execute each target test case corresponding to the preset test environment configuration in the first web application according to the test sequence corresponding to the preset test environment configuration of the web application, and obtain a second test result and a second web application. The second test result represents the test result of the server executing the target test case, and the second web application represents the web application after executing the target test case. The server can also execute the second preset hook file in the second web application to obtain the test result corresponding to the web application. The test result includes the execution results corresponding to the execution of the first preset hook file, the target test case, and the second preset hook file by the server under the preset test environment configuration, and the corresponding state of the web application.
[0103] Specifically, Fig. 9 As shown, Fig. 9 The structure diagram of the test execution in one embodiment. The server includes a test management execution module, which manages and distributes the test execution environment and test cases to complete the execution process of the entire test. The test management execution module mainly includes a test case management part and a test case execution part. Among them, in the test case management part, the server dispatches the test cases that need to be executed configured by the tester to the queue of the environment to be executed according to the test environment and test execution condition information in the configuration information. In the test case execution part, the server completes the preparation work before the test case execution, the execution process and the cleanup work after the execution.
[0104] The test management process can be as follows: Fig.10 As shown, Fig.10 The flowchart of the test execution steps in one embodiment is shown in FIG. 1 . The server can manage and assign the test environment and test cases that need to be executed. The server can determine, based on the demand analysis, that the test cases need to be tested in different country domains, different browser window sizes, and different machine environments, and that they need to support parallel operation at two levels. The server then obtains all the test environments from the test configuration information, and allocates the number of test cases and the test sequence for the test environment combination in a single execution. The server then obtains all the test cases through the test case directory in the test configuration information, and allocates each target test case of the corresponding test environment configuration to each executed test environment as required, and starts the test execution.
[0105] The process of executing the test case can be as follows Fig.11As shown, Fig.11 It is a flowchart of the test execution steps in another embodiment. After allocating the test environment and test cases, the server can perform the test case execution task. Among them, the execution of the test case is divided into before execution, during execution and after execution. The server can generate a hook file in advance. For example, the server completes the preparation and cleanup work before and after the test execution by rewriting the global hook file of Nightwatch; and it can also receive the hook file written and input by the tester, add the tester's hook file to the global hook and execute the operations defined in the file.
[0106] Among them, before executing the test case, the server can write a custom hook file, in which the server can write the common behaviors that all test cases need to execute before and after running; when the test is started, the server executes the pre-run hook in the global hook file, obtains the user hook file through the test configuration information and executes it; then starts to execute the test script, that is, executes the above-mentioned target test case, and operates the page of the web application under the corresponding preset test environment configuration through the Selenium server to complete the script content. After a single test case is completed, the server completes the post-execution cleanup work, such as executing the post-run hook and executing the post-run defined behavior in the user hook file. When all test cases are executed, the server can pass the test results to the test report module.
[0107] Through this embodiment, the server can combine multiple preset hook files and target test cases, execute corresponding target test cases according to the execution strategy in the web application under the corresponding test environment configuration, and use the preset hook files to execute global steps, thereby improving the testing efficiency of the web application.
[0108] In one embodiment, according to each execution strategy, each corresponding target test case is executed in each web application configured in each preset test environment. After the corresponding test results are obtained, it also includes: determining the execution order, execution success rate, text log and screenshot log corresponding to each target test case according to the test results; and displaying the test report corresponding to the web application according to the execution order, execution success rate, text log and screenshot log.
[0109] In this embodiment, after the server completes the execution of the corresponding target test cases in each preset test environment configuration and obtains the corresponding test results, the test report can be generated. Among them, the test results include the execution order of the target test cases, the test success rate, the corresponding text logs and screenshot logs, etc. The server can determine the execution order, execution success rate, text logs and screenshot logs corresponding to each target test case based on the test results, and display the test report corresponding to the web application based on the execution order, execution success rate, text log and screenshot log. Among them, the server can display the test report through the front-end multi-level display method.
[0110] In one embodiment, a test report corresponding to a web application is displayed according to an execution order, an execution success rate, a text log, and a screenshot log, including: according to the execution orders and execution success rates corresponding to the target test cases, the respective identifiers corresponding to the target test cases, the first step execution information corresponding to the web application, and the first execution success rate are displayed on a first page; the first step execution information represents the step execution information corresponding to all target test cases; the first execution success rate represents the execution success rate corresponding to all target test cases; for each target test case, the second page corresponding to the target test case is determined according to the identifier corresponding to the target test case; according to the execution order and execution success rate corresponding to the target test case, the second step execution information, the second execution success rate, the text log, and the screenshot log corresponding to the test case are displayed on a second page; the second step execution information represents the step execution information corresponding to the target test case; the second execution success rate represents the execution success rate corresponding to the target test case.
[0111] In this embodiment, the server can generate multiple pages to display different test results. Among them, the server can display the various identifiers corresponding to each target test case, the first step execution information corresponding to the web application, and the first execution success rate on the first page according to the various execution orders and execution success rates corresponding to each target test case. Among them, the first step execution information represents the step execution information corresponding to all target test cases, and the first execution success rate represents the execution success rate corresponding to all target test cases. The above-mentioned first page can be a main page.
[0112] The server can also generate a corresponding subpage for each target test case. For each target test case, the server can determine the second page corresponding to the target test case according to the identifier corresponding to the target test case. Among them, the second page can be a subpage corresponding to the above-mentioned main page, and the server can display the second step execution information, second execution success rate, text log and screenshot log corresponding to the test case on the second page according to the execution order and execution success rate corresponding to the target test case. Among them, the second step execution information represents the step execution information corresponding to the target test case, and the second execution success rate represents the execution success rate corresponding to the target test case. The server can display the corresponding subpage of the target test case by receiving the trigger information of the identifier of the target test case in the main page.
[0113] Specifically, Fig.12 As shown, Fig.12 : is a structural block diagram of a test report in an embodiment. Among them, the server can process data through the test report module and use a visual front-end page to intuitively display the test results. The server adopts the idea of separating the front and back ends to build a test report module. For example, the server processes data on the node server side, implements the test report page on the front end of the node server, and transmits data from the back end to the front end in JSON format.
[0114] The test report module mainly includes the server-side test result data processing part, the front-end test report introduction part and the test report front-end implementation part. In the data result data analysis and processing part, the server can obtain the original test result data and further process it; in the test report calling part, the server transmits the processed test data to the front-end implementation part by introducing the test report implementation part; in the test report front-end implementation part, the server displays the test result data on the page in the form of charts, step bars, etc.
[0115] The steps for the server to generate a test report can be as follows Fig.13 As shown, Fig.13 The figure is a flowchart of the test report generation step in an embodiment. The server obtains the original test results from the test management execution module, adds header information to different test cases according to the execution order of the test cases, and then generates a screenshot log of the screenshot logs of the failed steps and error steps captured by Nightwatch, and puts them into the log records of the corresponding steps of the test results; the server can also introduce the packaged file of the front-end test report from the library package, and pass the processed test results to the test report implementation part. The server determines whether to open the test report on the browser according to the preset configuration information, and if necessary, opens the browser to display the front-end page of the test implementation part.
[0116] The structure of the test report page displayed by the server can be as follows: Fig.14 As shown, Fig.14 The schematic diagram of the structure of the test report page in one embodiment. The front-end test report is divided into a main page and a sub-page. The server can display the overall situation of the success and failure of the target test case on the main page of the test report, and the server can display the specific execution process of each test case on the sub-page of the test report, that is, the execution information of the first step mentioned above, and the intuitive display of the website page during the test execution is obtained through the screenshot display.
[0117] Specifically, the server can display statistical information, error test case step bars and home page prompt information on the main page. In the main page, the upper part displays all test case pass rates, test step pass rates, test assertion pass rates in the form of charts, and displays all success and failure numbers at the same time; the lower part of the main page displays the overall step execution status of all test cases, that is, the above-mentioned second step execution information; the server displays different prompt information at the top of the home page according to whether the test execution is successful, failed, or an error occurs. The server can also display all test case names, that is, the identification of the above-mentioned test cases, in the left column of the main page. The server can classify according to the test country domain, test execution machine environment and browser open page size. Each column of test case names can be clicked, and after clicking, the test case names can be entered into the respective test case example page.
[0118] The server can display the specific execution steps and log records of each test case on a subpage. Each test case corresponds to a subpage, and the server displays the log records and execution time of all steps of the test case on the subpage. The log records include logs recorded when assertions and commands are executed, log records of HTTP tests, logs recorded when testers call the log module, screenshot logs, and screenshot images. Different log categories are displayed in different colors.
[0119] Through the above embodiment, the server can generate multiple levels of test reports based on the test results, and display the overall test results and the test results of each test case in the main page and sub-page respectively, thereby improving the intuitiveness of the test result display.
[0120] In an exemplary embodiment, Fig.15 As shown, Fig.15 The following is an architecture diagram of a web application testing method in an embodiment. The server implements a front-end automated testing framework based on the Nightwatch framework and the Selenium web driver. The testing framework includes a test management execution layer, a test case layer, and a test report layer.
[0121] The test case layer is used to generate test case scripts. The test framework uses a data-driven model to separate data and scripts. In the test case layer, the server obtains test data through local files, external files, and external web servers; the server writes test cases by calling assertions, commands, log screenshot functions, context objects, HTTP test functions, and encapsulated basic operations in the core library of the test framework. Multiple test case scripts can be written.
[0122] The test management execution layer relies on the input of the test configuration. The server manages the test scripts according to the test configuration information, calculates the parallel number and order of the dispatched test execution environments, and the number of test cases executed in each test environment; then, it completes the execution of all test cases according to the test script directory information in the test configuration.
[0123] The test report layer depends on the test management execution layer. After the test execution is completed, the server passes the test data to the test report layer through the test management execution layer. At the same time, the server starts the test report module on the node server side through the test management execution layer. After the server-side test report module processes the data, it passes the test data to the node front-end test report module in JSON format and opens the front-end test report on the browser.
[0124] Among them, in terms of writing test cases, the system provides testers with log screenshot functions, new core function library functions, encapsulated basic element operation functions, HTTP test functions, and context object functions that achieve high reuse of test cases. The log screenshot function provides multiple levels of logging and screenshot recording functions, and fully records the entire test execution process by calling the log screenshot function in each module and when the tester is writing the test case; the HTTP request test function provides the function of HTTP request testing, and enriches the front-end test function by building HTTP requests and testing their responses; the new core function library provides an API interface library suitable for platform page operations and page verification; the context object function provides the current test running environment and test data for different running environments for test cases, achieving high reuse of test cases in different environments; the basic element encapsulation module encapsulates the operation and logging of basic elements, and can be directly called when the server generates test cases, reducing the workload of test case generation.
[0125] In terms of test configuration, multiple test configuration methods are provided, and new configuration options are added for website and test framework operation. The server configures the test execution conditions, execution environment, execution method, etc. through the test configuration module to improve the flexibility of test configuration.
[0126] In terms of test management and execution, the server can complete the distribution and execution of test cases according to the test information configured by the tester. At the same time, the same test case can be run in parallel in different test environments to improve test efficiency.
[0127] In terms of viewing test results, the server provides a front-end test report to show test results and test execution process intuitively and in detail for testers. The main page of the test report shows test result statistics, prompt information and error test case step bars; the sub-pages show the specific execution process, execution time and screenshots of the test execution process of each test case.
[0128] The server obtains the test data used in this test case from the test data file through the context function object, and then writes the test case by using the new core function library, log screenshot and other functions. The test case is dispatched and executed through the test execution information configured by the server. After the test case is executed, the test data is passed to the test report part, which processes the data and generates a front-end test report. Through the above steps, the server can efficiently complete the entire front-end automated testing process, thereby reducing the testing workload, improving the test execution efficiency, reducing the time to analyze the test results, and providing faster feedback to developers on system problems.
[0129] by Fig.15 The architecture diagram can implement a web application testing method, such as Fig.16 As shown, Fig.16 The flowchart of the web application testing method in another embodiment is shown in FIG. The server can write test cases. The server first calls the context object in the core function library, obtains the test data of this test from local files, external files and external web servers, and then writes the test case script by calling the assertion, command, log, screenshot function, context object, HTTP test function and encapsulated basic element operations in the core function library according to the business process.
[0130] The server can configure the test, for example, configure the test execution conditions. The server obtains the configuration file or receives the configuration option information in the command line, specifies the directory address or file address of the test script to be executed in this test, and specifies the test execution environment and execution mode.
[0131] The server can also manage and execute test cases. The server manages the execution of test cases according to the test configuration information by using the management and execution part of the automated test framework. In each test case, the server parses the test case and operates the system under test according to the content to complete the test.
[0132] After the execution is completed, the server generates a test report and test result analysis. The server generates a test report after data processing based on the obtained test results. The test report is displayed in the form of a front-end page, and the tester can understand the test execution status by viewing statistical charts, home page prompts, log step bars, test environment classification information and screenshots. By viewing the report content, the failure position is located. If there is an error in the test case writing, the test case writing is revised, and the test is continued after the revision is completed; if there is a functional error, the developer is notified to modify the corresponding function.
[0133] In one embodiment, an application embodiment is also provided. In this embodiment, the ticket booking business flow of the ticketing website is taken as an example to illustrate the application of the above web application testing method in the ticketing platform testing work. Among them, the server installs the test framework and formulates the test content. According to the ticket booking business flow of the ticketing platform, the formulated test data content may include "1. Create a user and create a ticket event for the latest concert of singer L; 2. Open the corresponding ticket purchase page of the ticketing website according to the created ticket event; 3. The user logs in to the ticketing website; 4. Select the concert seat information; 5. Click to enter the payment page; 6. Submit the ticket purchase order; 7. Verify that the order is successfully created".
[0134] The server can generate test cases based on the specified test content. Generating test cases is divided into multiple steps. Among them, the server needs to create a js file and generate test cases in this file. The server can prepare for test writing. For example, the server calls the Nightly plug-in to obtain the client object, context function object, log function object, etc., and writes tests by calling framework API, context and log screenshot functions through these objects; the server can also obtain the source of test data and call public services to provide user and order data; call global test services to provide characteristic test data for different countries; call db-util components to connect to the database. Therefore, the server can create test steps based on the specified test content, clarify the execution purpose of each step, and each step corresponds to the corresponding execution content. And in each defined test step, the test behavior is generated through assertions, commands, logs, and context object call methods.
[0135] Take the creation event and ticket purchase event as examples. In the creation event step, the server first calls the public service, obtains the current test country and machine environment information through the context object, and uses the createUser method in the public service to create the user seller; then the server calls the logging.info method of the log module to record the information that the current user has created. In the ticket purchase event step, the server first calls the waitForElementVisible method in the API, waits for the appearance of the seat element to be selected on the page, and uses the click method to select the seat when the element appears, and the page jumps. Then the server waits for the appearance of the confirmation order button element. When the element appears, use the click method to click the confirmation order button, and the page jumps to the payment page. After waiting for the order information element to appear after the page jumps, it means that the page has been successfully jumped.
[0136] After generating the test case, the server can decide whether to write a custom hook file. If necessary, the server creates a hook file and writes the hook functions of the pre-run hook and the post-run hook in the file. For example, the server first generates the pre-run hook function. Before the test case starts executing, the server first uses the url method in the API to open the ticketing website URL, uses the setCookie method to set the cookie value for the current browser, and then uses the getCookie method to get the set cookie value and uses the logging.info method in the log module to record the value of the created cookie. Then the server can write the post-run hook function. After the test case execution ends, the server uses the resizeWindow method in the API to resize the browser window to 500×500.
[0137] The server can also write configuration information in the configuration file, that is, the preset test environment configuration mentioned above. For example, the server can set the test case directory address, the value of the machine environment process pool, and the value of the region for this test execution.
[0138] After all the files required for the test are written, the server receives the run command in the command line. The required test run configuration option information can be entered in the run command, so that the server can receive the corresponding configuration option information. The test case starts to execute, and the server can determine the current test execution status and the execution steps of each test case through the log in the local command line. After all test cases are executed, the browser will automatically open the test report by default. After completing all the testing work, the server uploads the latest project code to the git platform server for subsequent regression testing.
[0139] Among them, the server can display the overall execution status of the test case on the main page, such as Fig.17As shown, Fig.17 The interface diagram of the main page of the test report in an embodiment. Among them, in the home page summary section, the server can display charts of the pass rate of the number of all test cases, the pass rate of the execution steps, and the pass rate of the assertion. The server can convert the data into ratio charts and tables through the G2 visualization tool. In the home page prompt information section, the server adds different home page prompt information according to the results. In the home page case section, the server can display the overall step information of all test cases, display all test cases in order, obtain the test step name and test step execution status of each test case, and the server can also use the horizontal step bar in the Ant-Design component library for display, using a green logo before the successful step and a red logo before the failed step.
[0140] The server can display the menu sidebar part in the main page. The sidebar is a foldable menu bar. By configuring the priority order of the page size, the test cases with the same conditions are screened out and placed in the nested menu bars. By clicking each test case name in the menu bar, the server can jump to the corresponding subpage and realize the jump on one page.
[0141] like Fig.18 As shown, Fig.18 The following is a schematic diagram of the interface of a test report subpage in an embodiment. The test report contains multiple different subpages, each of which corresponds to a test case. The server can display all the information of all test step logs through step bars. Different colors are used to distinguish different logs. Fig.19 As shown, Fig.19 The following is a schematic diagram of the interface of a screenshot page in an embodiment. When there is a screenshot log in the step, the screenshot address information in the log information is obtained after the corresponding execution step, and the screenshot thumbnail is displayed. By clicking the thumbnail, the server can display the enlarged screenshot.
[0142] Through the above embodiments, the server generates test cases for various environment configurations by combining various function objects in the core function library, and executes corresponding test cases in parallel in various test environment configurations, thereby improving the efficiency of web application testing. In addition, the server implements multiple test configuration methods and adds new configurable options to enhance the configuration flexibility of testers; the server supports high reuse and parallel testing of the same test case in different environments where the website needs to be tested by utilizing context objects and multi-process methods, realizes code and data separation, and improves test efficiency; and the server implements logging and screenshot functions to record or screenshot each step of the operation performed on the front-end page, and records at different levels according to the purpose of the operation and the result of the operation, thereby enhancing the comprehensiveness of the test record; the server also adds an API library for writing test cases, and further simplifies the test case writing process by encapsulating basic elements; and the server implements the HTTP test module to implement testing of HTTP requests, enriching the front-end test functions; in addition, the server also designs and implements the front-end test report, which organizes and analyzes the test results, uses the front-end framework and component library to intuitively display the test results in the form of charts on the main page, uses a single-page application to jump to multiple sub-pages, displays the specific test execution process, logging and website page screenshots, and makes the feedback test results more intuitive and detailed.
[0143] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0144] Based on the same inventive concept, the embodiment of the present application also provides a web application testing device for implementing the web application testing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more web application testing device embodiments provided below can refer to the limitations of the web application testing method above, and will not be repeated here.
[0145] In an exemplary embodiment, Fig. 20As shown, a web application testing device is provided, including: an acquisition module 500, a generation module 502, a determination module 504 and a testing module 506, wherein:
[0146] The acquisition module 500 is used to acquire the test data corresponding to the web application to be tested, and call each function object in the core function library; each function object includes one or more of an operation function object, a log function object and a network function object.
[0147] The generating module 502 is used to generate various test cases according to the test data and various functional objects; the test cases include various test items determined based on one or more of the operation functional objects, the log functional objects and the network functional objects.
[0148] The determination module 504 is used to determine, from among the test cases, each target test case corresponding to each preset test environment configuration, and each execution strategy corresponding to each target test case.
[0149] The testing module 506 is used to execute corresponding target test cases in each web application configured in each preset test environment according to each execution strategy to obtain corresponding test results.
[0150] In one embodiment, the above-mentioned generation module 502 is used to determine the operation data for the web application according to the test data, and generate the operation test items according to the operation function object and the operation data in the function object; determine the network test data for the web application according to the test data, and generate the network test items according to the network function object and the network test data in the function object; determine the level of the operation data or the network test item according to the matching results of the operation data and the network test item with the preset log level table respectively; the level includes the first level and the second level; determine the log recording test item for the web application according to the log function object and the level; the log recording test item includes the screenshot log test corresponding to the first level and the text log test corresponding to the second level; generate each test case according to the operation test item, the network test item and the log recording test item.
[0151] In one embodiment, the above-mentioned determination module 504 is used to determine the test case directory, the number of test cases and the test order for each preset test environment configuration according to the preset test environment configuration; in each test case in the test case directory, determine each target test case corresponding to the number of test cases; and determine the execution strategy corresponding to the preset test environment configuration according to the test order.
[0152] In one embodiment, the above-mentioned test module 506 is used to execute the first preset hook file for each web application configured with a preset test environment to obtain a first test result and a first web application; according to the test sequence corresponding to the preset test environment configuration of the web application, in the first web application, execute each target test case corresponding to the preset test environment configuration to obtain a second test result and a second web application; and execute the second preset hook file in the second web application to obtain a test result corresponding to the web application.
[0153] In one embodiment, the above-mentioned device also includes: a display module, which is used to determine the execution order, execution success rate, text log and screenshot log corresponding to each target test case according to the test results; and display the test report corresponding to the web application according to the execution order, execution success rate, text log and screenshot log.
[0154] In one embodiment, the above-mentioned display module is used to display the various identifiers corresponding to each target test case, the first step execution information corresponding to the web page application, and the first execution success rate on the first page according to the various execution orders and execution success rates corresponding to each target test case; the first step execution information represents the step execution information corresponding to all target test cases; the first execution success rate represents the execution success rate corresponding to all target test cases; for each target test case, the second page corresponding to the target test case is determined according to the identifier corresponding to the target test case; according to the execution order and execution success rate corresponding to the target test case, the second step execution information, the second execution success rate, the text log and the screenshot log corresponding to the test case are displayed on the second page; the second step execution information represents the step execution information corresponding to the target test case; the second execution success rate represents the execution success rate corresponding to the target test case.
[0155] Each module in the web application testing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0156] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.21As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store test data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a web application testing method is implemented.
[0157] Those skilled in the art will understand that Fig.21 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0158] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned web application testing method when executing the computer program.
[0159] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned web application testing method is implemented.
[0160] In one embodiment, a computer program product is provided, including a computer program, which implements the above-mentioned web application testing method when executed by a processor.
[0161] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0162] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0163] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0164] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A web application testing method, characterized in that: The method comprises: Acquire test data corresponding to the web application to be tested, and call each function object in the core function library; each function object includes one or more of an operation function object, a log function object, and a network function object; Generate each test case according to the test data and each of the functional objects; the test case includes each test item determined based on one or more of the operation functional object, the log functional object and the network functional object; Determine, from each of the test cases, each target test case corresponding to each preset test environment configuration, and each execution strategy corresponding to each of the target test cases; According to each of the execution strategies, corresponding target test cases are executed in each of the web applications configured in each of the preset test environments to obtain corresponding test results.
2. The method according to claim 1, characterized in that Generating each test case according to the test data and each functional object includes: Determine operation data for the webpage application according to the test data, and generate an operation test item according to the operation function object in the function object and the operation data; Determine network test data for the webpage application according to the test data, and generate network test items according to the network function object in the function object and the network test data; Determine the level of the operation data or the network test item according to the matching results of the operation data and the network test item with the preset log level table respectively; the level includes a first level and a second level; Determine a log record test item for the web application according to the log function object and the level; the log record test item includes a screenshot log test corresponding to the first level and a text log test corresponding to the second level; The test cases are generated according to the operation test items, the network test items and the log record test items.
3. The method according to claim 1, characterized in that The step of determining, from the test cases, target test cases corresponding to the preset test environment configurations and execution strategies corresponding to the target test cases includes: For each of the preset test environment configurations, determine the test case directory, the number of test cases, and the test order according to the preset test environment configuration; Determine, among each of the test cases in the test case catalog, each of the target test cases corresponding to the number of test cases; An execution strategy corresponding to the preset test environment configuration is determined according to the test sequence.
4. The method according to claim 3, characterized in that The preset test environment configuration includes a first preset hook file and a second preset hook file; According to each of the execution strategies, executing corresponding target test cases in each of the web applications configured in each of the preset test environments to obtain corresponding test results includes: For each web application configured in the preset test environment, executing the first preset hook file to obtain a first test result and a first web application; According to the test sequence corresponding to the preset test environment configuration of the web application, executing each of the target test cases corresponding to the preset test environment configuration in the first web application to obtain a second test result and a second web application; The second preset hook file is executed in the second web application to obtain a test result corresponding to the web application.
5. The method according to any one of claims 1 to 4, characterized in that: After executing the corresponding target test cases in the web applications configured in the preset test environments according to the execution strategies and obtaining the corresponding test results, the method further includes: According to the test results, determine the execution order, execution success rate, text logs and screenshot logs corresponding to each of the target test cases; A test report corresponding to the web application is displayed according to the execution order, the execution success rate, the text log and the screenshot log.
6. The method according to claim 5, characterized in that The displaying of the test report corresponding to the web application according to the execution order, the execution success rate, the text log and the screenshot log includes: According to the execution orders and execution success rates corresponding to the target test cases, the identifiers corresponding to the target test cases, the first step execution information and the first execution success rate corresponding to the web application are displayed on the first page; the first step execution information represents the step execution information corresponding to all the target test cases; the first execution success rate represents the execution success rate corresponding to all the target test cases; For each of the target test cases, determining a second page corresponding to the target test case according to the identifier corresponding to the target test case; The second step execution information, the second execution success rate, the text log and the screenshot log corresponding to the test case are displayed on the second page; the second step execution information represents the step execution information corresponding to the target test case; the second execution success rate represents the execution success rate corresponding to the target test case.
7. A web application testing device, characterized in that: The device comprises: An acquisition module is used to acquire test data corresponding to the web application to be tested, and call each function object in the core function library; each of the function objects includes one or more of an operation function object, a log function object and a network function object; A generating module, configured to generate each test case according to the test data and each of the functional objects; the test case includes each test item determined based on one or more of the operation functional object, the log functional object and the network functional object; A determination module, used to determine each target test case corresponding to each preset test environment configuration from each of the test cases, and each execution strategy corresponding to each of the target test cases; The testing module is used to execute the corresponding target test cases in the web applications configured in the preset test environments according to the execution strategies to obtain corresponding test results.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Test case detection method and device, storage medium and electronic equipment
CN120429241A