An automated regression testing method, device, computer equipment and storage medium

By obtaining page objects and configuration parameters on the Puppeteer framework's visual regression testing platform, page elements are tested automatically, solving the problem of low testing efficiency in existing technologies and achieving efficient testing without the need for front-end scripting.

CN115543807BActive Publication Date: 2026-02-10CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211237685.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-10
Publication Date
2026-02-10
Estimated Expiration
2042-10-10

AI Technical Summary

Technical Problem

Existing technologies have low testing efficiency in regression testing, especially when using the Puppeteer framework, which requires extensive knowledge of front-end scripting, resulting in a large workload for maintaining test scripts.

Method used

By calling the test page in the test case, the page object corresponding to the page element address is obtained, the test mode is determined according to the configuration parameters, the executable script of the operation method is parsed, and the Puppeteer framework's visual regression testing platform is used for automated testing, reducing the dependence on front-end script writing.

Benefits of technology

It improves testing efficiency, reduces the workload and costs for testers, and allows testers to complete testing tasks without needing extensive knowledge of front-end scripting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543807B_ABST
    Figure CN115543807B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of regression testing, and discloses an automatic regression testing method and device, computer equipment and a storage medium, wherein a test page in a to-be-tested case is called, a page object corresponding to a page element address in the test page is obtained according to the page element address, a configuration parameter of the page object is obtained, a test mode is determined according to the configuration parameter, the test mode is parsed, an executable script of an operation means is obtained, and feedback data of the operation is determined as a target test report of the to-be-tested case. The application is based on a visual regression testing platform that is established in advance based on a Puppeteer framework to perform automatic testing, the to-be-tested case is subjected to automatic testing through an operation mode and a page element address, and a tester can complete the testing work without needing to master a lot of front-end script writing knowledge, so that the application is easy to operate, the workload and testing cost of the tester are reduced, and the testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of regression testing, and in particular to an automatic regression testing method and device, computer equipment and a storage medium. BACKGROUND

[0002] With the rapid development of computer technology, pages need to be constantly updated to meet user needs. Before a page is officially put online, developers need to improve the page in response to emerging problems and user needs, so the page needs to be regression tested, such as testing whether the page functions can be used, whether the page style meets expectations, and whether the page performance meets requirements.

[0003] When facing complex and numerous page regression tests, a browser simulation framework is usually used to write automatic test scripts. The commonly used frameworks are selenium and puppeteer. Puppeteer has an advantage over selenium in that it provides network interception and performance management functions. Moreover, since puppeteer is a node library, it does not require a complex installation environment. However, when using this framework to test pages, a lot of knowledge of front-end script writing is often required, resulting in too much work to maintain test script code and reducing test efficiency. Therefore, how to improve test efficiency during regression testing has become a problem to be solved. SUMMARY

[0004] Therefore, it is necessary to provide an automatic regression testing method, device, computer equipment and storage medium to solve the problem of low test efficiency during regression testing.

[0005] A first aspect of the embodiments of the present application provides an automatic regression testing method, which comprises:

[0006] calling a test page in a test case to be tested;

[0007] obtaining a page object corresponding to a page element address in the test page according to the page element address;

[0008] obtaining a configuration parameter of the page object by a user, determining a test mode according to the configuration parameter, and the test mode comprising at least one operation means;

[0009] parsing the test mode to obtain an executable script of the operation means, executing the executable script to operate the test page, and determining feedback data of the operation as a target test report of the test case to be tested.

[0010] The second aspect of the embodiment of the application provides an automatic regression testing device, the device comprising:

[0011] The calling module is configured to call a test page in a test case.

[0012] The page object determining module is configured to obtain a page object corresponding to a page element address in the test page according to the page element address.

[0013] The test mode determining module is configured to obtain a configuration parameter of the page object by a user, and determine a test mode according to the configuration parameter, wherein the test mode comprises at least one operation means.

[0014] The test module is configured to parse the test mode to obtain an executable script of the operation means, perform the executable script on the test page to determine feedback data of the operation as a target test report of the test case.

[0015] In a third aspect, the embodiment of the application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the automatic regression testing method according to the first aspect.

