CN116303050A - Test method and device - Google Patents
Test method and device Download PDFInfo
- Publication number
- CN116303050A CN116303050A CN202310286628.1A CN202310286628A CN116303050A CN 116303050 A CN116303050 A CN 116303050A CN 202310286628 A CN202310286628 A CN 202310286628A CN 116303050 A CN116303050 A CN 116303050A
- Authority
- CN
- China
- Prior art keywords
- image
- test
- function
- interface
- page
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000010998 test method Methods 0.000 title claims abstract description 8
- 238000012360 testing method Methods 0.000 claims abstract description 233
- 230000006870 function Effects 0.000 claims description 144
- 230000004044 response Effects 0.000 claims description 54
- 238000000034 method Methods 0.000 claims description 49
- 230000005856 abnormality Effects 0.000 claims description 11
- 230000002159 abnormal effect Effects 0.000 claims description 8
- 238000004422 calculation algorithm Methods 0.000 claims description 6
- 230000001960 triggered effect Effects 0.000 claims description 4
- 238000004590 computer program Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000007257 malfunction Effects 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000644 propagated effect Effects 0.000 description 1
- 238000012549 training Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application discloses a test method, comprising the following steps: and acquiring a test case corresponding to a first test task, wherein the first test task is used for testing the first function. And running the test case to obtain a test image, wherein the test image comprises first page content of a page corresponding to the first function. And acquiring standard images corresponding to the first function and image comparison configuration information, wherein the standard images comprise second page contents of pages corresponding to the first function. After the test image, the standard image and the image comparison configuration information are obtained, the test image and the standard image can be compared according to the image comparison configuration information, and a test result aiming at the first function is obtained. By utilizing the scheme, when the standard image and the test image are compared, the configuration information can be compared by combining the images, so that the obtained test result aiming at the first function is more accurate.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a testing method and apparatus.
Background
With the development of computer technology, more and more applications are emerging that can provide a wide variety of functions. Before the application is released, the application needs to be tested, so that the application can provide corresponding functions for users stably.
When an application is tested, if an accurate test result is obtained, the problem which is still to be solved at present is solved.
Disclosure of Invention
In order to solve or at least partially solve the above technical problems, a test method is provided in an embodiment of the present application.
In a first aspect, embodiments of the present application provide a test method, where the method includes:
acquiring a test case corresponding to a first test task, wherein the first test task is used for testing a first function;
running the test case to obtain a test image, wherein the test image comprises first page content of a page corresponding to the first function;
acquiring a standard image corresponding to the first function and image comparison configuration information, wherein the standard image comprises second page content of a page corresponding to the first function;
and comparing the test image with the standard image according to the image comparison configuration information to obtain a test result aiming at the first function.
Optionally, the image comparison configuration information includes an image comparison exemption area, and the comparing the test image with the standard image according to the image comparison configuration information includes:
And comparing a first area except the image comparison exemption area in the test image with a second area except the image comparison exemption area in the standard image according to the image comparison exemption area.
Optionally, the standard image and the test image are both images processed by an antialiasing algorithm.
Optionally, the test case corresponding to the first test task is generated based on the history data of the first function, where the history data of the first function includes: the standard image is an image corresponding to the history data for the operation of the first function and the response made for the operation.
Optionally, the page corresponding to the first function includes a first page element, the test case includes at least one element selector corresponding to the first page element, and the running the test case obtains a test image, including:
determining a target element selector from the at least one element selector;
and obtaining the test image comprising the first page element according to the target element selector.
Optionally, the second page content includes first content, where the first content is obtained by:
Operating the test case to obtain a first request message sent to a first interface;
obtaining a first response message aiming at the first request message based on pre-stored information, wherein the pre-stored information is obtained according to response data returned by the first interface aiming at the historical data of the first function;
and obtaining the first content according to the first response message.
Optionally, the second page content includes second content, where the second content is obtained by:
operating the test case to obtain a second request message sent to a second interface;
transmitting the second request message to the second interface in response to the second interface being set as an exempt interface;
receiving a second response message returned by the second interface aiming at the second request message;
and obtaining the second content according to the second response message.
Optionally, the method further comprises:
setting an interface for displaying interface exemption;
and receiving interface exemption operation triggered by the second interface in the interface exemption setting interface, and setting the second interface as an exemption interface.
Optionally, comparing a first area except the image comparison exemption area in the test image with a second area except the image comparison exemption area in the standard image to obtain a test result aiming at the first function, including:
If the first area and the second area are completely consistent, determining that the first function is normal;
or,
and if the first area and the second area are not completely consistent, determining that the first function is abnormal.
Optionally, the method further comprises:
and if the first area and the second area are not completely consistent, outputting the difference content of the test image and the standard image.
Optionally, the method further comprises:
and if the first area and the second area are not completely consistent, determining the abnormality reason of the first function according to the test image and the standard image.
In a second aspect, embodiments of the present application provide a test apparatus, the apparatus including:
the first acquisition unit is used for acquiring a test case corresponding to a first test task, wherein the first test task is used for testing a first function;
the running unit is used for running the test case to obtain a test image, and the test image comprises first page content of a page corresponding to the first function;
a second obtaining unit, configured to obtain a standard image corresponding to the first function and image comparison configuration information, where the standard image includes second page content of a page corresponding to the first function;
And the comparison unit is used for comparing the test image with the standard image according to the image comparison configuration information to obtain a test result aiming at the first function.
Optionally, the image comparison configuration information includes an image comparison exemption area, and the comparison unit is configured to:
and comparing a first area except the image comparison exemption area in the test image with a second area except the image comparison exemption area in the standard image according to the image comparison exemption area.
Optionally, the standard image and the test image are both images processed by an antialiasing algorithm.
Optionally, the test case corresponding to the first test task is generated based on the history data of the first function, where the history data of the first function includes: the standard image is an image corresponding to the history data for the operation of the first function and the response made for the operation.
Optionally, the page corresponding to the first function includes a first page element, the test case includes at least one element selector corresponding to the first page element, and the running unit is configured to:
Determining a target element selector from the at least one element selector;
and obtaining the test image comprising the first page element according to the target element selector.
Optionally, the second page content includes first content, where the first content is obtained by:
operating the test case to obtain a first request message sent to a first interface;
obtaining a first response message aiming at the first request message based on pre-stored information, wherein the pre-stored information is obtained according to response data returned by the first interface aiming at the historical data of the first function;
and obtaining the first content according to the first response message.
Optionally, the second page content includes second content, where the second content is obtained by:
operating the test case to obtain a second request message sent to a second interface;
transmitting the second request message to the second interface in response to the second interface being set as an exempt interface;
receiving a second response message returned by the second interface aiming at the second request message;
and obtaining the second content according to the second response message.
Optionally, the apparatus further includes:
the display unit is used for displaying the interface exemption setting interface;
and the setting unit is used for receiving interface exemption operation triggered by the second interface in the interface exemption setting interface and setting the second interface as an exemption interface.
Optionally, the comparing unit is configured to:
if the first area and the second area are completely consistent, determining that the first function is normal;
or,
and if the first area and the second area are not completely consistent, determining that the first function is abnormal.
Optionally, the apparatus further includes:
and the output unit is used for outputting the difference content of the test image and the standard image if the first area and the second area are not completely consistent.
Optionally, the apparatus further includes:
and the determining unit is used for determining the reason of the abnormality of the first function according to the test image and the standard image if the first area and the second area are not completely consistent.
In a third aspect, embodiments of the present application provide an apparatus comprising a processor and a memory;
the processor is configured to execute instructions stored in the memory to cause the apparatus to perform the method of any one of the first aspects above.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, including instructions that instruct a device to perform the method of any one of the first aspect above.
In a fifth aspect, embodiments of the present application provide a computer program product which, when run on a computer, causes the computer to perform the method of any one of the first aspects above.
Compared with the prior art, the embodiment of the application has the following advantages:
the embodiment of the application provides a testing method, which comprises the following steps: and acquiring a test case corresponding to the first test task, wherein the first test case is used for testing the first function. After the test case is acquired, the test case can be operated to obtain a test image, wherein the test image comprises first page content of a page corresponding to the first function. And, standard images and image comparison configuration information corresponding to the first function can be obtained, wherein the standard images comprise second page contents of pages corresponding to the first function. The second page content may be considered as page content displayed on a page corresponding to the first page when the first function is normal, and the standard image may be considered as a page image corresponding to the first function when the first function is normal. After obtaining the test image, the standard image and the image comparison configuration information, the test image and the standard image can be compared according to the image comparison configuration information, and a test result aiming at the first function is obtained. Therefore, by utilizing the scheme of the embodiment of the application, when the standard image and the test image are compared, the configuration information can be compared by combining the images, so that the obtained test result aiming at the first function is more accurate.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a test method according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating a method for determining a page selector according to an embodiment of the present disclosure;
fig. 3 is a flow chart of a method for determining first content according to an embodiment of the present application;
fig. 4 is a flow chart of a method for determining second content according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a testing device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will clearly and completely describe the technical solution in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
Various non-limiting embodiments of the present application are described in detail below with reference to the attached drawing figures.
Exemplary method
Referring to fig. 1, a flow chart of a testing method according to an embodiment of the present application is shown. In this embodiment, the test method shown in fig. 1 may be applied to a test platform, for example.
In one example, the method may include, for example, the steps of: S101-S104.
S101: and acquiring a test case corresponding to a first test task, wherein the first test task is used for testing a first function.
In this embodiment of the present application, the first test task is used to test the first function, which is not specifically limited in this embodiment of the present application, and the first function may be determined according to an actual situation. As an example, the first function may be, for example, a function corresponding to a control in the test page. For example, after a control is tested to trigger, whether the page is correctly jumped, and for example, after a control is tested to trigger, whether the corresponding interface (e.g., popup) is correctly presented.
In the embodiment of the present application, the test case corresponding to the first test task may be guaranteed in the test platform in advance. The test cases mentioned here are understood to be test codes.
In one example, the test case corresponding to the first test task is generated based on the historical data of the first function, where the historical data of the first function includes: an operation for the first function and a response to the operation. For example, if the first function is a function corresponding to a test target control, the operation for the first function may be clicking on the target control, and the response for the operation may be: a request message is sent to an interface.
S102: and running the test case to obtain a test image, wherein the test image comprises first page content of a page corresponding to the first function.
After the test case is obtained, the test case can be operated, and a test image corresponding to the test case is obtained. In this case, after the test case is executed, the page corresponding to the first function may be generated, and the screenshot is further performed on the page corresponding to the first function to obtain the test image, so that after the test case is executed, the obtained test image includes the first page content of the page corresponding to the first function. The embodiment of the application is not particularly limited to the page corresponding to the first function, and the page corresponding to the first function may be determined according to actual conditions.
In one example, the page corresponding to the first function includes a first page element, and when the page corresponding to the first function is generated, an element selector of the first page element may be combined to determine a position of the first page element in the page. In this embodiment of the present application, the test case may include at least one element selector corresponding to a first page element, when the test case is executed and a page corresponding to a first function is generated, a target element selector may be determined from the at least one element selector, and a position of the first page element in the page is determined based on the target element selector, so that a page including the first page element is further obtained, and correspondingly, the page is subjected to screenshot to obtain a test image including the first page element.
In one example, the at least one page element in the test case may include an extensible markup language path language (Extensible Markup Language Path Language, xpath) and/or a selector, which may include an Identifier (ID), a class (class), or a tag (tag).
At least one page element in the test case may be determined, for example, by the process shown in fig. 2. Fig. 2 is a flowchart of a method for determining a page selector according to an embodiment of the present application.
S201: in response to a trigger operation for a first page element, xpath and selector of the first page element are acquired, wherein the selector comprises an ID, a class and a tag.
S202: and storing the Xpath.
S203: it is determined whether the ID is a value after hash calculation.
If not, execution S206: storing the ID and ending the flow.
If yes, S204 is executed.
S204: and judging whether the class is a value after hash calculation.
If not, execution S207: storing the class and ending the flow.
If yes, S205 is executed.
S205: and judging whether the tag is a value after hash calculation.
If not, execution S208: and storing the tag, and ending the flow.
If yes, ending the flow.
The target element selector may be selected from the at least one element selector when the test case is running, for example, if the at least one element selector includes Xpath, the Xpath is determined to be the target element selector, and if the at least one element selector does not include Xpath, the selector is determined to be the target element selector. In one example, the second page content includes a first content, where the first content may be obtained through S301-S303 shown in fig. 3. Fig. 3 is a flowchart of a method for determining a first content according to an embodiment of the present application.
S301: and running the test case to obtain a first request message sent to the first interface.
In this embodiment of the present application, the first interface may be, for example, an interface of a server, and the client may interact with the first interface and determine the page display content according to the interaction result.
S302: and obtaining a first response message aiming at the first request message based on pre-stored information, wherein the pre-stored information is obtained according to response data returned by the first interface aiming at the historical data of the first function.
In the embodiment of the application, after the first request message is obtained, the first request message is not sent to the first interface, but a first response message for the first request message is obtained based on pre-stored information. The pre-stored information is obtained according to response data returned by the first interface for the history data of the first function, for example, the pre-stored data is response data returned by the first interface for the history data of the first function. Illustrating: the history data of the first function includes: the user performs operation 1, the client generates a request 1 in response to operation 1 and transmits the request 1 to the first interface, and the interface 1 returns a response 1 to the request 1, and the pre-stored information may be the response 1.
S303: and obtaining the first content according to the first response message.
After obtaining the first response message, the first content in the page may be determined according to the response message. The embodiment of the present application is not particularly limited to the specific implementation manner of S303, and in an example, the first content may be determined according to a key field in the first response message.
In yet another example, the second page content includes a second content, and the second content may be obtained through S401 to S404 shown in fig. 4. Fig. 4 is a flow chart of a method for determining second content according to an embodiment of the present application.
S401: and running the test case to obtain a second request message sent to a second interface.
In this embodiment of the present application, similar to the first interface, the second interface may be, for example, an interface of a server, and the client may interact with the second interface, and determine the page display content according to the interaction result.
S402: and sending the second request message to the second interface in response to the second interface being set as an exempt interface.
In the embodiment of the application, considering that for a part of interfaces, the response message returned by the interface cannot be simulated according to the historical data, for this case, in order to ensure the test effect of testing the first function, the user may set the interface as an exemption interface. In a specific example, an interface exempt setting interface may be presented, where an interface list may be included in the interface exempt setting interface, and where multiple interfaces may be included in the interface list. The user may set the second interface as an exempt interface in the interface exempt setting interface. Specifically, the user may trigger an interface exemption operation for the second interface in the interface exemption setting interface, and correspondingly, the test platform may set the second interface as an exemption interface in response to the interface exemption operation for the second interface.
In this embodiment of the present application, if the second interface is an exempt interface, the test platform does not determine a response message corresponding to the second request message by using pre-stored information, but sends the second request message to the second interface.
S403: and receiving a second response message returned by the second interface for the second request message.
S404: and obtaining the second content according to the second response message.
Correspondingly, after receiving the second request message, the second interface may return a second response message returned for the second request message, and after receiving the second response message, the test platform may obtain the second content according to the second response message.
The embodiment of the present application is not particularly limited to the specific implementation manner of S404, and in an example, the second content may be determined according to a key field in the second response message.
S103: and acquiring standard images and image comparison configuration information corresponding to the first function, wherein the standard images comprise second page contents of pages corresponding to the first function.
S104: and comparing the test image with the standard image according to the image comparison configuration information to obtain a test result aiming at the first function.
In order to determine whether the first function is normal, a standard image corresponding to the first function can be acquired, and a test result for the first function can be obtained according to the test image and the standard image.
In this embodiment of the present application, the standard image corresponding to the first function may be considered as a page image of a page corresponding to the first function when the first function is normal. In a specific example, when the first function is normal, the content in the page corresponding to the first function is the second page content, and therefore, the standard image includes the second page content of the page corresponding to the first function.
As one example, the standard image may be an image corresponding to the history data including an operation for the first function and a response made to the operation as described above. In one example, after triggering the operation for the first function and the client including the first function responds to the operation, the page content of the page corresponding to the first function is second page content, and the page including the second page content may be subjected to screenshot, so as to obtain the standard image.
In one example, the standard image may be pre-stored in the test platform. Thus, it is possible to acquire the standard image stored in advance, and further determine a test result for the first function based on the standard image and the test image.
In the embodiment of the application, considering that the page of the first function is not stable and unchanged in the display content of some areas, for example, the first area displays the user head portrait, and the user head portrait can be changed. Therefore, the contents of the corresponding areas are inconsistent for the standard image and the test image, and the first functional abnormality cannot be explained. In view of this, in order to be able to accurately obtain a test result for the first function, image comparison configuration information may be configured in advance, and the image comparison configuration information may include a factor that is negligible when comparing a standard image and a test image. In one example, the image comparison configuration information may include an image comparison exemption area, and for example, the area may be set as the image comparison exemption area.
In one example, when the test image and the standard image are compared according to the image comparison configuration information, for example, when the test image and the standard image are compared, a factor indicated by the image comparison configuration information is not considered. In a specific example, the image comparison configuration information includes an image comparison exemption area, and when the test image and the standard image are compared, the image comparison exemption area may not be considered. In other words, in the specific implementation of S104, a first area except the image comparison exemption area in the test image may be compared with a second area except the image comparison exemption area in the standard image, so as to obtain a test result for the first function. For example, the first region and the second region may be compared pixel by pixel, thereby obtaining a test result for the first function.
As one example, if the first region and the second region are completely identical, the first function is determined to be normal, and if the first region and the second region are not completely identical, for example, the similarity of the first region and the second region is 99.9%, the first function is determined to be abnormal. In this way, the test result for the first function can be determined more accurately than in the conventional art in which the similarity threshold (for example, 80%) is set to determine the test result for the first function. This is because, assuming that the similarity threshold is set to 80%, the first function is considered to be normal when the similarity threshold of the test image and the standard image is higher than 80% (for example, 81%), so that factors that cause the test image and the standard image to be different are ignored, and therefore, the similarity threshold is set to determine the test result of the first function, the result of which is not very accurate. In the embodiment of the application, any factors which cause the first area and the second area to be different are not ignored, and the first function is determined to be normal under the condition that the first area and the second area are completely consistent, so that the test result for the first function is accurately determined.
In one example, in order to improve accuracy of the foregoing test result, the standard image may be an image processed by using an antialiasing algorithm, and accordingly, when determining the test result for the first function according to the standard image and the test image, the test image may be first processed by using the antialiasing algorithm to obtain a processed test image, and then, according to the processed test image and the standard image, the test result for the first function is obtained. For example, comparing the first region in the processed test image with the second region in the standard image to obtain a test result for the first function.
In one example, the generating the test case and obtaining the standard image may be implemented by a target module, which is not specifically limited in the embodiments of the present application, and in one example, the target module may be a plug-in, for example, may be a browser plug-in. In one example, the goal module may save the test case and the standard image to a test platform after generating the test case and obtaining the standard image. In addition, the pre-stored information may be sent to the test platform by the target module. As an example, when the user operates the first function, the target module may be turned on, and correspondingly, when the user operates the first function, the target module may generate the test case, obtain the standard image and the pre-stored information, and further send the test case, the standard image and the pre-stored information to the test platform.
As can be seen from the above description, with the solution according to the embodiment of the present application, it is not necessary to manually write a test case by a user as in the conventional technology, but the test case may be generated based on the history data of the first function, and the test case is further operated to test the first function, so that the test efficiency of testing the first function is improved. In a specific example, the user only needs to operate the first function once, and then the target module can generate the test case, obtain the standard image and the pre-stored information, and in a test stage, the test platform can test the first function by using the test case, the standard image and the pre-stored information, so that the test efficiency is high.
As previously described, in one example, the first functional anomaly is determined if the test image and the standard image are not exactly identical. As an example, in case of said first malfunction, the cause of the first malfunction may be determined in order to perform the corresponding handling measures.
In one example, if the first area and the second area are not completely consistent, the test image and the standard image may be output, for example, the test image and the standard image may be correspondingly displayed on a page, so as to determine the cause of the first functional abnormality by adopting a manual analysis manner.
In still another example, if the first area and the second area are not completely consistent, a difference content of the test image and the standard image may be determined, and the difference content may be output, for example, the test image and the standard image may be correspondingly displayed on a page, and the difference content may be displayed in a preset style, so that a cause of the first functional abnormality may be determined by using a manual analysis method. Of course, only the difference content may be displayed, and the complete standard image and the test image are not displayed, which is not particularly limited in the embodiment of the present application.
In yet another example, if the first area and the second image do not completely coincide, the test platform may further determine a cause of the abnormality of the first function according to the test image and the standard image.
The embodiment of the application is not particularly limited to a specific implementation manner that the test platform determines the cause of the abnormality according to the test image and the standard image. In one example, the test platform may first determine an anomaly content between the first region and the second region, and then determine an anomaly cause for the first function based on the anomaly content. For example, the test platform may obtain the abnormal reason of the first function according to a mapping relationship between preset abnormal content and abnormal reason. In yet another example, the test platform may determine the cause of the abnormality of the first function by means of a model, for example, the test image and the standard image may be input to the model, which then outputs the cause of the abnormality of the first function. The structure of the model and the training manner of the model are not particularly limited in the embodiments of the present application.
Exemplary apparatus
Based on the method provided by the embodiment, the embodiment of the application also provides a device, and the device is described below with reference to the accompanying drawings.
Referring to fig. 5, the structure of a testing device according to an embodiment of the present application is shown. The apparatus 500 may specifically include, for example: a first acquisition unit 501, an operation unit 502, a second acquisition unit 503, and an alignment unit 504.
A first obtaining unit 501, configured to obtain a test case corresponding to a first test task, where the first test task is used to test a first function;
the operation unit 502 is configured to operate the test case to obtain a test image, where the test image includes a first page content of a page corresponding to the first function;
a second obtaining unit 503, configured to obtain a standard image corresponding to the first function and image comparison configuration information, where the standard image includes second page content of a page corresponding to the first function;
and a comparison unit 504, configured to compare the test image with the standard image according to the image comparison configuration information, so as to obtain a test result for the first function.
Optionally, the image comparison configuration information includes an image comparison exemption area, and the comparison unit 504 is configured to:
And comparing a first area except the image comparison exemption area in the test image with a second area except the image comparison exemption area in the standard image according to the image comparison exemption area.
Optionally, the standard image and the test image are both images processed by an antialiasing algorithm.
Optionally, the test case corresponding to the first test task is generated based on the history data of the first function, where the history data of the first function includes: the standard image is an image corresponding to the history data for the operation of the first function and the response made for the operation.
Optionally, the page corresponding to the first function includes a first page element, the test case includes at least one element selector corresponding to the first page element, and the running unit 502 is configured to:
determining a target element selector from the at least one element selector;
and obtaining the test image comprising the first page element according to the target element selector.
Optionally, the second page content includes first content, where the first content is obtained by:
Operating the test case to obtain a first request message sent to a first interface;
obtaining a first response message aiming at the first request message based on pre-stored information, wherein the pre-stored information is obtained according to response data returned by the first interface aiming at the historical data of the first function;
and obtaining the first content according to the first response message.
Optionally, the second page content includes second content, where the second content is obtained by:
operating the test case to obtain a second request message sent to a second interface;
transmitting the second request message to the second interface in response to the second interface being set as an exempt interface;
receiving a second response message returned by the second interface aiming at the second request message;
and obtaining the second content according to the second response message.
Optionally, the apparatus further includes:
the display unit is used for displaying the interface exemption setting interface;
and the setting unit is used for receiving interface exemption operation triggered by the second interface in the interface exemption setting interface and setting the second interface as an exemption interface.
Optionally, the comparing unit 504 is configured to:
if the first area and the second area are completely consistent, determining that the first function is normal;
or,
and if the first area and the second area are not completely consistent, determining that the first function is abnormal.
Optionally, the apparatus further includes:
and the output unit is used for outputting the difference content of the test image and the standard image if the first area and the second area are not completely consistent.
Optionally, the apparatus further includes:
and the determining unit is used for determining the reason of the abnormality of the first function according to the test image and the standard image if the first area and the second area are not completely consistent.
Since the apparatus 500 is an apparatus corresponding to the method provided in the above method embodiment, the specific implementation of each unit of the apparatus 500 is the same as the above method embodiment, and therefore, with respect to the specific implementation of each unit of the apparatus 500, reference may be made to the description part of the above method embodiment, and details are not repeated herein.
The embodiment of the application also provides equipment, which comprises a processor and a memory;
The processor is configured to execute instructions stored in the memory to cause the apparatus to perform the method of any one of the method embodiments above.
Referring now to fig. 6, a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present application is shown. The electronic devices in the embodiments of the present application may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistant, personal digital assistants), PADs (portable android device, tablet computers), PMPs (Portable Media Player, portable multimedia players), vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs (televisions), desktop computers, and the like. The electronic device shown in fig. 6 is only an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present application.
As shown in fig. 6, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present application, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present application are performed when the computer program is executed by the processing means 601.
The electronic device provided in the embodiment of the present application and the method provided in the foregoing embodiment belong to the same inventive concept, and technical details not described in detail in the present embodiment can be seen in the foregoing embodiment, and the present embodiment has the same beneficial effects as the foregoing embodiment.
Embodiments of the present application provide a computer readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements a method as described in any of the embodiments above.
It should be noted that the computer readable medium described in the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, a computer-readable signal medium may include a data signal that propagates in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the method described above.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present application may be implemented by software, or may be implemented by hardware. The name of the unit/module is not limited to the unit itself in some cases, and, for example, the voice data acquisition module may also be described as a "data acquisition module".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this application, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Embodiments of the present application provide a computer program product which, when run on a computer, causes the computer to perform the method of any of the above method embodiments.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.
The foregoing description of the preferred embodiments of the present application is not intended to limit the invention to the particular embodiments of the present application, but to limit the scope of the invention to the particular embodiments of the present application.
Claims (14)
1. A method of testing, the method comprising:
acquiring a test case corresponding to a first test task, wherein the first test task is used for testing a first function;
running the test case to obtain a test image, wherein the test image comprises first page content of a page corresponding to the first function;
acquiring a standard image corresponding to the first function and image comparison configuration information, wherein the standard image comprises second page content of a page corresponding to the first function;
and comparing the test image with the standard image according to the image comparison configuration information to obtain a test result aiming at the first function.
2. The method of claim 1, wherein the image comparison configuration information includes an image comparison exemption region, and wherein the comparing the test image with the standard image according to the image comparison configuration information includes:
and comparing a first area except the image comparison exemption area in the test image with a second area except the image comparison exemption area in the standard image according to the image comparison exemption area.
3. The method of claim 1, wherein the standard image and the test image are both images processed using an antialiasing algorithm.
4. The method of claim 1, wherein the test cases corresponding to the first test task are generated based on historical data of the first function, the historical data of the first function comprising: the standard image is an image corresponding to the history data for the operation of the first function and the response made for the operation.
5. The method of claim 1, wherein the page corresponding to the first function includes a first page element, the test case includes at least one element selector corresponding to the first page element, and the running the test case to obtain the test image includes:
determining a target element selector from the at least one element selector;
and obtaining the test image comprising the first page element according to the target element selector.
6. The method of claim 1, wherein the second page content comprises first content, the first content being derived by:
Operating the test case to obtain a first request message sent to a first interface;
obtaining a first response message aiming at the first request message based on pre-stored information, wherein the pre-stored information is obtained according to response data returned by the first interface aiming at the historical data of the first function;
and obtaining the first content according to the first response message.
7. The method of claim 1, wherein the second page content comprises second content, the second content being derived by:
operating the test case to obtain a second request message sent to a second interface;
transmitting the second request message to the second interface in response to the second interface being set as an exempt interface;
receiving a second response message returned by the second interface aiming at the second request message;
and obtaining the second content according to the second response message.
8. The method of claim 7, wherein the method further comprises:
setting an interface for displaying interface exemption;
and receiving interface exemption operation triggered by the second interface in the interface exemption setting interface, and setting the second interface as an exemption interface.
9. The method of claim 2, wherein comparing a first region of the test image other than the image comparison exemption region with a second region of the standard image other than the image comparison exemption region to obtain a test result for the first function comprises:
if the first area and the second area are completely consistent, determining that the first function is normal;
or,
and if the first area and the second area are not completely consistent, determining that the first function is abnormal.
10. The method according to claim 9, wherein the method further comprises:
and if the first area and the second area are not completely consistent, outputting the difference content of the test image and the standard image.
11. The method according to claim 9, wherein the method further comprises:
and if the first area and the second area are not completely consistent, determining the abnormality reason of the first function according to the test image and the standard image.
12. A test apparatus, the apparatus comprising:
the first acquisition unit is used for acquiring a test case corresponding to a first test task, wherein the first test task is used for testing a first function;
The running unit is used for running the test case to obtain a test image, and the test image comprises first page content of a page corresponding to the first function;
a second obtaining unit, configured to obtain a standard image corresponding to the first function and image comparison configuration information, where the standard image includes second page content of a page corresponding to the first function;
and the comparison unit is used for comparing the test image with the standard image according to the image comparison configuration information to obtain a test result aiming at the first function.
13. An apparatus comprising a processor and a memory;
the processor is configured to execute instructions stored in the memory to cause the apparatus to perform the method of any one of claims 1 to 11.
14. A computer readable storage medium comprising instructions that instruct a device to perform the method of any one of claims 1 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310286628.1A CN116303050A (en) | 2023-03-22 | 2023-03-22 | Test method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310286628.1A CN116303050A (en) | 2023-03-22 | 2023-03-22 | Test method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116303050A true CN116303050A (en) | 2023-06-23 |
Family
ID=86792300
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310286628.1A Pending CN116303050A (en) | 2023-03-22 | 2023-03-22 | Test method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116303050A (en) |
-
2023
- 2023-03-22 CN CN202310286628.1A patent/CN116303050A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20220094758A1 (en) | Method and apparatus for publishing video synchronously, electronic device, and readable storage medium | |
CN112684968A (en) | Page display method and device, electronic equipment and computer readable medium | |
CN111459364B (en) | Icon updating method and device and electronic equipment | |
CN112597047A (en) | Test method, test device, electronic equipment and computer readable medium | |
CN110619100B (en) | Method and apparatus for acquiring data | |
CN111596991A (en) | Interactive operation execution method and device and electronic equipment | |
CN111309617A (en) | Application program control method and device, storage medium and electronic equipment | |
CN110865846B (en) | Application management method, device, terminal, system and storage medium | |
CN109634702B (en) | Information prompting method and device, electronic equipment and readable medium | |
CN112954056B (en) | Method and device for processing monitoring data, electronic equipment and storage medium | |
CN111596992B (en) | Navigation bar display method and device and electronic equipment | |
CN111783010B (en) | Webpage blank page monitoring method, device, terminal and storage medium | |
CN113391860B (en) | Service request processing method and device, electronic equipment and computer storage medium | |
CN110674050B (en) | Memory out-of-range detection method and device, electronic equipment and computer storage medium | |
CN111290812B (en) | Display method, device, terminal and storage medium of application control | |
CN116303050A (en) | Test method and device | |
CN113656286A (en) | Software testing method and device, electronic equipment and readable storage medium | |
CN113849416A (en) | Test method, test device, storage medium and electronic equipment | |
CN116266206A (en) | Page display method and device and electronic equipment | |
CN111381813B (en) | Front-end page debugging method and device, computer equipment and storage medium | |
CN113239300B (en) | Data processing method and device and electronic equipment | |
CN115860573B (en) | Highway engineering detection method based on detection item, electronic equipment and readable medium | |
CN113220293B (en) | Page display method, page display device, electronic equipment and computer readable medium | |
CN111857879B (en) | Data processing method, device, electronic equipment and computer readable medium | |
CN111367555B (en) | Assertion method, assertion device, electronic equipment and computer readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |