CN110704304B - Application program testing method and device, storage medium and server - Google Patents

Application program testing method and device, storage medium and server Download PDF

Info

Publication number
CN110704304B
CN110704304B CN201910840701.9A CN201910840701A CN110704304B CN 110704304 B CN110704304 B CN 110704304B CN 201910840701 A CN201910840701 A CN 201910840701A CN 110704304 B CN110704304 B CN 110704304B
Authority
CN
China
Prior art keywords
variable
application program
value
tested
test
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.)
Active
Application number
CN201910840701.9A
Other languages
Chinese (zh)
Other versions
CN110704304A (en
Inventor
胡鹏强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201910840701.9A priority Critical patent/CN110704304B/en
Publication of CN110704304A publication Critical patent/CN110704304A/en
Application granted granted Critical
Publication of CN110704304B publication Critical patent/CN110704304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test 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 invention relates to the technical field of computers, and provides an application program testing method, an application program testing device, a storage medium and a server. The test method comprises the following steps: acquiring an application program to be tested and a pre-written test script; running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page; capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested; extracting the numerical value of the target page element and storing the numerical value in a first variable; sending an interface calling request to a background server of the application program to be tested based on a preset testing framework; receiving a return value of the interface calling request, and storing the return value in a second variable; and if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test.

Description

Application program testing method and device, storage medium and server
Technical Field
The invention relates to the technical field of computers, in particular to an application program testing method, an application program testing device, a storage medium and a server.
Background
In the process of testing the application program, in order to save manpower, time or hardware resources and improve the testing efficiency, the test behavior driven by human will be generally converted into machine execution, that is, an automated test is executed. Currently, an application test generally includes a plurality of tests of different levels, such as a unit test, an interface test, a UI test, and the like, however, the tests of different levels are usually executed independently in the industry, an application scenario is relatively single, and flexibility is low when a test case is developed.
Disclosure of Invention
In view of this, embodiments of the present invention provide an application program testing method, an application program testing device, a storage medium, and a server, which can combine an interface test and a UI test for execution, so as to enrich application scenarios of the application program test and improve flexibility of developing test cases.
In a first aspect of the embodiments of the present invention, a method for testing an application program is provided, including:
acquiring an application program to be tested and a pre-compiled test script;
running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
capturing a target page element in an element positioning mode in the process of executing page operation by the application program to be tested, wherein the target page element is determined according to the attribute of the operation page;
extracting the numerical value of the target page element, and storing the numerical value in a first variable;
sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page;
receiving a return value of the interface calling request, and storing the return value in a second variable;
and if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test.
In a second aspect of the embodiments of the present invention, an application program testing apparatus is provided, including:
the test script acquisition module is used for acquiring an application program to be tested and a pre-written test script;
the test script running module is used for running the test script, and the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
the page element capturing module is used for capturing a target page element in an element positioning mode in the process of executing page operation by the application program to be tested, and the target page element is determined according to the attribute of the operation page;
the numerical value extraction module is used for extracting the numerical value of the target page element and storing the numerical value in a first variable;
the interface calling triggering module is used for sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page;
a return value receiving module, configured to receive a return value of the interface call request, and store the return value in a second variable;
and the test judgment module is used for determining that the application program to be tested passes the test if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison.
In a third aspect of the embodiments of the present invention, a computer-readable storage medium is provided, where computer-readable instructions are stored, and when executed by a processor, implement the steps of the application program testing method as set forth in the first aspect of the embodiments of the present invention.
In a fourth aspect of the embodiments of the present invention, there is provided a server, including a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, where the processor executes the computer readable instructions to implement the steps of the application program testing method as set forth in the first aspect of the embodiments of the present invention.
The application program testing method provided by the embodiment of the invention comprises the following steps: acquiring an application program to be tested and a pre-written test script; running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page; capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested; extracting the numerical value of the target page element, and storing the numerical value in a first variable; sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page; receiving a return value of the interface calling request, and storing the return value in a second variable; and if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test. Through the arrangement, when the test of certain page operation of the application program to be tested is executed, on one hand, the test value of the UI test is extracted and stored in the first variable in an element positioning mode, on the other hand, the return value of the interface test corresponding to the test value is extracted and stored in the second variable, and finally, the application program test is completed by comparing the numerical values in the two variables, so that the combination of the interface test and the UI test is realized, the application scenes of the application program test can be enriched, and the flexibility of developing test cases is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of a first embodiment of an application testing method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a second embodiment of a method for testing an application according to the present invention;
FIG. 3 is a block diagram of one embodiment of an application test device provided by embodiments of the present invention;
fig. 4 is a schematic diagram of a server according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides an application program testing method, an application program testing device, a storage medium and a server, which can combine interface testing and UI testing for execution, thereby enriching application scenes of application program testing and improving the flexibility of developing testing cases.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a first embodiment of an application program testing method according to an embodiment of the present invention includes:
101. acquiring an application program to be tested and a pre-written test script;
firstly, an application program to be tested and a pre-written test script are obtained, wherein the test script can be written by adopting Python, java and other languages and is used for controlling the application program to be tested to execute certain UI page operation (such as registration or login operation on a webpage).
102. Running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
and then, running the test script, where the test script is used to control the application program to be tested to open an operation page and execute a page operation indicated by the test script on the operation page, for example, opening an information browsing interface of an application program, and then executing a page operation such as clicking a certain interface key. The essence of step 102 is to operate the browser through code, instead of manually, to simulate those cases of page operation. For example, a user can open a login website on a browser, input an account and a password, click a login case, and check whether login is successful, for this case, manual operation can be replaced by a code, and a test script is used to realize page operations such as opening the website, inputting the account and the password, clicking login, checking whether login is successful, and the like, which is a UI automation case.
Specifically, a selenium tool may be called to execute the test script, so that the application program to be tested executes a corresponding page operation. The Selenium is a tool for testing Web application programs and can directly run in a browser just like a real user operates. The main functions of this tool include: testing compatibility with browsers-testing your application to see if it works well on different browsers and operating systems. Testing system function-creating regression testing verification software function and user requirements.
103. Capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested;
and capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested. The element positioning modes such as css positioning, xpath positioning, id positioning and the like can position and capture various page elements in the application program page. The target page element, which is generally a check point of the UI test case, may be determined according to the attribute of the operation page. If the operation page belongs to a page for user login, after the application login, whether the login is successful needs to be detected, then the detection can be completed by checking whether a text word of "welcome you" exists on the login page, that is, the text on the operation page is the target page element.
104. Extracting the numerical value of the target page element, and storing the numerical value in a first variable;
after the target page element is captured, extracting the numerical value of the target page element, and storing the numerical value in a variable. Generally, the target page elements are div, span, table, tr, and td, and the value values of these elements are extracted and stored in some variable.
105. Based on a preset test framework, sending an interface calling request to a background server of the application program to be tested;
then, based on a preset test framework, sending an interface call request to a background server of the application program to be tested, wherein the interface call request is used for acquiring the page elements of the operation page. In actual operation, the test framework can be a testng test framework, and the testng is an open-source automatic test framework, so that the limitation of most old frameworks is eliminated, and developers can write more flexible and powerful tests. The above process is equivalent to an automatic case for initiating an interface test, for example, an account aaa, a password 123, and a confirmation password 123 are transmitted to an interface of the registration function, and then an interface call request is initiated to obtain each page element on the page of the registration operation. Specifically, the interface call request can be sent by using a method of a java-owned httpclient package.
106. Receiving a return value of the interface calling request, and storing the return value in a second variable;
after sending the interface call request, waiting for receiving a return value of the interface call request and storing the return value in another variable.
107. Judging whether the numerical value of the first variable is consistent with the numerical value of the second variable in comparison;
and then, comparing the numerical value of the first variable with the numerical value of the second variable, and judging whether the numerical values are compared and consistent.
Further, the numerical alignment process of the first variable and the second variable may include:
(1) respectively extracting the numerical value of the first variable and the numerical value of the second variable;
(2) and comparing the extracted value of the first variable with the value of the second variable by adopting an assertEquals method of a testng framework.
The assertEquals method is an assertion that is used primarily during code development and testing for the purpose of judging certain critical data, and if this critical data is not what the program expects, the program will issue a warning or exit.
Specifically, the comparing the extracted value of the first variable with the extracted value of the second variable may include:
(2.1) detecting whether the value of the first variable is included in the respective values of the second variable;
(2.2) if the values of the second variable include the value of the first variable, determining that the value of the first variable is consistent with the value of the second variable in comparison;
(2.3) if the numerical values of the first variable are not contained in the numerical values of the second variable, judging that the numerical value of the first variable is inconsistent with the numerical value of the second variable in comparison.
The first variable is a numerical value of a target page element, the second variable is a numerical value of each page element contained in an operation page where the target page element is located, if the target page element is a word "welcome you" in a page, the obtained return value contains each text data displayed by the page, namely the word "welcome you" should be contained, during comparison, whether the second variable contains the text numerical value of "welcome you" is judged, if yes, the numerical values are compared in a consistent mode, and if not, the numerical values are compared in a inconsistent mode.
If the value of the first variable is consistent with the value of the second variable in comparison, step 108 is executed, and if the value of the first variable is inconsistent with the value of the second variable in comparison, step 109 is executed.
108. Determining that the application program to be tested passes the test;
and comparing the numerical value of the first variable with the numerical value of the second variable to be consistent, wherein the results show that the returned values of the UI test and the interface test of the same target page element are consistent, and the results are normal, so that the application program to be tested is determined to pass the test.
109. And determining that the application program to be tested fails to test.
And comparing the numerical value of the first variable with the numerical value of the second variable to be inconsistent, wherein the results are abnormal because the returned values of the UI test and the interface test for the same target page element are different, so that the application program to be tested is determined to fail to be tested.
In addition, according to the scheme, the data of the UI test is stored in the first variable, and the data of the interface test is stored in the second variable, so that a user can extract the data of the UI automation for use in the interface automation and can also extract the data of the interface automation for use in the UI automation, and the development of the automation case can be more flexible. For example, by storing the data of the UI test in a first variable and the data of the interface test in a second variable, when the interface automation test is executed, a numerical value in the first variable may be extracted as an intermediate result, or as a reference value or an evaluation value to design a corresponding test case, thereby improving the design flexibility of the automation test case; similarly, when the UI automatic test is executed, the numerical value in the second variable can be extracted to be used as an intermediate quantity, or used as a reference value or an evaluation value to design a corresponding test case, so that the design flexibility of the automatic test case is improved.
The application program testing method provided by the embodiment of the invention comprises the following steps: acquiring an application program to be tested and a pre-written test script; running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page; capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested; extracting the numerical value of the target page element, and storing the numerical value in a first variable; sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page; receiving a return value of the interface calling request, and storing the return value in a second variable; and if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test. Through the arrangement, when the test of certain page operation of the application program to be tested is executed, on one hand, the test value of the UI test is extracted and stored in the first variable in an element positioning mode, on the other hand, the return value of the interface test corresponding to the test value is extracted and stored in the second variable, and finally, the application program test is completed by comparing the numerical values in the two variables, so that the combination of the interface test and the UI test is realized, the application scenes of the application program test can be enriched, and the flexibility of developing test cases is improved.
Referring to fig. 2, a second embodiment of an application program testing method according to the embodiment of the present invention includes:
201. acquiring an application program to be tested and a pre-written test script;
202. running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
203. capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested;
204. extracting the numerical value of the target page element and storing the numerical value in a first variable;
the steps 201-204 are the same as the steps 101-104, and the related description of the steps 101-104 can be referred to specifically.
205. Comparing the value of the first variable with a pre-stored expected value;
after the numerical values of the target page elements are extracted and stored in a first variable, the numerical values of the first variable are compared with the pre-stored expected numerical values. The pre-stored expectation value, i.e. the expectation value of the target page element, should normally correspond to the value of the first variable. For example, if the expected value is "welcome you", the value of the first variable is compared to determine whether the value is "welcome you" to complete the automated case of UI test. The content of each automation case to be inspected is different, and the corresponding elements to be positioned and inspected are also different, but generally, whether the value values of the elements such as div, span, table, tr, and td are corresponding content is checked.
Further, step 205 may include:
(1) calling a dataProvider tool of the testng framework to read a target file, wherein the target file records expected values of all page elements of the application program to be tested;
(2) and comparing the value of the first variable with the expected value of the target page element recorded in the read target file by adopting an assertEquals method of a testng frame.
Firstly, calling a dataProvider tool of a testng framework to read a target file, wherein the target file is created in advance, and records expected values of each page element of the application program to be tested, and specifically can be an excel file. Then, the value of the first variable is compared with the expected value of the target page element recorded in the read target file by adopting the assertesquares method of the testng framework.
206. Judging whether the numerical value of the first variable is consistent with a pre-stored expected numerical value in a comparison manner;
if the value of the first variable is consistent with the pre-stored expected value, it indicates that the UI test passes, and then step 207 is executed; if the comparison between the value of the first variable and the pre-stored expected value is not consistent, it indicates that the UI test is failed, and step 211 is directly executed.
207. Based on a preset test framework, sending an interface calling request to a background server of the application program to be tested;
208. receiving a return value of the interface calling request, and storing the return value in a second variable;
209. judging whether the numerical value of the first variable is consistent with the numerical value of the second variable in comparison;
if the value of the first variable is consistent with the value of the second variable in comparison, step 210 is executed, and if the value of the first variable is inconsistent with the value of the second variable in comparison, step 211 is executed.
210. Determining that the application program to be tested passes the test;
211. and determining that the application program to be tested fails to test.
The steps 207-211 are the same as the steps 105-109, and the related description of the steps 105-109 can be referred to.
The application program testing method provided by the embodiment of the invention comprises the following steps: acquiring an application program to be tested and a pre-compiled test script; running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page; capturing target page elements in an element positioning mode in the process of executing page operation by the application program to be tested; extracting the numerical value of the target page element, and storing the numerical value in a first variable; comparing the value of the first variable with a pre-stored expected value; if the value of the first variable is consistent with a pre-stored expected value in comparison, sending an interface calling request to a background server of the application program to be tested based on a preset test frame, wherein the interface calling request is used for acquiring a page element of the operation page; and receiving a return value of the interface calling request, storing the return value in a second variable, and judging whether the numerical value of the first variable is consistent with the numerical value of the second variable in comparison. And if the comparison between the value of the first variable and the pre-stored expected value is inconsistent, determining that the test of the application program to be tested fails. Compared with the first embodiment of the present invention, after the values of the target page elements are extracted and stored in the first variable, the values of the first variable are compared with the pre-stored expected values, and the subsequent interface testing step is executed only if the comparison is successful, and if the comparison is failed, it is directly determined that the test of the application program to be tested fails. Through the setting, only under the condition that the UI test passes, the subsequent interface test is executed, and the accuracy and the rationality of the application program test can be further improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not limit the implementation process of the embodiments of the present invention in any way.
An application test method has been mainly described above, and an application test apparatus will be described below.
Referring to fig. 3, an embodiment of an application testing apparatus according to an embodiment of the present invention includes:
a test script obtaining module 301, configured to obtain an application program to be tested and a pre-compiled test script;
a test script running module 302, configured to run the test script, where the test script is used to control the application program to be tested to open an operation page and execute a page operation indicated by the test script on the operation page;
the page element capturing module 303 is configured to capture a target page element in an element positioning manner in a process that the application to be tested executes a page operation, where the target page element is determined according to an attribute of the operation page;
a value extracting module 304, configured to extract a value of the target page element, and store the value in a first variable;
an interface call triggering module 305, configured to send an interface call request to a background server of the application to be tested based on a preset test framework, where the interface call request is used to obtain a page element of the operation page;
a return value receiving module 306, configured to receive a return value of the interface call request, and store the return value in a second variable;
and a test determining module 307, configured to determine that the application program to be tested passes the test if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison.
Further, the application testing apparatus may further include:
the value comparison module is used for comparing the value of the first variable with a pre-stored expected value;
the first execution module is used for executing the step of sending an interface calling request to a background server of the application program to be tested if the value of the first variable is consistent with the pre-stored expected value;
and the second execution module is used for determining that the test of the application program to be tested fails if the comparison between the value of the first variable and the expected value stored in advance is inconsistent.
Further, the value comparison module may include:
the target file reading unit is used for calling a dataProvider tool of the testng framework to read a target file, and the target file records expected values of all page elements of the application program to be tested;
and the first numerical value comparison unit is used for comparing the numerical value of the first variable with the expected numerical value of the target page element recorded in the read target file by adopting an assertesquares method of a testng frame.
Further, the test decision module may include:
a value extracting unit for extracting a value of the first variable and a value of the second variable, respectively;
and the second numerical value comparison unit is used for comparing the extracted numerical value of the first variable with the numerical value of the second variable by adopting an assertEquals method of a testng frame.
Further, the second numerical value comparing unit may include:
a value detection subunit, configured to detect whether the value of the first variable is included in the values of the second variable;
a first determination subunit, configured to determine that the numerical values of the first variable and the numerical values of the second variable are in a consistent comparison if each of the numerical values of the second variable includes the numerical value of the first variable;
a second determining subunit, configured to determine that a comparison between the value of the first variable and the value of the second variable is inconsistent if each of the values of the second variable does not include the value of the first variable.
Embodiments of the present invention further provide a computer-readable storage medium, which stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of any one of the application program testing methods shown in fig. 1 or fig. 2 are implemented.
Embodiments of the present invention further provide a server, which includes a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, where the processor executes the computer readable instructions to implement the steps of any one of the application testing methods shown in fig. 1 or fig. 2.
Fig. 4 is a schematic diagram of a server according to an embodiment of the present invention. As shown in fig. 4, the server 4 of this embodiment includes: a processor 40, a memory 41, and computer readable instructions 42 stored in the memory 41 and executable on the processor 40. The processor 40, when executing the computer readable instructions 42, implements the steps in the above-described embodiments of the method for evaluating an application promotion effect, such as steps 101 to 109 shown in fig. 1. Alternatively, the processor 40, when executing the computer readable instructions 42, implements the functions of the modules/units in the above device embodiments, such as the functions of the modules 301 to 307 shown in fig. 3.
Illustratively, the computer readable instructions 42 may be partitioned into one or more modules/units that are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules/units may be a series of computer-readable instruction segments capable of performing certain functions, which are used to describe the execution of the computer-readable instructions 42 in the server 4.
The server 4 may be a computing device such as a smart phone, a notebook, a palm computer, and a cloud server. The server 4 may include, but is not limited to, a processor 40, a memory 41. Those skilled in the art will appreciate that fig. 4 is merely an example of a server 4 and does not constitute a limitation of server 4 and may include more or fewer components than shown, or some components in combination, or different components, e.g., server 4 may also include input output devices, network access devices, buses, etc.
The Processor 40 may be a CentraL Processing Unit (CPU), other general purpose Processor, a DigitaL SignaL Processor (DSP), an AppLication Specific Integrated Circuit (ASIC), an off-the-shelf ProgrammabLe Gate Array (FPGA) or other ProgrammabLe logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the server 4, such as a hard disk or a memory of the server 4. The memory 41 may also be an external storage device of the server 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure DigitaL (SD) Card, a FLash memory Card (FLash Card), or the like, provided on the server 4. Further, the memory 41 may also include both an internal storage unit of the server 4 and an external storage device. The memory 41 is used to store the computer readable instructions and other programs and data required by the server. The memory 41 may also be used to temporarily store data that has been output or is to be output.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a portable hard disk, a Read-OnLy Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An application testing method, comprising:
acquiring an application program to be tested and a pre-compiled test script;
running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
capturing a target page element in an element positioning mode in the process of executing page operation by the application program to be tested, wherein the target page element is determined according to the attribute of the operation page;
extracting the numerical value of the target page element and storing the numerical value in a first variable;
sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page;
receiving a return value of the interface calling request, and storing the return value in a second variable;
if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test;
when the automatic interface test of the application program to be tested is executed, extracting a numerical value in the first variable as an intermediate result or a reference value, and generating a test case;
and when the UI automation test of the application program to be tested is executed, extracting the numerical value in the second variable as an intermediate result or a reference value, and generating a test case.
2. The method for testing an application program according to claim 1, before sending an interface call request to a background server of the application program to be tested, further comprising:
comparing the value of the first variable with a pre-stored expected value;
if the value of the first variable is consistent with the pre-stored expected value in comparison, executing a step of sending an interface calling request to a background server of the application program to be tested;
and if the comparison between the value of the first variable and the pre-stored expected value is inconsistent, determining that the test of the application program to be tested fails.
3. The method for testing an application program according to claim 2, wherein the comparing the value of the first variable with a pre-stored expected value comprises:
calling a dataProvider tool of the testng framework to read a target file, wherein the target file records expected values of all page elements of the application program to be tested;
and comparing the numerical value of the first variable with the expected numerical value of the target page element recorded in the read target file by adopting an assertEquals method of a testng frame.
4. The method for testing an application program according to any one of claims 1 to 3, wherein the numerical comparison process of the first variable and the second variable comprises:
respectively extracting the numerical value of the first variable and the numerical value of the second variable;
and comparing the extracted value of the first variable with the value of the second variable by adopting an assertEquals method of a testing frame.
5. The method of claim 4, wherein comparing the extracted value of the first variable to the value of the second variable comprises:
detecting whether the value of the first variable is contained in the values of the second variable;
if the numerical values of the second variable comprise the numerical value of the first variable, judging that the numerical value of the first variable is consistent with the numerical value of the second variable in comparison;
and if the numerical values of the second variable do not contain the numerical value of the first variable, judging that the numerical value of the first variable is inconsistent with the numerical value of the second variable in comparison.
6. An application testing apparatus, comprising:
the test script acquisition module is used for acquiring an application program to be tested and a pre-written test script;
the test script running module is used for running the test script, and the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
the page element capturing module is used for capturing a target page element in an element positioning mode in the process of executing page operation by the application program to be tested, and the target page element is determined according to the attribute of the operation page;
the numerical value extraction module is used for extracting the numerical value of the target page element and storing the numerical value in a first variable;
the interface calling triggering module is used for sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page;
a return value receiving module, configured to receive a return value of the interface call request, and store the return value in a second variable;
the test judgment module is used for determining that the test of the application program to be tested passes if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison;
the first test case generation module is used for extracting a numerical value in the first variable as an intermediate result or a reference value to generate a test case when the automatic test of the interface of the application program to be tested is executed;
and the second test case generation module is used for extracting the numerical value in the second variable as an intermediate result or a reference value to generate a test case when the UI automation test of the application program to be tested is executed.
7. A computer readable storage medium storing computer readable instructions, wherein the computer readable instructions, when executed by a processor, implement the steps of the application testing method of any one of claims 1 to 5.
8. A server comprising a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the processor when executing the computer readable instructions performs the steps of:
acquiring an application program to be tested and a pre-written test script;
running the test script, wherein the test script is used for controlling the application program to be tested to open an operation page and executing the page operation indicated by the test script on the operation page;
capturing a target page element in an element positioning mode in the process of executing page operation by the application program to be tested, wherein the target page element is determined according to the attribute of the operation page;
extracting the numerical value of the target page element and storing the numerical value in a first variable;
sending an interface calling request to a background server of the application program to be tested based on a preset testing framework, wherein the interface calling request is used for acquiring page elements of the operation page;
receiving a return value of the interface calling request, and storing the return value in a second variable;
if the numerical value of the first variable is consistent with the numerical value of the second variable in comparison, determining that the application program to be tested passes the test;
when the automatic interface test of the application program to be tested is executed, extracting a numerical value in the first variable as an intermediate result or a reference value, and generating a test case;
and when the UI automation test of the application program to be tested is executed, extracting the numerical value in the second variable as an intermediate result or a reference value, and generating a test case.
9. The server according to claim 8, before sending an interface call request to a background server of the application to be tested, further comprising:
comparing the value of the first variable with a pre-stored expected value;
if the value of the first variable is consistent with the pre-stored expected value in comparison, executing a step of sending an interface calling request to a background server of the application program to be tested;
and if the comparison between the value of the first variable and the pre-stored expected value is inconsistent, determining that the test of the application program to be tested fails.
10. The server according to claim 9, wherein the comparing the value of the first variable with a pre-stored expected value comprises:
calling a dataProvider tool of the testng framework to read a target file, wherein the target file records expected values of all page elements of the application program to be tested;
and comparing the value of the first variable with the expected value of the target page element recorded in the read target file by adopting an assertEquals method of a testng frame.
CN201910840701.9A 2019-09-06 2019-09-06 Application program testing method and device, storage medium and server Active CN110704304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910840701.9A CN110704304B (en) 2019-09-06 2019-09-06 Application program testing method and device, storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910840701.9A CN110704304B (en) 2019-09-06 2019-09-06 Application program testing method and device, storage medium and server

Publications (2)

Publication Number Publication Date
CN110704304A CN110704304A (en) 2020-01-17
CN110704304B true CN110704304B (en) 2022-09-27

Family

ID=69194360

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910840701.9A Active CN110704304B (en) 2019-09-06 2019-09-06 Application program testing method and device, storage medium and server

Country Status (1)

Country Link
CN (1) CN110704304B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113721933B (en) * 2020-05-25 2024-08-23 奇安信网神信息技术(北京)股份有限公司 Data processing method and device for application program, computing equipment and medium
CN111679974A (en) * 2020-05-26 2020-09-18 泰康保险集团股份有限公司 Application program testing method and device
CN114116434A (en) * 2020-08-26 2022-03-01 腾讯科技(深圳)有限公司 Data processing method, device, server and computer readable storage medium
CN112286822A (en) * 2020-11-06 2021-01-29 国家电网有限公司 Web automatic test system, test method and test device based on selenium framework
CN112559331A (en) * 2020-12-10 2021-03-26 京东数字科技控股股份有限公司 Test method and device
CN112597051B (en) * 2020-12-30 2024-09-20 北京华胜天成科技股份有限公司 Method and device for obtaining test result, electronic equipment and storage medium
CN113268416A (en) * 2021-05-17 2021-08-17 深圳Tcl新技术有限公司 Application program testing method and device, storage medium and terminal
CN113535841A (en) * 2021-08-04 2021-10-22 杭州遥望网络科技有限公司 Data verification method, device and equipment and computer readable storage medium
CN114063603A (en) * 2021-11-16 2022-02-18 柳州赛克科技发展有限公司 Automobile controller testing method and system based on ECU-TEST
CN114679402B (en) * 2022-03-25 2024-05-14 武汉联影智融医疗科技有限公司 Method and device for testing communication protocol between upper computer and lower computer of medical robot
CN116521572B (en) * 2023-07-03 2023-09-19 天津金城银行股份有限公司 Webpage script visual verification method, system, terminal equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10169221B2 (en) * 2008-07-22 2019-01-01 Accelerate Group Limited Method and system for web-site testing
US10747655B2 (en) * 2018-11-20 2020-08-18 Express Scripts Strategic Development, Inc. Method and system for programmatically testing a user interface
CN109783355A (en) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 Page elements acquisition methods, system, computer equipment and readable storage medium storing program for executing
CN109828903B (en) * 2018-12-14 2022-03-08 中国平安人寿保险股份有限公司 Automatic testing method and device, computer device and storage medium
CN110175117A (en) * 2019-05-06 2019-08-27 珠海全志科技股份有限公司 Test method, system, device, terminal and readable storage medium storing program for executing
CN110134612A (en) * 2019-05-17 2019-08-16 深圳前海微众银行股份有限公司 UI test data generating method, device, equipment and readable storage medium storing program for executing

Also Published As

Publication number Publication date
CN110704304A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
CN110704304B (en) Application program testing method and device, storage medium and server
CN109871326B (en) Script recording method and device
CN111427803B (en) Automated random test method, apparatus, computer device and medium
US20150378876A1 (en) Visual graphical user interface verification
CN111459495B (en) Unit test code file generation method, electronic device and storage medium
CN109947637B (en) Automatic testing method, device, equipment and medium for webpage compatibility
CN109871312B (en) Interface testing method, device, equipment and readable storage medium
CN108804305A (en) A kind of method and device of automatic test
CN109783365A (en) Automated testing method, device, computer equipment and storage medium
CN111124870A (en) Interface testing method and device
US20150143342A1 (en) Functional validation of software
CN116245074A (en) Chip verification method, device and storage medium
CN112925524A (en) Method and device for detecting unsafe direct memory access in driver
CN110287700B (en) iOS application security analysis method and device
CN113407449A (en) Interface testing method and device
CN117312148A (en) Automatic interface testing method and device, computer equipment and storage medium
CN111949510B (en) Test processing method, device, electronic equipment and readable storage medium
US8464103B2 (en) Generating a functional coverage model from a trace
CN111027073B (en) Vulnerability detection method, device, equipment and storage medium
CN111597101B (en) SDK access state detection method, computer equipment and computer readable storage medium
CN113360397A (en) Regression testing method, device, equipment and storage medium of system function
CN112580334A (en) File processing method, file processing device, server and storage medium
US10296449B2 (en) Recording an application test
CN113419738A (en) Interface document generation method and device and interface management equipment
CN113238953A (en) UI automation test method and device, electronic equipment and storage 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
GR01 Patent grant
GR01 Patent grant