[0016] In a fourth aspect, the embodiment of the application provides a computer readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to implement the automatic regression testing method according to the first aspect.

[0017] Compared with the prior art, the embodiment of the application has the following beneficial effects:

[0018] The test page in the test case is called, the page object corresponding to the page element address in the test page is obtained according to the page element address, the configuration parameter of the page object by the user is obtained according to the page object, the test mode is determined according to the configuration parameter, the test mode is parsed to obtain the executable script of the operation means, and the feedback data of the operation is determined as the target test report of the test case. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0020] Figure 1 is a schematic diagram of an application environment of an automatic regression testing method provided by an embodiment of the present application;

[0021] Figure 2 is a schematic diagram of a flow of an automatic regression testing method provided by an embodiment of the present application;

[0022] Figure 3 is a schematic diagram of a flow of an automatic regression testing method provided by an embodiment of the present application;

[0023] Figure 4 is a schematic diagram of a flow of an automatic regression testing method provided by an embodiment of the present application;

[0024] Figure 5 is a schematic diagram of a structure of an automatic regression testing device provided by an embodiment of the present application;

[0025] Figure 6 is a schematic diagram of a structure of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0026] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort under the premise of not making the present application fall into the public domain.

[0027] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0028] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0029] As used in the description of the application and the appended claims, the term "if' can be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted to mean "upon determining" or "in response to determining" or "upon detecting [the described condition or event]" or "in response to detecting [the described condition or event]," depending on the context.

[0030] In addition, the terms "first", "second", "third", etc. as used in the description of the application and the appended claims are merely used to differentiate one description from another, and cannot be interpreted to imply or suggest relative importance.

[0031] Reference in the specification to "one embodiment" or "some embodiments" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. The appearances of the phrase "in one embodiment" or "in some embodiments" in various places in the specification are not necessarily all referring to the same embodiment, although it can. The terms "including," "comprising," "having" and variations thereof are meant to encompass the items listed thereafter, but do not exclude other items from being present.

[0032] It should be understood that the size of the serial number of each step in the following embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the application.

[0033] In order to illustrate the technical solutions of the application, the following specific embodiments are described.

[0034] An embodiment of the application provides an automatic regression testing method, which can be applied in an application environment of a client and a server. Figure 1 The client includes but is not limited to a palm computer, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA) and the like computer device. The server can be implemented by an independent server or a server cluster composed of multiple servers.

[0035] Referring to Figure 2 is a flowchart of an automatic regression testing method provided by an embodiment of the application, and the automatic regression testing can be applied in an application environment of a client and a server.Figure 1 a server end in the service end, the server end is connected with the corresponding client end, as shown in Figure 2 The automatic regression test method can include the following steps.

[0036] S201: calling a test page in a to-be-tested case.

[0037] In step S201, the to-be-tested case is a page included in a system that needs to be tested, i.e., a to-be-tested page, and the to-be-tested case can be multiple.

[0038] In this embodiment, the to-be-tested case is selected in the visualization interface, and the corresponding test page is called according to the selected to-be-tested case. When the test page of the to-be-tested case is called, the test page can be called by obtaining the address URL of the test page. The URL provides an abstract identification method for the location of a resource, and the resource is located by using this method, so that the system can perform various operations on the resource, such as accessing, updating, replacing, and finding the attributes.

[0039] The to-be-tested case is a system module completed in a development environment and not formally put online. On the basis of the benchmark function, the to-be-tested case is improved by adding, deleting, modifying, etc. The test page in the to-be-tested case needs to be tested before going online to ensure that the code runs correctly, and the predetermined function of the upgraded version can be implemented. The test page in the to-be-tested case of the benchmark function is the online code allowed to run on the current production environment, i.e., it has been applied to an actual application scenario, and the code running result can achieve the expected result.

[0040] It should be noted that the visualization interface in this embodiment is an interface in a visualization regression test platform pre-established based on a Puppeteer framework. The Puppeteer framework can be used to simulate the behavior of a browser. It is a headless browser simulation framework based on the Chrome kernel, and most user operation behaviors, such as access, click, etc., can be simulated by directly controlling the Chrome kernel through the API provided by the Puppeteer framework. The page test of the present application is also based on this. A visualization regression test platform is pre-established based on the Puppeteer framework, the address of the test page is accessed by using the visualization regression test platform, and a test result is generated to realize automatic test of the test page.

