Assertion test method and device, electronic equipment and computer readable storage medium
Through the combination of page type judgment network model and assertion testing rules, the problem of low assertion testing efficiency and accuracy during application update is solved, efficient and accurate automated testing is achieved, and testing costs are reduced.
Patent Information
- Application Number
- CN202410832360.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-01
AI Technical Summary
During the application update process, how to test at assertion locations to improve the efficiency and accuracy of automated testing and reduce testing costs.
Classify the page type of the current page through the page type judgment network model to determine whether the current page is the expected page type. Combined with the assertion test rules to determine whether the page contains target key information, it is divided into page style assertions and detail assertions to improve the testing efficiency. Accuracy and tolerance.
It improves the accuracy of page type judgment, simplifies the number of detailed assertions for page judgment, and reduces test case maintenance costs. It is suitable for situations where the overall style of the page does not change much. It can tolerate minor changes and improves testing efficiency and accuracy.
Smart Images

Figure CN118733459A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of automated testing technology, and in particular to an assertion testing method, device, electronic device, and computer-readable storage medium. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the disclosure that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.
[0003] In programming, the purpose of assertions is to indicate and verify whether the results expected by the program developer are the same as the actual results of the operation - when the program runs to the assertion position, the corresponding assertion should be true. If the assertion is not true, the program will stop running and give an error message.
[0004] In the era of mobile Internet, major applications have become the traffic portal for a large number of users, and the architecture and design of applications are becoming more and more complex. As applications are updated, automated test cases are usually used to test the applications. In automated test cases, how to execute assertions to improve the efficiency and accuracy of automated testing and reduce testing costs has always been a difficulty and pain point. Summary of the invention
[0005] The purpose of the present disclosure is to provide an assertion testing method, device, electronic device and computer-readable storage medium, which can improve the efficiency and accuracy of automated testing and reduce testing costs.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] An embodiment of the present disclosure provides an assertion testing method, including: when a current page is reached, obtaining the current page; performing page type judgment processing on the current page through a page type judgment network model to determine a predicted page type of the current page; obtaining an expected page type corresponding to the current page; if the predicted page type is the same as the expected page type, determining that the current page passes a first assertion test.
[0008] In some embodiments, after determining that the current page passes the first assertion test, the method also includes: obtaining the assertion test rules corresponding to the current page; determining whether the current page includes target key information according to the assertion test rules; if the current page includes the target key information, determining that the current page passes the second assertion test; if the current page does not include the target key information, determining that the current page does not pass the second assertion test.
[0009] In some embodiments, determining whether the current page includes the target key information according to the assertion test rule includes: determining whether the current page includes the target key information according to the assertion test rule, and judging whether the target key information appears in a designated area; wherein, if the current page includes the target key information, determining that the current page passes the second assertion test includes: determining that the current page includes the target key information and the target key information appears in the designated area according to the assertion test rule, then determining that the current page passes the second assertion test; wherein, if the assertion test rule determines that the current page does not include the target key information, determining that the current page does not pass the second assertion test includes: determining that the current page does not include the target key information and / or the target key information does not appear in the designated area according to the assertion test rule, then determining that the current page does not pass the second assertion test.
[0010] In some embodiments, the method further includes: determining that the predicted page type is different from the expected page type, and then determining that the current page fails the first assertion test.
[0011] In some embodiments, the method also includes: obtaining automated test cases; testing the target application according to the automated test cases; wherein, when the current page is reached, obtaining the current page, including: determining that the target application reaches the current page according to the automated test case; wherein, performing page type judgment processing on the current page through a page type judgment network model to determine the predicted page type of the current page, including: comparing the current page with the previous frame page of the current page; if the current page is the same as the previous frame page, it is determined that the current page fails to appear normally, and it is determined that the target application fails to pass the first assertion test; if the current page is different from the previous frame page, the current page is processed through the page type judgment network model to continue to determine whether the target application passes the first assertion test.
[0012] In some embodiments, the method further includes: obtaining a target network to be trained; obtaining a page to be trained and a page type corresponding to the page to be trained; training the target network using the page to be trained and the page type corresponding to the page to be trained to obtain the page type judgment network model.
[0013] In some embodiments, the page type judgment processing is performed on the current page through a page type judgment network model to determine the predicted page type of the current page, including: determining the pixel mean and pixel standard deviation of each current page; normalizing each current page respectively through the pixel mean and the pixel standard deviation to obtain a normalized vector set corresponding to each current page; performing page type judgment processing on the normalized vector set corresponding to each current page through the page type judgment network model to determine the predicted page type of each current page.
[0014] The embodiment of the present disclosure provides an assertion testing device, including: a current page acquisition module, a page type judgment module, an expected page type acquisition module and a test pass judgment module.
[0015] Among them, the current page acquisition module is used to acquire the current page when the current page is reached; the page type judgment module can be used to perform page type judgment processing on the current page through a page type judgment network model to determine the predicted page type of the current page; the expected page type acquisition module can be used to acquire the expected page type corresponding to the current page; the test pass judgment module can be used to determine that the current page passes the first assertion test if the predicted page type is the same as the expected page type.
[0016] An embodiment of the present disclosure provides an electronic device, which includes: a memory and a processor; the memory is used to store computer program instructions; the processor calls the computer program instructions stored in the memory to implement any of the above-mentioned assertion testing methods.
[0017] The embodiment of the present disclosure provides a computer-readable storage medium having computer program instructions stored thereon to implement any of the assertion testing methods described above.
[0018] The embodiment of the present disclosure provides a computer program product or a computer program, which includes computer program instructions stored in a computer-readable storage medium. The computer program instructions are read from the computer-readable storage medium, and a processor executes the computer program instructions to implement the above assertion test method.
[0019] The assertion testing method, device, electronic device and computer-readable storage medium provided by the embodiments of the present disclosure can at least solve the technical problem of "how to perform testing at the assertion location in the process of application program updates and upgrades in order to improve the efficiency and accuracy of automated testing and reduce testing costs". The above-mentioned assertion testing method, device, electronic device and computer-readable storage medium can classify the page type of the current page through the page type judgment network model of the training network when the page is reached to determine whether the current page is the expected page type. By testing the current page by the above-mentioned method, on the one hand, it is possible to improve the accuracy of the test judgment of the current page by improving the classification accuracy of the page type judgment network model; on the other hand, the page type judgment network model has a greater tolerance for local modifications to the page, which is more friendly to test verification when the overall style of the page does not change much, but small changes are constantly made.
[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0022] Figure 1 A schematic diagram of a scenario that can be applied to an assertion testing method or an assertion testing device in an embodiment of the present disclosure is shown.
[0023] Figure 2 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0024] Figure 3 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0025] Figure 4 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0026] Figure 5 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0027] Figure 6 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0028] Figure 7The figure is a flowchart of a network model training method according to an exemplary embodiment.
[0029] Figure 8 The figure is a block diagram of an assertion testing device according to an exemplary embodiment.
[0030] Fig. 9 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0031] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0032] Those skilled in the art will appreciate that the embodiments of the present disclosure may be a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0033] The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.
[0034] In the embodiments of the present disclosure, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0035] The accompanying drawings are only schematic diagrams of the present disclosure, and the same reference numerals in the drawings represent the same or similar parts, so their repeated description will be omitted. Some block diagrams shown in the accompanying drawings do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0036] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and steps, nor must they be executed in the order described. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0037] In the description of the present disclosure, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is only a kind of association relationship describing the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different; the terms "comprising", "including" and "having" are used to express the meaning of open inclusion and mean that in addition to the listed elements / components / etc., there may be other elements / components / etc.
[0038] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0039] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information and network security.
[0040] The exemplary embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0041] Figure 1 A schematic diagram of a scenario that can be applied to an assertion testing method or an assertion testing device in an embodiment of the present disclosure is shown.
[0042] Please refer to Figure 1 , which shows a schematic diagram of an implementation environment provided by an exemplary embodiment of the present disclosure.
[0043] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0044] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, wearable devices, virtual reality devices, smart homes, etc.
[0045] The server 105 may be a server that provides various services, such as a background management server that provides support for devices operated by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received request data, and feed back the processing results to the terminal device.
[0046] The server can be an independent physical server or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as basic cloud computing services such as big data and artificial intelligence platforms, etc. The present disclosure does not impose any restrictions on this.
[0047] For example, server 105 may obtain the current page when the current page is reached; server 105 may, for example, perform page type judgment processing on the current page through a page type judgment network model to determine the predicted page type of the current page; server 105 may, for example, obtain the expected page type corresponding to the current page; server 105 may, for example, determine that the current page passes the first assertion test if the predicted page type is the same as the expected page type.
[0048] It should be understood that Figure 1 The number of terminal devices, networks and servers in the figure is only for illustration. The server 105 may be a physical server or may be composed of multiple servers. According to actual needs, it may have any number of terminal devices, networks and servers.
[0049] Under the above system architecture, an assertion testing method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device with computing and processing capabilities.
[0050] Figure 2 The method provided in the embodiment of the present disclosure can be executed by any electronic device with computing processing capability. For example, the method can be executed by the above-mentioned Figure 1 The server or terminal device in the embodiment may be executed, or the server and the terminal device may be executed together. In the following embodiments, the server is used as the execution subject for example, but the present disclosure is not limited to this.
[0051] Reference Figure 2 The assertion testing method provided by the embodiment of the present disclosure may include the following steps.
[0052] Step S202, when the current page is reached, obtain the current page.
[0053] In some embodiments, during the process of automated testing of application software or programs, the application software or programs are usually tested by writing test cases.
[0054] In some embodiments, when testing a corresponding program, it is usually tested whether the content displayed in a page is what the designer expects to be displayed. In order to test the page content, the page is usually automatically obtained as the current page when the page is reached (i.e., the page is displayed).
[0055] It is understandable that those skilled in the art can determine that a page has been reached through a variety of methods, for example, after a specific operation is performed in an application, a specific page will be displayed.
[0056] Step S204: performing page type judgment processing on the current page through the page type judgment network model to determine the predicted page type of the current page.
[0057] In some embodiments, the page type judgment network model can be obtained in advance through the training of the page to be trained and the page type corresponding to the page to be trained. The page type judgment network module can be a convolutional neural network model, a machine learning model, etc., and this application does not limit this.
[0058] The page type judgment network model may be an image recognition model, which may process the input page image to predict the page type of the input page image. The above page type may be set by a technician according to actual needs, and this application does not limit this.
[0059] Step S206, obtaining the expected page type corresponding to the current page.
[0060] The expected page type mentioned above may refer to a preset page type to which the current page should belong.
[0061] In some embodiments, it can be preset that a specific type of page will appear after a specific operation is performed on an application, and the specific type may be the expected page type described above.
[0062] In some embodiments, the current page mentioned above may refer to a page image corresponding to the current page.
[0063] Step S208: If the predicted page type is the same as the expected page type, it is determined that the current page passes the first assertion test.
[0064] In some embodiments, if the predicted page type determined for the current page by the page type determination network model is the same as the expected page type preset for the current page, then the current page passes the first assertion test.
[0065] In some embodiments, if the predicted page type determined for the current page by the page type determination network model is different from the preset expected page type corresponding to the current page, then it is determined that the current page fails the first assertion test.
[0066] Testing the accessed pages using the above method has the following beneficial effects.
[0067] 1. By improving the prediction accuracy of the page type judgment network model, the accuracy of testing the current page can be improved.
[0068] 2. Testing the current page through the page type judgment network model corresponding to the neural network structure is simpler and faster than judging the specific content of the page through rules, and can improve testing efficiency.
[0069] 3. Testing the current page by judging the network model based on the page type is a coarse-grained test with high tolerance. It does not make abnormal judgments for some small changes on the page during the application upgrade process. Therefore, this test does not need to modify the test case when the page changes are minor during the application upgrade process, which improves the efficiency of the test.
[0070] In the above embodiment, the image recognition model can be used to identify the overall style of the page as an assertion (referred to as "page style assertion", the same below) and added to the mobile automation test. After each page is touched, the "page style assertion" is first used to check whether the page belongs to a certain established category. If it does, the page test passes.
[0071] The advantages of this are: 1. First, the page is judged as a whole, which simplifies the number of detail assertions for page judgment and also reduces the cost of writing and maintaining detail assertions. 2. Page style assertions do not belong to detail type assertions. They have a greater tolerance for local modifications to the page. This is more friendly to test verification when the overall style of the page does not change much but small changes are made continuously.
[0072] Figure 3 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0073] refer to Figure 3 , the above assertion testing method may include the following steps.
[0074] Step S302, when the current page is reached, obtain the current page.
[0075] Step S304: performing page type determination processing on the current page through the page type determination network model to determine the predicted page type of the current page.
[0076] Step S306, obtaining the expected page type corresponding to the current page.
[0077] Step S308: determine whether the predicted page type is the same as the expected page type.
[0078] Step S310, obtaining the assertion test rules corresponding to the current page.
[0079] The above assertion test rules may be pre-set rules that can test and judge the specific content in the current page, for example, whether the current page includes certain key content, or whether certain key content is in certain specified locations, or whether certain key content is displayed in certain specific colors, etc. In short, this application does not limit the specific content of the assertion test rules.
[0080] Step S312: determining whether the current page includes target key information according to the assertion test rule.
[0081] In some embodiments, those skilled in the art can set the above target key information according to actual needs, and the target key information can be certain keywords, a certain key box or certain pictures, etc. For example, the target key information can be, for example, whether the font style of a certain word is a specified self-provisioning style, whether the picture resolution of the current page is a specified resolution, and whether the text in a certain place is modified to a specified text.
[0082] In some embodiments, the current page can be processed by image recognition technology (such as recognition through a neural network) or image segmentation technology (such as image segmentation through an image segmentation neural network) or optical character recognition (OCR) technology to determine whether the current page contains the target key information in the assertion test rules.
[0083] Step S314: If the current page includes the target key information, it is determined that the current page passes the second assertion test.
[0084] Step S316: If the current page does not include the target key information, it is determined that the current page fails the second assertion test.
[0085] In some embodiments, if the current page includes the target key information, it can be determined that the current page passes the second assertion test; if it is determined that the current page does not include the target key information, it can be determined that the current page fails the second assertion test.
[0086] In the above embodiment, on the one hand, the current page can be coarse-grained tested by the page type judgment network model to determine whether the current page has any abnormality; on the other hand, the content in the current page can be tested and judged by the assertion test rules to determine whether certain specified content appears in the current page.
[0087] It is understandable that in the update of the application, some relatively important things may be added to a certain page through minor changes. In this case, the page type judgment network in the above embodiment can be used to perform a coarse-grained page type judgment test on the page, and after the page type judgment test passes, some key content in the page can be fine-grained tested through assertion test rules.
[0088] In the above embodiment, on the one hand, the page is judged as a whole through the page type judgment network model, which simplifies the number of detail assertions for page attribution judgment and also reduces the cost of writing and maintaining detail assertions. On the other hand, the page style assertion does not belong to the detail type assertion, and it has a greater tolerance for local modifications to the page. This is more friendly to test verification when the overall style of the page does not change much but small changes are made continuously. In addition, some key local modifications in the page can be judged and tested through assertion test rules to better meet the test requirements.
[0089] Figure 4 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0090] refer to Figure 4 , the above assertion testing method may include the following steps.
[0091] Step S402, when the current page is reached, obtain the current page.
[0092] Step S404: performing page type determination processing on the current page through the page type determination network model to determine the predicted page type of the current page.
[0093] Step S406, obtaining the expected page type corresponding to the current page.
[0094] Step S408: determine whether the predicted page type is the same as the expected page type.
[0095] Step S410, obtaining the assertion test rules corresponding to the current page.
[0096] Step S412, determining whether the current page includes target key information according to the assertion test rule, and judging whether the target key information appears in the designated area.
[0097] Step S414: If the assertion test rule determines that the current page includes the target key information and the target key information appears in the designated area, it is determined that the current page passes the second assertion test.
[0098] Step S416: Determine, according to the assertion test rule, that the current page does not include the target key information and / or the target key information does not appear in the designated area, and then determine that the current page fails the second assertion test.
[0099] In some embodiments, the current page can be processed by image recognition technology (such as recognition through a neural network) or image segmentation technology (such as image segmentation through an image segmentation neural network) or optical character recognition (OCR) technology to determine whether the current page contains the target key information in the assertion test rule and whether the target key information appears in a specified area.
[0100] In some embodiments, if the current page includes the target key information and the target key information appears in the specified area, it is determined that the current page passes the second assertion test, then it can be determined that the current page has passed the test; if it is determined that the current page does not include the target key information and / or the target key information does not appear in the specified area, it can be determined that the current page has not passed the second test.
[0101] In the above embodiment, on the one hand, a coarse-grained test can be performed on the current page through the page type judgment network model to determine whether there is an abnormality in the current page; on the other hand, the content in the current page can be tested and judged through the assertion test rules to determine whether certain specified content appears in the current page and whether the specified content appears in the specified position.
[0102] It is understandable that in the upgrading of an application, some important things may be added to a certain page through minor changes. In this case, the page type judgment network in the above embodiment can be used to perform a coarse-grained page type judgment test on the page, and after the page type judgment test passes, the assertion test rules can be used to perform fine-grained tests on certain key content and the location of the key content in the page.
[0103] In the above embodiment, on the one hand, the page is judged as a whole through the page type judgment network model, which simplifies the number of detail assertions for page attribution judgment and also reduces the cost of writing and maintaining detail assertions. On the other hand, the page style assertion does not belong to the detail type assertion, and it has a greater tolerance for local modifications to the page. This is more friendly to test verification when the overall style of the page does not change much but small changes are made continuously. In addition, some key local modifications in the page can be judged and tested through assertion test rules to better meet the test requirements.
[0104] In the above embodiment, assertions are divided into two categories: page style assertions and detail assertions. The former uses the image recognition model to identify the page style as an assertion, and the latter is local text assertions and picture assertions, etc. The page style assertion plus detail type assertion proposed in this embodiment performs assertion checking, which can effectively reduce the false positives of mobile test cases and reduce the maintenance cost of the case.
[0105] Figure 5 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0106] refer to Figure 5 , the above assertion testing method may include the following steps.
[0107] Step S502, obtaining automated test cases.
[0108] The target application can be automatically tested through the above automated test cases to determine whether the target application can achieve the expected function.
[0109] Step S504: testing the target application according to the automated test case.
[0110] Step S506: Determine, according to the automated test case, that the target application has reached the current page, and then obtain the current page.
[0111] During the automated testing process, if it is determined that the page of the target application is reached, that is, if it is determined that the target application displays a page during the automated testing process, the page is obtained as the current page.
[0112] Step S508, comparing the current page with the previous frame page of the current page.
[0113] Step S510: If the current page is the same as the previous frame page, it is determined that the current page fails to appear normally, and it is determined that the target application fails the first assertion test.
[0114] Step S512: If the current page is different from the previous frame page, the current page is processed by the page type determination network model to continue to determine whether the target application passes the first assertion test.
[0115] In some embodiments, when the current page is obtained, the current page can be compared with the previous frame page of the current page. If the current page is the same as the previous frame page, it is determined that the current page fails to appear normally, and it is determined that the target application fails to pass the first assertion test; if the current page is different from the previous frame page, the current page is processed by the trained page type judgment network model to continue to determine whether the target application passes the first assertion test.
[0116] It is easy to understand that in the target application, the two frames of the page displayed should be different. If the two frames of the page displayed before and after are exactly the same during the test, it is determined that the latter frame of the page does not appear normally, then it can be determined that the application is abnormal.
[0117] Through the technical solution provided by the above embodiment, it is possible to determine whether an abnormality occurs in the current page in a relatively simple and rapid manner.
[0118] Figure 6 The figure is a flowchart of an assertion testing method according to an exemplary embodiment.
[0119] refer to Figure 6 , the above assertion testing method may include the following steps.
[0120] Step S602, obtaining a target network to be trained.
[0121] Step S604, obtaining the page to be trained and the page type corresponding to the page to be trained.
[0122] Step S606: training the target network using the to-be-trained page and the page type corresponding to the to-be-trained page to obtain a page type determination network model.
[0123] In some embodiments, the target network can be constructed using mature deep convolutional models, such as VGG (Visual Geometry Group), ALEXNET (a deep network model proposed by Alex Krizhevsky), RESNET (Residual Network), etc. For example, a residual network can be used for construction.
[0124] In some embodiments, transfer learning can be used to train the target network. For example, the convolutional layer and pooling layer of feature extraction can be solidified, and only the fully connected layer can be trained. Individualized training can also be performed layer by layer. Depending on the amount of data and hardware resources, 50 layers, 101 layers, 152 layers, etc. can be used for training. This embodiment will not be described in detail.
[0125] In some embodiments, after the target network is trained, the page type can be judged. The input is a picture, which is then substituted into the model and its classification is output. If it is consistent with the expected page type of the page, the assertion passes, otherwise the assertion fails.
[0126] In some embodiments, the test case enters a new page and first performs a page style assertion. If the page does not match the expected type, it fails without performing any detail assertions. If the page is consistent with the expected type, it continues to perform detail assertions through rules (such as asserting whether the page includes key content and whether the key content is in a specified location).
[0127] Figure 7 The figure is a flowchart of a network model training method according to an exemplary embodiment.
[0128] refer to Figure 7 , the above network model training method may include the following steps.
[0129] Step S702, determining the pixel mean and pixel standard deviation of the page to be trained.
[0130] Step S704 , normalizing each to-be-trained page by using the pixel mean and the pixel standard deviation to obtain a normalized vector set corresponding to each to-be-trained page.
[0131] Step S706 , training the target network using the normalized vector sets and page types corresponding to each to-be-trained page to obtain a page type judgment network model.
[0132] In some embodiments, the application pages may be different on different models, different operating systems, and different resolutions. To facilitate subsequent analysis, this embodiment pre-processes all the pages to be trained so that the page data can be unified.
[0133] In some embodiments, the page of the current page can be normalized by the following method: determine the pixel mean and pixel standard deviation of each current page to be trained; normalize each current page to be trained by the pixel mean and pixel standard deviation to obtain a normalized vector set corresponding to each current page to be trained; perform page type judgment processing on the normalized vector set corresponding to each current page to be trained by a page type judgment network model to determine the predicted page type of each current page and train the target network by page type to obtain a page type judgment network model.
[0134] Next, page image normalization will be explained in detail.
[0135] 1. First, calculate the mean (mean of pixels) and standard deviation (such as standard deviation of pixels) of the images of all pages to be trained.
[0136] 2. Then scale the page image of the page to be trained to the specified size, such as 255*255, 1024*786, etc.; in view of the slight differences in color resolution between high-end models and mid-to-low-end models, perform data enhancement on the brightness, contrast value, saturation, and hue of the image. Since the images are all on the mobile phone, there is no horizontal or vertical flipping, tilt change, etc.
[0137] 3. Finally, perform unified normalization processing. For example, the pixel value at a pixel point can be subtracted from the pixel mean and then divided by the pixel standard deviation to obtain the normalized vector of the pixel point. Then the vectors corresponding to all pixels in a page image constitute the normalized vector set corresponding to the page image.
[0138] The above method can be used to normalize the training page or the current page to reduce the impact of different display effects of pages on different models on the test results.
[0139] It should be particularly pointed out that the various steps in the various embodiments of the above assertion test method can be mutually crossed, replaced, added, or deleted. Therefore, these reasonable permutations and combinations of the assertion test method should also fall within the protection scope of the present disclosure, and the protection scope of the present disclosure should not be limited to the embodiments.
[0140] Based on the same inventive concept, the present disclosure also provides an assertion test device, such as the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0141] Figure 8 is a block diagram of an assertion testing device according to an exemplary embodiment. Figure 8 The assertion testing device 800 provided in the embodiment of the present disclosure may include: a current page acquisition module 801, a page type determination module 802, an expected page type acquisition module 803 and a test pass determination module 804.
[0142] Among them, the current page acquisition module 801 can be used to obtain the current page when the current page is reached; the page type judgment module 802 can be used to perform page type judgment processing on the current page through the page type judgment network model to determine the predicted page type of the current page; the expected page type acquisition module 803 can be used to obtain the expected page type corresponding to the current page; the test pass judgment module 804 can be used to determine that the current page passes the first assertion test if the predicted page type is the same as the expected page type.
[0143] It should be noted that the above-mentioned current page acquisition module 801, page type determination module 802, expected page type acquisition module 803 and test pass determination module 804 correspond to S202 to S208 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules and corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules as part of the device can be executed in a computer system such as a set of computer executable instructions.
[0144] In some embodiments, the test pass judgment module 804 may include: an assertion test rule acquisition submodule, a target key information determination submodule, a key information inclusion submodule, and a key information exclusion submodule.
[0145] Among them, the assertion test rule acquisition submodule can be used to obtain the assertion test rules corresponding to the current page; the target key information determination submodule can be used to determine whether the current page includes the target key information according to the assertion test rules; the key information includes submodule can be used to determine that if the current page includes the target key information, then the current page passes the second assertion test; the key information does not include submodule can be used to determine that if the current page does not include the target key information, then the current page fails the second assertion test.
[0146] In some embodiments, the target key information determination submodule may include: a designated area judgment unit.
[0147] The designated area determination unit may be used to determine whether the current page includes target key information according to the assertion test rule, and determine whether the target key information appears in the designated area.
[0148] Among them, the key information includes sub-modules that may include: a designated area appearance unit.
[0149] The designated area appearance unit may be used to determine, according to the assertion test rule, that the current page includes target key information and the target key information appears in the designated area, and then determine that the current page passes the second assertion test.
[0150] Among them, the key information not including the submodule may include: no unit appears in the specified area.
[0151] The designated area non-appearance unit may be used to determine, according to the assertion test rule, that the current page does not include the target key information or the target key information does not appear in the designated area, and then determine that the current page fails the second assertion test.
[0152] In some embodiments, the assertion testing apparatus 800 may further include: a fail judgment module.
[0153] The failure judgment module may be used to determine that the current page fails the first assertion test if the predicted page type is different from the expected page type.
[0154] In some embodiments, the method further includes: an automated test case acquisition module and a testing module.
[0155] Among them, the automated test case acquisition module can be used to acquire automated test cases; and the testing module can be used to test the target application according to the automated test cases.
[0156] Among them, the current page acquisition module 801 may include: a current page access sub-module.
[0157] Among them, the current page reaching submodule can be used to determine whether the target application reaches the current page based on the automated test case.
[0158] The page type determination module 802 may include: a comparison submodule, a sameness determination submodule and a differentness determination submodule.
[0159] Among them, the comparison submodule can be used to compare the current page with the previous frame page of the current page; the same judgment submodule can be used to determine that the current page fails to appear normally if the current page is the same as the previous frame page, and then determine that the target application has not passed the first assertion test; the different judgment submodule can be used to process the current page through the page type judgment network model if the current page is different from the previous frame page, so as to continue to determine whether the target application has passed the first assertion test.
[0160] In some embodiments, the assertion testing apparatus 800 may further include: a target network acquisition module, a to-be-trained page acquisition module, and a training module.
[0161] Among them, the target network model acquisition module can be used to obtain the target network to be trained; the page to be trained acquisition module can be used to obtain the page to be trained and the page type corresponding to the page to be trained; the training module can be used to train the target network through the page to be trained and the page type corresponding to the page to be trained to obtain a page type judgment network model.
[0162] In some embodiments, the training module may include: a mean value determination submodule, a normalization processing submodule, and a training submodule.
[0163] Among them, the mean determination submodule can be used to determine the pixel mean and pixel standard deviation of the page to be trained; the normalization processing submodule can be used to normalize each page to be trained through the pixel mean and pixel standard deviation to obtain a normalized vector set corresponding to each page to be trained; the training submodule can be used to train the target network through the normalized vector set and page type corresponding to each page to be trained to obtain a page type judgment network model.
[0164] Since the functions of the device 800 have been described in detail in the corresponding method embodiments, the present disclosure will not elaborate on them here.
[0165] The modules and / or submodules and / or units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The modules and / or submodules and / or units described may also be arranged in a processor. The names of these modules and / or submodules and / or units do not, in certain circumstances, constitute limitations on the modules and / or submodules and / or units themselves.
[0166] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a part of a module or program segment, and a part of the above-mentioned module or program segment contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer program instructions.
[0167] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0168] Fig. 9 FIG. 1 shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure. It should be noted that: Fig. 9 The electronic device 900 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0169] like Fig. 9 As shown, the electronic device 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0170] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0171] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains computer program instructions for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 909, and / or installed from a removable medium 911. When the computer program is executed by a central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present disclosure are executed.
[0172] It should be noted that the computer-readable storage medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable computer program instructions. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The computer program instructions contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0173] As another aspect, the present disclosure also provides a computer-readable storage medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed by a device, the device can implement functions including: obtaining the current page when the current page is touched; performing page type judgment processing on the current page through the page type judgment network model to determine the predicted page type of the current page; obtaining the expected page type corresponding to the current page; if the predicted page type is the same as the expected page type, determining that the current page passes the first assertion test.
[0174] According to one aspect of the present disclosure, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer program instructions, the computer program instructions being stored in a computer-readable storage medium. The computer program instructions are read from the computer-readable storage medium, and a processor executes the computer program instructions to implement the methods provided in various optional implementations of the above embodiments.
[0175] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of computer program instructions for enabling an electronic device (which can be a server or a terminal device, etc.) to execute the method according to the embodiment of the present disclosure.
[0176] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and embodiments are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0177] It should be understood that the present disclosure is not limited to the detailed structures, drawings or implementations shown herein, but rather the present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. An assertion testing method, characterized in that: include: When the current page is reached, obtaining the current page; Performing page type determination processing on the current page through a page type determination network model to determine a predicted page type of the current page; Obtaining the expected page type corresponding to the current page; If the predicted page type is the same as the expected page type, then it is determined that the current page passes a first assertion test.
2. The method according to claim 1, characterized in that: After determining that the current page passes the first assertion test, the method further includes: Obtain the assertion test rules corresponding to the current page; Determine whether the current page includes target key information according to the assertion test rule; If the current page includes the target key information, determining that the current page passes a second assertion test; If the current page does not include the target key information, it is determined that the current page fails the second assertion test.
3. The method according to claim 2, characterized in that: Determining whether the current page includes target key information according to the assertion test rule includes: Determining whether the current page includes target key information according to the assertion test rule, and judging whether the target key information appears in a designated area; If the current page includes the target key information, determining that the current page passes the second assertion test includes: If it is determined according to the assertion test rule that the current page includes the target key information and the target key information appears in the designated area, then it is determined that the current page passes the second assertion test; If the current page does not include the target key information, determining that the current page fails the second assertion test includes: If it is determined according to the assertion test rule that the current page does not include the target key information and / or the target key information does not appear in the designated area, it is determined that the current page fails the second assertion test.
4. The method according to claim 1, characterized in that: The method further comprises: If the predicted page type is not the same as the expected page type, it is determined that the current page fails the first assertion test.
5. The method according to claim 1, characterized in that: The method further comprises: Get automated test cases; Testing the target application according to the automated test case; When the current page is reached, obtaining the current page includes: Determine, according to the automated test case, that the target application reaches the current page, and obtain the current page; The page type determination process is performed on the current page by using a page type determination network model to determine the predicted page type of the current page, including: Compare the current page with the previous frame page of the current page; If the current page is the same as the previous frame page, it is determined that the current page fails to appear normally, and it is determined that the target application fails the first assertion test; If the current page is different from the previous frame page, the current page is processed by the page type determination network model to continue determining whether the target application passes the first assertion test.
6. The method according to claim 1, characterized in that: The method further comprises: Get the target network to be trained; Obtain a page to be trained and a page type corresponding to the page to be trained; The target network is trained using the to-be-trained page and the page type corresponding to the to-be-trained page to obtain the page type determination network model.
7. The method according to claim 6, characterized in that: Performing page type determination processing on the current page through a page type determination network model to determine a predicted page type of the current page includes: Determine the pixel mean and pixel standard deviation for each current page; Normalizing each current page by using the pixel mean and the pixel standard deviation to obtain a normalized vector set corresponding to each current page; The page type judgment network model is used to perform page type judgment processing on the normalized vector set corresponding to each current page to determine the predicted page type of each current page.
8. An assertion testing device, characterized in that: include: A current page acquisition module, used to acquire the current page when the current page is reached; A page type judgment module, used to perform page type judgment processing on the current page through a page type judgment network model to determine the predicted page type of the current page; An expected page type acquisition module is used to acquire the expected page type corresponding to the current page; The test pass judgment module is used to determine whether the current page passes a first assertion test if the predicted page type is the same as the expected page type.
9. An electronic device, characterized in that: include: Memory and processor; The memory is used to store computer program instructions; the processor calls the computer program instructions stored in the memory to implement the assertion testing method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the assertion testing method according to any one of claims 1 to 7 is implemented.