[0041] It should be noted that the to-be-tested case refers to the description of a test task performed on a specific object (for example, a software product, a functional node, an application page, etc.), which embodies the test scheme, method, technology and strategy. Its content includes but is not limited to at least one of the following: test target, test environment, input data, test step, expected result, test script, etc., and finally forms a document.

[0042] For example, for a page, its corresponding test case can include, but is not limited to, the following information: page identification, page address, test element and corresponding click path, test step, expected result (entry availability, can jump, no crash, etc.), test script.

[0043] The test pages in the to-be-tested case can be multiple, and each test page can be tested to obtain the test result of each to-be-tested page. The multiple to-be-tested pages can be sequentially tested or tested in parallel.

[0044] It should be noted that when the test pages are multiple, the selection of the test pages and the testing of the test pages can be sequentially executed, that is, all the test pages are selected first, and then each page is tested, or can be executed in parallel, that is, the test pages are selected and the selected test pages are tested at the same time.

[0045] The to-be-tested case is automatically generated according to the operation history information of the test page, and the operation history information of the test page can reflect the user's preference for operating the to-be-tested page, that is, for the test page, which information provided in the page is used by the user, and how to control the page to provide the required information. According to the operation history information, the to-be-tested case can be generated to simulate the operation of the user using the page to test the availability, stability and other aspects of the performance of the page.

[0046] It should be noted that the to-be-tested case can also be preconfigured with permission configuration information in the embodiment, for example, the permission configuration information generally includes which roles can access the current to-be-tested case and which roles cannot access the current to-be-tested case in the to-be-tested system.

[0047] S202: Obtain a page object corresponding to the page element address according to the corresponding page element address in the test page.

[0048] In step S202, the page element address is an address corresponding to each page element in the test page, wherein each page element address corresponds to a page element, and the page object is a page element corresponding to the obtained page element address.

[0049] In the embodiment, the page element address is used to indicate the storage path of the page element content, for example, if the page element is a picture element, the element path information is the path information of the picture in the picture element; for another example, if the page element is an audio element, the element path information is the path information of the audio in the audio element.

[0050] In the embodiment, the page element path address is stored by using an XPath path language, wherein the XPath is a language for finding information in an XML document, the corresponding page element can be acquired by the XPath path, and the data in the XML document body is organized by a tree structure. The XPath regards the document structure of the XML as a tree structure, and elements, attributes, texts, annotations and processing instructions are nodes on the tree structure. The access to the elements, attributes, texts, annotations and processing instructions in the XML document is actually the sequential traversal of the tree.

[0051] The XPath uses path expressions to select nodes or node sets in an XML document. The path expressions are very similar to the expressions we see in a regular computer file system. For example, when the page element is a click operation element, after detecting that the user clicks the A element on the corresponding page, according to the XML file of the page, all the ancestor elements of the page element A are html, body, div, div, wherein the html element is the root element of the page. At this time, according to the acquired ancestor elements and the element page A, the XPath path of the page element A is generated, wherein the XPath path of the page element A is: / html / body / div[4] / div[2] / A. The path expression is a written step sequence from one XML node to another node or a set of nodes, which can locate a node or a node set in the XML document, thereby locating the corresponding page element.

[0052] For example, taking the login system in the test case as an example, there are a login interface text page element and a key page element, wherein the text page element is stored in the storage path corresponding to the text page element, the key page element is stored in the storage path corresponding to the key page element, and the configuration parameters of the text page element and the key page element are written into the XML document. When the corresponding page element needs to be acquired, the page element address in the XML document is used to acquire the page element corresponding to the address.

[0053] It should be noted that in the process of generating the page element address, the address corresponding to the page element is preferentially selected by the ID selector.

[0054] S203: Acquire the page object configuration parameters of the user, and determine the test mode according to the configuration parameters.

[0055] In step S203, the configuration parameter is parameter information pre-configured for the page element, and the configured parameter at least includes a position parameter of the page element in the test page and a size parameter of the page element. Of course, the parameter information pre-configured for the page element is not limited to the above-mentioned position parameter and size parameter, and according to different application scenarios, the configuration parameter of the page element can also include other parameter data.

[0056] In this embodiment, according to the page object, the page object configuration parameter is obtained, wherein the page object configuration parameter includes a size parameter of the page element, a function parameter, a position parameter of the page element in the test page and a series of parameters.

[0057] For example, the button operation in the page element corresponds to the page object configuration parameter, which can be a "click" button, a "long press" button, a "slide" button, a "coordinate click" button and an "assert" button. In addition, the time length information corresponding to the "click" button, the time length information of the "long press" button, the slide length information and the slide start and end position information of the "slide" button, etc. When clicking, the page object configuration parameter corresponding to the "click" operation can include parameter configuration items "name", "sleep" and "click times (times)". In the test case, when the page is converted, for example, in the home page of the test case, there are text page elements and key page elements, wherein the text page element is used to display the corresponding text style, the key page element has a "next step" prompt text, and when the key page element is pressed, it can jump to the next page.

[0058] S204: Analyzing the test mode to obtain an executable script of the operation means, executing the executable script to operate the test page, and determining the feedback data of the operation as the target test report of the test case.

[0059] In step S204, in the regression automation test process, according to the parameter configuration, the operation means corresponding to the preset test mode is started, wherein the corresponding operation means can be clicking, inputting, asserting, uploading files, executing functions, etc. After the test is completed, the corresponding test report is generated.

[0060] In this embodiment, according to the page object configuration parameter, the operation means corresponding to the preset test mode is started, for example, clicking, inputting, asserting, uploading files, executing functions, etc. For complex operations, the browser can be operated through the preset function, such as setting the fixed time interval date, operating the rich text editor, etc.

[0061] For example, when testing interface display, user interface jump and logic, animation effects and other cases, the test control button is clicked in the execution script obtained in the automatic test, and whether the next page can be successfully tested is tested. It should be understood that the examples of test operations here are only for easy understanding and do not limit the present application.

[0062] Optionally, the test mode includes an assertion operation, the test mode is parsed to obtain an executable script of the operation means, the test page is operated by executing the executable script, and the feedback data of the operation is determined as the target test report of the to-be-tested case, including:

[0063] The test mode is parsed to obtain an executable script of the assertion operation;

[0064] The test page is judged by executing the executable script, and if the judgment result does not meet the preset condition, the test is aborted, and the result of the aborted test is taken as the target test report of the to-be-tested case.

[0065] In this embodiment, the test mode is parsed to obtain an executable script of the assertion operation, the test page is judged by executing the executable script, and if the judgment result does not meet the preset condition, the test is aborted, and the result of the aborted test is taken as the target test report of the to-be-tested case.

[0066] The test mode is parsed to obtain each configuration item, the execution script in the corresponding automatic test is obtained according to each configuration item, the test page is tested by running the execution script, and the test report of the to-be-tested case is generated. The automatic execution script is used for automatic test work, and the test personnel can write the automatic test script on the local or cloud of the Mac system. The programming language of the automatic test script can be Python language, Java language or other computer program languages that can realize script programming. The automatic execution script contains related data of testing insurance business. It should be understood that the examples of the automatic execution script here are only for easy understanding and do not limit the present application.

[0067] In this embodiment, the execution script generally refers to a series of instructions for a specific test, which can be executed by an automatic test tool. In order to improve the maintainability and reusability of the execution script, they must be built before execution. The execution script is a computer readable instruction for automatically executing a test process (or part of a test process). The execution script can be created (recorded) or automatically generated using a test automation tool, or programmed in a programming language. In a popular understanding, the to-be-tested case is a specific set of input data, operations or various environment settings provided to the tested system for implementing the test, and the expected result. The execution script is a script written for automatic testing. The test script must correspond to the corresponding test case.

[0068] The executable script is executed to judge the test page, and if the judgment result does not satisfy the preset condition, the test is terminated, and the result of the terminated test is taken as the target test report of the to-be-tested case, wherein the preset condition is a condition that is satisfied by the test result and is set in advance.

[0069] Optionally, if the judgment result does not satisfy the preset condition, the test is terminated, and the result of the terminated test is taken as the target test report of the to-be-tested case, including:

[0070] If the judgment result does not satisfy the preset condition, the test is terminated, and a screenshot of the terminated page corresponding to the terminated test is taken to obtain a page snapshot of the terminated page.

[0071] The page snapshot is written into the target test report of the to-be-tested case.

[0072] In the embodiment, the assertion mode in the operation means refers to some Boolean expressions used for debugging the program in the to-be-tested case to determine whether some tested functions work normally (i.e., whether the actual value and the expected value are the same), and the assertion is a judgment on the execution structure rather than a judgment on the business process. The assertion is the most basic component of the unit test, and the assertion is equivalent to an if() statement. If the execution program satisfies the assertion, if the assertion is not satisfied, an error is thrown. Each type of assertion has two forms. One form includes a received message parameter, and the message indicates a prompt information when an error occurs. The other form does not include the message parameter. For example, a programmer believes that the expression value is true at a specific point in the program, and the assertion verification can be enabled and disabled at any time. The assertion is enabled during the test, and the assertion is disabled during the deployment. After the program is put into operation, the assertion can be re-enabled when a problem is encountered. The use of the assertion can create more stable, better quality and less error-prone code. When it is necessary to interrupt the current operation when a value is FALSE, the assertion can be used, and the unit test must use the assertion (Junit / JunitX). The assertion can also be used to determine whether various features are well maintained in the program.

[0073] The assertion mode is used to terminate the test when the expected value cannot be output during the test, take a page screenshot of the result page, obtain a page snapshot of the terminated page, and write the page snapshot into the target test report of the to-be-tested case.

[0074] Optionally, after the executable script is executed to judge the test page, the method further includes:

[0075] If the judgment result meets the preset condition, the test mode is analyzed, the executable script of the operation means is obtained, the test page is operated by executing the executable script, and the feedback data of the operation is determined as the target test report of the to-be-tested case.

[0076] In this embodiment, if the judgment result meets the preset condition, the test mode is analyzed, the executable script of the operation means is obtained, wherein the operation means can include clicking, dragging, filling, etc., the test page is operated by executing the executable script, and the feedback data of the operation is determined as the target test report of the to-be-tested case.

[0077] Optionally, the test page is operated by executing the executable script, and the feedback data of the operation is determined as the target test report of the to-be-tested case, comprising:

[0078] The test time when the test page is the home page of the to-be-tested case and the data request amount of the test page are recorded by executing the executable script to monitor the test page;

[0079] The test time and the data request amount of the test page are written into the target test report of the to-be-tested case.

[0080] In this embodiment, when the executable script is executed, the execution script is monitored, the test time of the test page when the test page is the home page of the to-be-tested case in the to-be-tested case is obtained, and the data request amount of the test page is obtained, the test time and the data request amount of the test page are written into the target test report of the to-be-tested case.

[0081] The test page in the to-be-tested case is called, the page object corresponding to the page element address is obtained according to the corresponding page element address in the test page, the user configuration parameter of the page object is obtained according to the page object, the test mode is determined according to the configuration parameter, the test mode is analyzed, the executable script of the operation means is obtained, and the feedback data of the operation is determined as the target test report of the to-be-tested case.

[0082] Referring to Figure 3 is a flowchart of an automatic regression test method provided by an embodiment of the application, as shown in Figure 3 The automatic regression test method can include the following steps:

[0083] S301: A test scene configured by a user is obtained, the test scene is analyzed, and N test interfaces are determined.

[0084] S302: Obtain the test mode configured by the user, and test the to-be-tested case by sequentially calling N test interfaces according to the test mode to generate a test page, or test the to-be-tested case by simultaneously calling N test interfaces to generate a test page.

[0085] S303: Determine the test mode of the to-be-tested case according to the test scene corresponding to the to-be-tested case.

[0086] In this embodiment, the test scene configured by the user is obtained, the test scene is parsed, N test interfaces are determined, the test mode configured by the user is obtained, the to-be-tested case is tested by sequentially calling N test interfaces according to the test mode to generate a test page, or the to-be-tested case is tested by simultaneously calling N test interfaces to generate a test page, the test mode of the to-be-tested case is determined according to the test scene corresponding to the to-be-tested case, and the test mode includes a separate test mode, a parallel test mode and a serial test mode.

[0087] For example, when the test scene is a registration scene, the test interface related to the registration scene is determined, the test mode of the registration scene is to simultaneously call N test interfaces for testing, and when the corresponding test content such as name test and identity test is input on the test page, the interface for name authentication and the interface for identity authentication are simultaneously called. The test mode of simultaneously calling multiple interfaces is a parallel test mode.

[0088] S304: Call the test page in the to-be-tested case;

[0089] S305: Obtain the page object corresponding to the page element address according to the corresponding page element address in the test page;

[0090] S306: Obtain the configuration parameter of the page object configured by the user, and determine the test mode according to the configuration parameter;

[0091] S307: Parse the test mode to obtain an executable script of an operation means, execute the executable script to operate the test page, and determine the feedback data of the operation as the target test report of the to-be-tested case.

[0092] The steps S304 to S307 and the contents of the steps S201 to S204 are the same, and the description of the steps S201 to S204 can be referred to, and details are not described herein.

[0093] Referring to Figure 4 , a flowchart of an automatic regression test method provided by an embodiment of the present application is shown as Figure 4 The automatic regression test method can include the following steps:

[0094] S401: calling a test page in a to-be-tested case;

[0095] S402: obtaining a page object corresponding to a page element address according to the page element address in the test page;

[0096] S403: obtaining a configuration parameter of the page object by a user, and determining a test mode according to the configuration parameter;

[0097] S404: parsing the test mode to obtain an executable script of an operation means, performing the executable script on the test page to determine feedback data of the operation as a target test report of the to-be-tested case.

[0098] The steps S401 to S404 are the same as the contents of the steps S201 to S204, and the description of the steps S201 to S204 can be referred to, and details are not described herein.

[0099] S405: obtaining a historical test report of the to-be-tested case according to the to-be-tested case, comparing the target test report with the historical test report, and determining a test result of the to-be-tested case.

[0100] In the embodiment, the test report generated in the to-be-tested case is compared with the historical test report in the to-be-tested case to obtain a comparison result, and the test result of the to-be-tested case is determined according to the comparison result.

[0101] It should be noted that the test report includes performance data of the to-be-tested page, an execution result of a test step, and a page snapshot of a failed step, and the performance data includes a first page white screen time, a first page loading time, and a number of HTTP requests. When the test report is compared with the historical test report, the page snapshots in the test report and the historical test report are compared by using a preset comparison algorithm, for example, an image diff algorithm, to obtain difference information between the two sets of page snapshots, and the difference information is used as a reference of the test result. The preset comparison algorithm can also be another comparison algorithm that can realize snapshot comparison, and the embodiment of the present application is not limited in this regard.

[0102] It should be noted that when the comparison result is greater than a preset threshold, it is considered that the regression test result of the to-be-tested case reaches an expected effect, and when the comparison result is less than the preset threshold, it is considered that the regression test result of the to-be-tested case does not reach the expected effect.

[0103] Please refer to Figure 5 , Figure 5 is a structural schematic diagram of an automatic regression test device provided by the embodiment of the present application. In the embodiment, each unit included in the terminal is used to perform Figures 2 to 4Corresponding to the steps in the embodiment. For details, please refer to Figures 2 to 4 and Figures 2 to 4 Corresponding to the description in the embodiment. For ease of illustration, only the part related to the present embodiment is shown. Please refer to Figure 5 , the automatic regression test device 50 comprises a calling module 51, a page object determining module 52, a test mode determining module 53, and a test module 54.

[0104] The calling module 51 is configured to call a test page in a test case;

[0105] The page object determining module 52 is configured to obtain a page object corresponding to a page element address according to the page element address in the test page;

[0106] The test mode determining module 53 is configured to obtain a configuration parameter of the page object by a user, and determine a test mode according to the configuration parameter, wherein the test mode comprises at least one operation means;

[0107] The test module 54 is configured to parse the test mode to obtain an executable script of the operation means, perform the executable script on the test page, and determine feedback data of the operation as a target test report of the test case.

[0108] Optionally, the test module 54 comprises:

[0109] The parsing unit is configured to parse the test mode to obtain an executable script of the assertion operation;

[0110] The judging unit is configured to perform the executable script on the test page, and if a judging result does not satisfy a preset condition, the test is stopped, and a result of the test is taken as the target test report of the test case.

[0111] Optionally, the judging unit comprises:

[0112] The screenshot subunit is configured to, if the judging result does not satisfy the preset condition, stop the test, take a screenshot of a corresponding termination page when the test is terminated, and obtain a page snapshot of the termination page;

[0113] The writing subunit is configured to write the page snapshot into the target test report of the test case.

[0114] The execution subunit is configured to, if the judging result satisfies the preset condition, parse the test mode to obtain the executable script of the operation means, perform the executable script on the test page, and determine the feedback data of the operation as the target test report of the test case.

[0115] Optionally, the execution subunit comprises:

[0116] The monitoring subunit is used to execute executable scripts to monitor the test page and record the test time and the amount of data requests for the test page when the test page is the homepage of the test case.

[0117] The target test report defines a sub-unit, which is used to write the test time and the amount of data requests to the test page into the target test report of the test case.

[0118] Optionally, the aforementioned automated regression testing device 50 also includes:

[0119] The parsing module is used to obtain the user-configured test scenario, parse the test scenario, and determine N test interfaces;

[0120] The calling module is used to obtain the test method configured by the user. Based on the test method, it sequentially calls N test interfaces to test the test cases and generate test pages, or simultaneously calls N test interfaces to test the test cases and generate test pages.

[0121] The test method determination module is used to determine the test method for the test case based on the test scenario corresponding to the test case. The test methods include individual test method, parallel test method and serial test method.

[0122] It should be noted that the information interaction and execution process between the above-mentioned units are based on the same concept as the method embodiments of the present invention. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.

[0123] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 6 As shown, the computer device of this embodiment includes: at least one processor ( Figure 6 Only one is shown in the diagram), a memory, and a computer program stored in the memory and capable of running on at least one processor, which, when executed by the processor, implements the steps in any of the above-described embodiments of the automated regression testing methods.

[0124] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 6 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown in the illustration, or combinations of certain components, or different components, such as network interfaces, displays, and input devices.

[0125] The processor can be a CPU, and can also be other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0126] The memory includes a readable storage medium, an internal memory, etc., where the internal memory can be a memory of the computer device, and the internal memory provides an environment for running the operating system and the computer-readable instructions in the readable storage medium. The readable storage medium can be a hard disk of the computer device, and in other embodiments, can also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory can include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a BootLoader, data, and other programs, such as program codes of computer programs, etc. The memory can also be used to temporarily store data that has been output or will be output.

[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the above-described functions. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the unit and module in the above device can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here. If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the above-mentioned embodiment methods, which can be completed by a computer program to instruct related hardware. The computer program can be stored in a computer readable storage medium, and when the processor executes the computer program, the steps of the above-mentioned method embodiment can be realized. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer readable medium can at least include any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium cannot be an electrical carrier signal and a telecommunication signal.

[0128] The present application realizes all or part of the processes in the above-mentioned embodiment methods, which can also be completed by a computer program product. When the computer program product runs on the computer device, it makes the computer device execute the steps that can realize the above-mentioned method embodiments.

[0129] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.

[0130] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0131] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other manners. For example, the described apparatus / computer device embodiments are merely schematic. For example, the division of the modules or units can be different, and each can include a plurality of sub-units. Some or all of the modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.

[0132] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0133] The above embodiments are only used to illustrate the technical solutions of the present application, but not to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. An automated regression testing method, characterized in that, The automated regression testing method is applied to a pre-built visual regression testing platform based on the Puppeteer framework, and the automated regression testing method includes: Call the test page in the test case; Based on the page element address in the test page, obtain the page object corresponding to the page element address; Obtain the user's configuration parameters for the page object, and determine the test mode based on the configuration parameters. The test mode includes at least one operation method. The test mode is parsed to obtain the executable script of the operation method. The executable script is executed to operate the test page, and the feedback data of the operation is determined as the target test report of the test case. The test mode includes assertion operations. The test mode is parsed to obtain an executable script for the operation method. The executable script is executed to operate the test page, and the feedback data of the operation is determined as the target test report for the test case, including: The test mode is parsed to obtain the executable script for the assertion operation; The executable script is executed to judge the test page. If the judgment result does not meet the preset conditions, the test is terminated and the result of the test termination is used as the target test report of the test case. After executing the executable script to judge the test page, the method further includes: If the judgment result meets the preset conditions, the test mode is parsed to obtain the executable script of the operation method, the executable script is executed to operate the test page, and the feedback data of the operation is determined as the target test report of the test case. The step of executing the executable script to operate on the test page and determining the feedback data of the operation as the target test report of the test case includes: The executable script is executed to monitor the test page, and the test time and the amount of data requests for the test page are recorded when the test page is the homepage of the test case. The test time and the data request volume of the test page are written into the target test report of the test case.

2. The automated regression testing method as described in claim 1, characterized in that, Before calling the test page in the test case, the following steps are also included: Obtain the user-configured test scenario, parse the test scenario, and determine N test interfaces; Obtain the test method configured by the user, and according to the test method, sequentially call the N test interfaces to test the test case and generate a test page; or, simultaneously call the N test interfaces to test the test case and generate a test page. Based on the test scenario corresponding to the test case, the test method for the test case is determined. The test method includes a single test method, a parallel test method, and a serial test method.

3. The automated regression testing method as described in claim 1, characterized in that, If the judgment result does not meet the preset conditions, the test is terminated, and the result of the termination test is used as the target test report of the test case, including: If the judgment result does not meet the preset conditions, the test is terminated, and a screenshot of the termination page corresponding to the termination test is taken to obtain a page snapshot of the termination page. Write the page snapshot into the target test report of the test case.

4. The automated regression testing method as described in claim 1, characterized in that, After the feedback data for the determined operation is the target test report of the test case, it also includes: Based on the test case, obtain the historical test report of the test case, compare the target test report with the historical test report, and determine the test result of the test case.

5. An automated regression testing device, characterized in that, The device is applied to a pre-built visual regression testing platform based on the Puppeteer framework, and the device includes: The calling module is used to call the test page in the test case; The page object determination module is used to obtain the page object corresponding to the page element address based on the page element address in the test page. The test mode determination module is used to obtain the user's configuration parameters for the page object, and determine the test mode based on the configuration parameters. The test mode includes at least one operation method. The testing module is used to parse the test mode, obtain the executable script of the operation method, execute the executable script to operate the test page, and determine the feedback data of the operation as the target test report of the test case. The test mode includes assertion operations. The test mode is parsed to obtain an executable script for the operation method. The executable script is executed to operate the test page, and the feedback data of the operation is determined as the target test report for the test case, including: The test mode is parsed to obtain the executable script for the assertion operation; The executable script is executed to judge the test page. If the judgment result does not meet the preset conditions, the test is terminated and the result of the test termination is used as the target test report of the test case. After executing the executable script to judge the test page, the method further includes: If the judgment result meets the preset conditions, the test mode is parsed to obtain the executable script of the operation method, the executable script is executed to operate the test page, and the feedback data of the operation is determined as the target test report of the test case. The step of executing the executable script to operate on the test page and determining the feedback data of the operation as the target test report of the test case includes: The executable script is executed to monitor the test page, and the test time and the amount of data requests for the test page are recorded when the test page is the homepage of the test case. The test time and the data request volume of the test page are written into the target test report of the test case.

6. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the automated regression testing method as described in any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the automated regression testing method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Visual regression testing method, device, terminal device, and readable storage medium

    CN109254908A

  • Universal lightweight deep learning vehicle detection method

    CN113177560A