CN115858329A - Interactive component testing method and device, electronic equipment and storage medium - Google Patents

Interactive component testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115858329A
CN115858329A CN202111124019.3A CN202111124019A CN115858329A CN 115858329 A CN115858329 A CN 115858329A CN 202111124019 A CN202111124019 A CN 202111124019A CN 115858329 A CN115858329 A CN 115858329A
Authority
CN
China
Prior art keywords
function
target
component
interactive
call
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
Application number
CN202111124019.3A
Other languages
Chinese (zh)
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.)
Beijing ByteDance Network Technology Co Ltd
University of Edinburgh
Original Assignee
Beijing ByteDance Network Technology Co Ltd
University of Edinburgh
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 Beijing ByteDance Network Technology Co Ltd, University of Edinburgh filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202111124019.3A priority Critical patent/CN115858329A/en
Publication of CN115858329A publication Critical patent/CN115858329A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure provides an interactive component testing method, an interactive component testing device, electronic equipment and a storage medium, wherein a change function is obtained and represents a function with code change in an application; determining a target function corresponding to the modification function according to a function call chain, wherein the function call chain is used for representing a call relation among functions in the application, the target function is a function in which the modification function is called in the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in an active interface; determining the target interaction component according to the mapping relation between the target function and the target interaction component; and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, generating a test result, realizing accurate test of a change function, and improving the test efficiency and the test effect.

Description

Interactive component testing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, and in particular relates to an interactive component testing method and device, electronic equipment and a storage medium.
Background
In the life cycle of the Application, whenever the Application is upgraded and iterated to cause the change of the program code of the Application, the Application program needs to be tested to ensure that the change of the program code does not introduce new program exception (BUG) to affect the normal use of the Application.
In the process of testing, when the Activity interface (Activity) of the application changes, for example, interactive components in the Activity interface are modified and added, program codes involved in the application also change correspondingly. In the prior art, when some codes are changed, in order to test whether the changed codes cause application exception, all the codes in the application are usually tested due to complexity of calling and coupling relations among the codes, so that the problems of low test efficiency and poor test effect are caused.
Disclosure of Invention
The embodiment of the disclosure provides an interactive component testing method and device, electronic equipment and a storage medium, so as to overcome the problems of low testing efficiency and poor testing effect caused by testing all codes in an application.
In a first aspect, an embodiment of the present disclosure provides an interactive component testing method, including:
acquiring a change function, wherein the change function represents a function with code change in an application; determining a target function corresponding to the change function according to a function call chain, wherein the function call chain is used for representing a call relation among functions in the application, the target function is a function in which the change function is called inside the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in the active interface; determining the target interaction component according to a mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance; and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result.
In a second aspect, an embodiment of the present disclosure provides an interactive component testing apparatus, including:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring a change function which represents a function with code change in application;
a first determining module, configured to determine, according to a function call chain, a target function corresponding to the change function, where the function call chain is used to characterize a call relationship between functions in the application, the target function is a function in which the change function is called inside the function, and the target function is a function that is called by the application in response to a trigger action of a target interaction component in an active interface;
a second determining module, configured to determine the target interaction component according to a mapping relationship between the target function and the target interaction component, where the mapping relationship is pre-established;
and the test module is used for generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case and generating a test result.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the interactive component testing method as described above in the first aspect and in various possible designs of the first aspect.
In a fourth aspect, the embodiments of the present disclosure provide a computer-readable storage medium, where computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the method for testing an interactive component according to the first aspect and various possible designs of the first aspect is implemented.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program that, when executed by a processor, implements the interactive component testing method as described above in the first aspect and in various possible designs of the first aspect.
According to the interactive component testing method, the interactive component testing device, the electronic equipment and the storage medium, the change function is obtained, and the change function represents a function with code change in an application; determining a target function corresponding to the modification function according to a function call chain, wherein the function call chain is used for representing a call relation among functions in the application, the target function is a function in which the modification function is called in the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in an active interface; determining the target interaction component according to a mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance; and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result. Because the mapping relation from the change function to the target interaction assembly is determined, the change function can be accurately tested by generating and testing a test case for testing the target interaction assembly, and the test efficiency and the test effect are improved.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings 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 some embodiments of the present disclosure, and those skilled in the art can obtain other drawings without inventive labor.
Fig. 1 is an application scenario diagram of an interactive component testing method according to an embodiment of the present disclosure;
FIG. 2 is a diagram illustrating functional relationships in an application provided by an embodiment of the present disclosure;
fig. 3 is a first flowchart illustrating an interactive component testing method according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of one implementation of step S102 in the embodiment shown in FIG. 3;
FIG. 5 is a schematic diagram of a process for determining an objective function according to an embodiment of the present disclosure;
fig. 6 is a flowchart illustrating a second method for testing an interactive component according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a generated test result provided by an embodiment of the present disclosure;
FIG. 8 is a schematic diagram of another generated test result provided by embodiments of the present disclosure;
FIG. 9 is a block diagram of an interactive component testing apparatus according to an embodiment of the present disclosure;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 11 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are some, but not all embodiments of the present disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without inventive step, are intended to be within the scope of the present disclosure.
The following explains an application scenario of the embodiment of the present disclosure:
fig. 1 is an application scenario diagram of the interactive component testing method provided in the embodiment of the present disclosure, and the interactive component testing method provided in the embodiment of the present disclosure may be applied in an application scenario of an automated test. Specifically, as shown in fig. 1, an execution main body of the method provided in this embodiment may be a code server, a code warehouse of an application program is arranged in the code server, and after a developer user changes a code in the code warehouse through a terminal device, the code server generates a test case for an active interface of the application according to the program code updated in the code warehouse this time, and tests the active interface of the application based on the test case to generate a test result. The code server may then send the test results to the terminal device to complete delivery of the test results.
In the prior art, when an active interface of an application is changed, for example, an interactive component in the active interface is modified, added, or an active interface is added, program codes involved in the application are also changed accordingly. Specifically, under an Android system, an Activity interface is Activity, also known as Activity. The active interface represents a single screen with a user interface, such as a Java window or frame. When part of the code in the application is changed, the changed code needs to be tested in order to ensure that the changed code does not introduce new program exception. However, due to the complex calling and coupling relationships between program codes, all code in an application is typically tested. Fig. 2 is a schematic diagram of functional relationships in an application according to an embodiment of the present disclosure, and referring to fig. 2, a function a in which a code change occurs in a program code is, for example, a function for compressing data, and the function a is called by a plurality of functions, for example, a function B and a function C are included. Furthermore, the function B is called again by other functions such as the function D, and after multiple calls, the function of the interactive component a in the active interface #1 can be finally realized. However, since there are many functions and complex relationships for directly or indirectly calling a function a that has been changed, it is impossible to specifically determine the change of the function a, which active interfaces and which interactive components in the active interfaces are affected, therefore, in the prior art, a test case is usually generated based on all codes, and all interactive components in an application are used as an entry to be tested, that is, the application is integrally tested. However, the scheme can cause the problems of low testing efficiency and poor testing effect. Therefore, a method for testing only the interactive components affected by the code change is needed to improve the testing efficiency. The embodiment of the present disclosure provides an interactive component testing method to solve the above problems.
Fig. 3 is a first flowchart illustrating an interactive component testing method according to an embodiment of the present disclosure. Illustratively, the method of the present embodiment may be applied in a code server, and the interactive component testing method includes:
step S101: and acquiring a change function, wherein the change function represents a function with code change in the application.
Illustratively, the change function is a function in which a code change occurs in an application, and specifically, in one possible implementation, after a developer user modifies a program code of the application, the modified program code is uploaded to a code repository in a code server, the modified program code includes the change function, and a related service of the code repository identifies a modified part of the modified program code, so as to determine the change function in the application; in another possible implementation, the program code of the application is stored in the code repository, and when a function in the program code stored in the code repository changes, the function is automatically marked as a change function, so as to obtain the change function. The method for obtaining the change function may be set according to specific needs, and is not described herein again.
Step S102: and determining a target function corresponding to the change function according to the function call chain, wherein the function call chain is used for representing the call relation among the functions in the application, the target function is a function in which the change function is called in the function, and the target function is a function called by the application in response to the trigger action of the target interaction component in the active interface.
Illustratively, after the code server obtains the alteration function, a target function that directly or indirectly calls the alteration function is determined based on a function call chain of the program code of the application. Specifically, the function call chain is information pre-stored in the code server and used for describing a call relationship between functions in the application program code. The function call chain can be obtained by means of static analysis and the like on the application program code, and the specific implementation method and the implementation form of the function call chain are not limited here.
Further, exemplarily, a plurality of interaction components are arranged in the Activity interface, and under the android system, the Activity interface is Activity. When an interactive component in the active interface is triggered, a function corresponding to the interactive component needs to be executed, where the function is an interactive function, that is, the interactive function is a function corresponding to the interactive component in the active interface. The target function is an interactive function which directly or indirectly calls the change function, and the interactive function and the interactive components are in one-to-one correspondence, so that the target function and the interactive components are also in one-to-one correspondence, and mapping from the change function to the interactive components is realized by determining the target components.
Illustratively, as shown in fig. 4, step S102 includes three specific implementation steps of steps S1021, S1022, and S1023:
step S1021: and based on the function call chain, carrying out call detection on the change function to obtain a corresponding intermediate call function, wherein the intermediate call function is a function for calling the change function when executing.
Step S1022: if the intermediate calling function is not the interactive function, the intermediate calling function is continuously called and detected, and the function corresponding to the calling and detecting result is taken as a new intermediate calling function until the obtained intermediate calling function is the interactive function,
step S1023: and if the intermediate calling function is an interactive function, determining the intermediate calling function as a target function corresponding to the change function.
Exemplarily, after the change function is obtained, the functions directly and indirectly calling the change function are sequentially detected layer by layer according to the function call chain until the interaction function corresponding to the interaction control, namely the target function, is obtained. Since the objective function obtained in the above process is obtained based on the change function and the function call chain, the obtained objective function is affected by the change function, thereby realizing the mapping from the change function to the interactive control.
Fig. 5 is a schematic process diagram of determining a target function according to an embodiment of the present disclosure, as shown in fig. 5, after a change function is obtained, call detection is performed on the change function according to a preset function call chain, so as to obtain one or more functions that call the change function, that is, intermediate call functions, and then, for example, according to a function name of the intermediate call function, whether the intermediate call function is an interactive function is determined, and if the intermediate call function is an interactive function, the intermediate call function is determined as the target function; and if the intermediate calling function is not an interactive function, continuing to carry out calling detection on the intermediate calling function based on the function calling chain. In the program code of the application, a function can realize its function only by being called by other functions or being called when triggered by an interactive component (i.e. the function is an interactive function), so that if the intermediate calling function is not an interactive function, the function is usually called by other functions, i.e. the detection result of its call detection points to one or more functions. Therefore, after continuing to perform call detection on the intermediate call function, according to the detection result of the call detection, the function (shown as a detection result function in the figure) corresponding to the detection result of the call detection is taken as a new intermediate call function (shown as a function C in the figure) to continue judgment, and if the intermediate call function (shown as the function C in the figure) is an interactive function, the intermediate call function is determined as a target function; if the intermediate calling function is not an interactive function, based on the function calling chain, continuing to perform calling detection on the intermediate calling function until the obtained intermediate calling function is the interactive function, and determining the intermediate calling function as a target function.
Step S103: and determining the target interaction component according to the mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance.
Illustratively, the objective function is an interactive function that directly or indirectly calls a change function, and by calling the objective function, the response of the application to the trigger action of the corresponding interactive component in the active interface can be realized. The target function and the corresponding interactive component have a mapping relation, and according to the preset mapping relation, the interactive component corresponding to the target function, namely the target interactive component, can be realized.
The mapping relationship between the target function and the target interaction component may be determined by a preset layout file, where the mapping relationship between the target interaction component and the target function in the target active interface is stored in the layout file. More specifically, the layout file is a layout file of the target activity interface. Illustratively, the different activity interfaces correspond to different layout files, and the layout files can be obtained based on the identification of the activity interfaces.
Illustratively, before acquiring the corresponding layout file according to the identifier of the active interface, the method further includes: acquiring component identifications of each interactive component in the active interface; acquiring function identifiers of called interactive functions when each interactive component in the active interface is triggered; and registering and binding the function identifier of the interactive function and the component identifier of each interactive component corresponding to the active interface to generate a layout file.
Illustratively, for example, the active interface is identified as MainFragment, the active interface includes a plurality of components, where the interactive component whose component identification is id.compress corresponds to the corresponding target function a, and when the interactive component id.compress is triggered, the application will call the target function a. And registering and binding the function identifier A and id.compress in the MainFragment active interface to generate a layout file (or storing the layout file in the file), wherein the layout file is the layout file of the MainFragment of the target active interface. After the layout file is generated, based on the layout file (layout file), mapping from the target function to the target activity interface and between the target interaction controls in the target activity interface can be achieved.
Step S104: and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result.
In this embodiment, after the target interaction component is determined, a corresponding target test case is generated based on a trigger mode of the target interaction component, a corresponding input parameter, and an expected response result. The target test case is used for testing the target interaction component, and the target interaction component is obtained by mapping the change function, so that the target interaction component is triggered to call the change function, and the accurate test of the change function is realized. The problem of low testing efficiency caused by integral testing of the application is avoided. The specific implementation method for generating the test case for testing the interactive component after determining the interactive component is known to those skilled in the art and will not be described herein again.
According to the interactive component testing method, the interactive component testing device, the electronic equipment and the storage medium, the change function is obtained and represents the function with code change in the application; determining a target function corresponding to the change function according to the function call chain, wherein the function call chain is used for representing the call relation among functions in the application, the target function is a function in which the change function is called in the function, and the target function is a function called by the application in response to the trigger action of a target interaction component in the active interface; determining a target interaction component according to a mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance; and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result. Because the mapping relation from the change function to the target interaction component is determined, the change function can be accurately tested by generating and testing the test case for testing the target interaction component, and the test efficiency and the test effect are improved.
Fig. 6 is a schematic flowchart of a second method for testing an interactive component according to an embodiment of the present disclosure. In this embodiment, on the basis of the embodiment shown in fig. 3, the step S104 is further detailed, and the interactive component testing method includes:
step S201: and acquiring a change function, wherein the change function represents a function with code change in the application.
Step S202: and determining a target function corresponding to the change function according to the function call chain, wherein the function call chain is used for representing the call relation among the functions in the application, the target function is a function in which the change function is called in the function, and the target function is a function called by the application in response to the trigger action of the target interaction component in the active interface.
Step S203: and determining the target interaction component according to the mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance.
Step S204: and generating a target test case corresponding to the target interaction component, wherein the target test case comprises a target component identifier and corresponding trigger information, the target component identifier is used for indicating the target interaction component, and the trigger information is used for indicating a trigger action when the target interaction component is tested.
Illustratively, based on the embodiment shown in fig. 3, after the target interaction component is determined, a corresponding target test case may be generated based on the target interaction component. The target test case includes a target component identifier for indicating the target interaction component, and trigger information representing a trigger action when the target interaction component is tested, for example, the target interaction component is a button (button), the corresponding trigger action includes clicking, pressing, releasing, and the like, and response results of various trigger actions of the target interaction component can be tested through the trigger information, so that a change function corresponding to the target interaction component is tested. The target component identifier and the corresponding trigger information in the target test case are used as a group of data, and are generated according to the corresponding target interaction component, and the specific generation process is not described herein again.
Step S205: and executing the target function corresponding to the target interaction component according to the target component identification and the corresponding trigger information.
Step S206: and generating an intermediate test result according to the execution result of the called change function in the target function execution process.
Step S207: and generating a test result according to the intermediate test result and the execution result of the target function.
Exemplarily, the target interaction component is tested according to the target component identifier and the corresponding trigger information, that is, the process of executing the test case is omitted here for details. In the process, as the trigger action corresponding to the trigger information is executed, the target function corresponding to the target interaction component is also called to realize the corresponding function.
However, since the target function directly or indirectly calls the alteration function during the execution of the target function, the process of executing the alteration function and the process of executing the intermediate call function that calls the alteration function are also included during the execution of the target function. In one possible implementation, the result of executing the change function is the intermediate test result. And generating a test result together according to the intermediate test result and the execution result of the target function, so that the problem function can be positioned. For example, if the execution result of the target function is abnormal and the intermediate test result (i.e., the modification function) is also abnormal according to the test result, it can be determined that the abnormality of the target function is caused by at least the modification function, and therefore the modification function can be determined as a problem function for subsequent error correction; if the execution result of the target function is abnormal and the intermediate test result is normal, it can be determined that the abnormality of the target function is not directly caused by the alteration function and may be caused by other intermediate call functions which call the alteration function, so that the intermediate call function which calls the alteration function can be further tested to locate the problem function. Therefore, the problem function causing program abnormity is positioned, and the test accuracy and the test efficiency are improved.
Fig. 7 is a schematic diagram for generating a test result according to an embodiment of the present disclosure, as shown in fig. 7, after a target interaction component is triggered according to a target component identifier and corresponding trigger information, a corresponding target function is executed, since the target function calls a change function, the change function is also executed in the process of executing the target function, further, an intermediate test result is generated according to an execution result of the change function, and finally, a test result is generated together through an execution result of the target function and the intermediate test result.
In another possible implementation, the result of executing the alter function, and the result of executing the intermediate call function that called the alter function, are intermediate test results. And generating a test result together according to the intermediate test result and the execution result of the target function, and further realizing the positioning of the problem function, thereby improving the test accuracy and the test efficiency.
More specifically, for example, if the execution result of the target function is abnormal, a test result indicating an abnormal function in each intermediate call function is determined based on the execution result of each intermediate call function in the target function that calls the alteration function.
Fig. 8 is another schematic diagram for generating a test result provided by the embodiment of the present disclosure, as shown in fig. 8, after a target interaction component is triggered according to a target component identifier and corresponding trigger information, a corresponding target function is executed, where the target function includes a plurality of intermediate call functions (shown as an intermediate call function a, an intermediate call function B, and an intermediate call function C) having a call relationship, each intermediate call function directly or indirectly calls a change function, and a call relationship between each intermediate call function is shown in fig. 7. During the execution of the target function, each intermediate call function in the target function is executed, and corresponding execution results (shown as an execution result a, an execution result b, and an execution result c) are generated. Further, the test result is determined in accordance with the execution result of each intermediate call function, the execution result of the modification function, and the execution result of the target function.
For example, the method for generating the test result provided in the embodiment shown in fig. 8 may be used in combination with the method for generating the test result provided in the embodiment shown in fig. 7 after the method for generating the test result provided in the embodiment shown in fig. 7. That is, after it is determined that the execution result of the target function is abnormal and the intermediate test result is normal, the method provided in the embodiment shown in fig. 8 may be continued to obtain the execution result of the intermediate call function, and a test result may be generated based on the execution result of each intermediate call function, where the test result may be used to indicate an abnormal function in each intermediate call function, so as to further locate the problem function, and improve the test accuracy and the test efficiency.
In this embodiment, the implementation manners of step S201 to step S203 are the same as the implementation manners of step S101 to step S103 in the embodiment shown in fig. 3 of the present disclosure, and are not described in detail herein.
Fig. 9 is a block diagram of an interactive component testing apparatus according to an embodiment of the present disclosure, which corresponds to the interactive component testing method according to the above embodiment. For ease of illustration, only portions relevant to embodiments of the present disclosure are shown. Referring to fig. 9, the interactive component test apparatus 3 includes:
an obtaining module 31, configured to obtain a change function, where the change function represents a function in which a code change occurs in an application;
the first determining module 32 is configured to determine a target function corresponding to the change function according to a function call chain, where the function call chain is used to characterize a call relationship between functions in the application, the target function is a function in which the change function is called inside the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in the active interface;
a second determining module 33, configured to determine the target interaction component according to a mapping relationship between the target function and the target interaction component, where the mapping relationship is pre-established;
the test module 34 is configured to generate a target test case corresponding to the target interaction component, and test the target interaction component based on the target test case to generate a test result.
In a possible implementation manner, the first determining module 32 is specifically configured to: based on the function call chain, carrying out call detection on the change function to obtain a corresponding intermediate call function, wherein the intermediate call function is a function for calling the change function during execution; if the intermediate calling function is not the interactive function, continuing to call and detect the intermediate calling function, and taking a function corresponding to a call and detection result as a new intermediate calling function until the obtained intermediate calling function is the interactive function, wherein the interactive function is a function corresponding to an interactive component in the active interface; and if the intermediate calling function is an interactive function, determining the intermediate calling function as a target function corresponding to the change function.
In a possible implementation manner, the second determining module 33 is further configured to: acquiring an identifier of the active interface; and acquiring a corresponding layout file according to the identifier of the active interface, wherein the mapping relation between the target interaction assembly and the target function in the target active interface is stored in the layout file.
In a possible implementation manner, before the second determining module 33 obtains the corresponding layout file according to the identifier of the active interface, the second determining module is further configured to: acquiring component identifications of each interactive component in the active interface; acquiring function identifiers of called interactive functions when each interactive component in the active interface is triggered; and registering and binding the function identifier of the interactive function and the component identifier of each interactive component corresponding to the active interface to generate a layout file.
In one possible implementation, the layout file is a layout file of the target campaign interface.
In a possible implementation manner, the target test case includes a target component identifier and corresponding trigger information, the target component identifier is used for indicating the target interaction component, and the trigger information is used for indicating a trigger action when the target interaction component is tested; when the test module 34 tests the target interaction component based on the target test case and generates a test result, it is specifically configured to: executing a target function corresponding to the target interaction component according to the target component identification and the corresponding trigger information; and generating a test result according to the execution result of the target function.
In one possible implementation, test module 34 is further configured to: generating an intermediate test result according to an execution result of the called change function in the target function execution process; when the test module 34 generates a test result according to the execution result of the target function, it is specifically configured to: and generating a test result according to the intermediate test result and the execution result of the target function.
In a possible implementation manner, the intermediate test result includes an execution result of each intermediate call function that calls the alteration function in the target function; when the test module 34 generates a test result according to the intermediate test result and the execution result of the target function, it is specifically configured to: and if the execution result of the target function is abnormal, determining a test result according to the execution result of each intermediate calling function calling the change function in the target function, wherein the test result is used for indicating the abnormal function in each intermediate calling function.
The obtaining module 31, the first determining module 32, the second determining module 33 and the testing module 34 are connected in sequence. The interactive component testing apparatus 3 provided in this embodiment may execute the technical solution of the method embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, and as shown in fig. 10, the electronic device 4 includes:
a processor 41, and a memory 42 communicatively coupled to the processor 41;
the memory 42 stores computer-executable instructions;
processor 41 executes computer-executable instructions stored by memory 42 to implement the interactive component testing method in the embodiment shown in fig. 3-8.
Wherein optionally the processor 41 and the memory 42 are connected by a bus 43.
The relevant descriptions and effects corresponding to the steps in the embodiments corresponding to fig. 3 to fig. 8 can be understood, and are not described in detail herein.
Referring to fig. 11, a schematic structural diagram of an electronic device 900 suitable for implementing the embodiment of the present disclosure is shown, where the electronic device 900 may be a terminal device or a server. Among them, the terminal Device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a Digital broadcast receiver, a Personal Digital Assistant (PDA), a tablet computer (PAD), a Portable Multimedia Player (PMP), a car terminal (e.g., car navigation terminal), etc., and a fixed terminal such as a Digital TV, a desktop computer, etc. The electronic device shown in fig. 11 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 11, the electronic device 900 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 901, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 902 or a program loaded from a storage means 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are also stored. The processing apparatus 901, the ROM902, and the RAM 903 are connected to each other through a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
Generally, the following devices may be connected to the I/O interface 905: input devices 906 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 907 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 908 including, for example, magnetic tape, hard disk, etc.; and a communication device 909. The communication means 909 may allow the electronic apparatus 900 to communicate with other apparatuses wirelessly or by wire to exchange data. While fig. 11 illustrates an electronic device 900 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided.
In particular, the processes described above with reference to the flow diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. The computer program, when executed by the processing device 901, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present disclosure, 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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 methods shown in the above embodiments.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including 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 latter scenario, the remote computer may be connected to the user's computer through any type of Network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 disclosure. 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 described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first obtaining unit may also be described as a "unit obtaining at least two internet protocol addresses".
The functions described herein above 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: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, 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. A 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 compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In a first aspect, according to one or more embodiments of the present disclosure, there is provided an interactive component testing method, including:
acquiring a change function, wherein the change function represents a function with code change in an application; determining a target function corresponding to the modification function according to a function call chain, wherein the function call chain is used for representing a call relation among functions in the application, the target function is a function in which the modification function is called in the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in an active interface; determining the target interaction component according to a mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance; and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result.
According to one or more embodiments of the present disclosure, determining an objective function corresponding to the change function according to a function call chain includes: based on the function call chain, carrying out call detection on the change function to obtain a corresponding intermediate call function, wherein the intermediate call function is a function for calling the change function when executing; if the intermediate calling function is not an interactive function, continuing to call and detect the intermediate calling function, and taking a function corresponding to the result of the call and detection as a new intermediate calling function until the obtained intermediate calling function is the interactive function, wherein the interactive function is a function corresponding to an interactive component in the active interface; and if the intermediate calling function is the interactive function, determining the intermediate calling function as a target function corresponding to the change function.
According to one or more embodiments of the present disclosure, the method further comprises: acquiring an identifier of the activity interface; and acquiring a corresponding layout file according to the identifier of the active interface, wherein the mapping relation between the target interaction component in the target active interface and the target function is stored in the layout file.
According to one or more embodiments of the present disclosure, before obtaining the corresponding layout file according to the identifier of the active interface, the method further includes: acquiring component identification of each interactive component in the active interface; acquiring function identifiers of the called interactive functions when each interactive component in the active interface is triggered; and registering and binding the function identifier of the interactive function and the component identifier of each corresponding interactive component in the active interface to generate a layout file.
According to one or more embodiments of the present disclosure, the layout file is a layout file of the target activity interface.
According to one or more embodiments of the present disclosure, the target test case includes a target component identifier and corresponding trigger information, where the target component identifier is used to indicate a target interaction component, and the trigger information is used to indicate a trigger action when the target interaction component is tested; testing the target interaction component based on the target test case to generate a test result, wherein the test result comprises the following steps: executing a target function corresponding to the target interaction component according to the target component identification and the corresponding trigger information; and generating a test result according to the execution result of the target function.
According to one or more embodiments of the present disclosure, the method further comprises: generating an intermediate test result according to the execution result of the called change function in the target function execution process; generating a test result according to the execution result of the target function, wherein the test result comprises the following steps: and generating a test result according to the intermediate test result and the execution result of the target function.
According to one or more embodiments of the present disclosure, the intermediate test result includes an execution result of each intermediate call function that calls a change function in the target function; generating a test result according to the intermediate test result and the execution result of the target function, wherein the test result comprises: and if the execution result of the target function is abnormal, determining the test result according to the execution result of each intermediate calling function for calling the change function in the target function, wherein the test result is used for indicating the abnormal function in each intermediate calling function.
In a second aspect, according to one or more embodiments of the present disclosure, there is provided an interactive component testing apparatus, including:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring a change function which represents a function with code change in application;
a first determining module, configured to determine, according to a function call chain, a target function corresponding to the change function, where the function call chain is used to characterize a call relationship between functions in the application, the target function is a function in which the change function is called inside the function, and the target function is a function that is called by the application in response to a trigger action of a target interaction component in an active interface;
a second determining module, configured to determine the target interaction component according to a mapping relationship between the target function and the target interaction component, where the mapping relationship is pre-established;
and the test module is used for generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case and generating a test result.
According to one or more embodiments of the present disclosure, the first determining module is specifically configured to: based on the function call chain, carrying out call detection on the change function to obtain a corresponding intermediate call function, wherein the intermediate call function is a function for calling the change function when executing; if the intermediate calling function is not an interactive function, continuing to call and detect the intermediate calling function, and taking a function corresponding to the call and detection result as a new intermediate calling function until the obtained intermediate calling function is the interactive function, wherein the interactive function is a function corresponding to an interactive component in the active interface; and if the intermediate calling function is the interactive function, determining the intermediate calling function as a target function corresponding to the change function.
According to one or more embodiments of the present disclosure, the second determining module is further configured to: acquiring an identifier of the activity interface; and acquiring a corresponding layout file according to the identifier of the active interface, wherein the mapping relation between the target interaction assembly in the target active interface and the target function is stored in the layout file.
According to one or more embodiments of the present disclosure, before the second determining module obtains the corresponding layout file according to the identifier of the active interface, the second determining module is further configured to: acquiring component identification of each interactive component in the active interface; acquiring function identifiers of the called interactive functions when the interactive components in the active interface are triggered; and registering and binding the function identifier of the interactive function and the component identifier of each corresponding interactive component in the active interface to generate a layout file.
According to one or more embodiments of the present disclosure, the layout file is a layout file of the target campaign interface.
According to one or more embodiments of the present disclosure, the target test case includes a target component identifier and corresponding trigger information, where the target component identifier is used to indicate a target interaction component, and the trigger information is used to indicate a trigger action when the target interaction component is tested; the test module is specifically configured to, when testing the target interaction component based on the target test case and generating a test result: executing a target function corresponding to the target interaction component according to the target component identification and the corresponding trigger information; and generating a test result according to the execution result of the target function.
In accordance with one or more embodiments of the present disclosure, the test module is further configured to: generating an intermediate test result according to the execution result of the called change function in the target function execution process; when the test module generates a test result according to the execution result of the target function, the test module is specifically configured to: and generating a test result according to the intermediate test result and the execution result of the target function.
According to one or more embodiments of the present disclosure, the intermediate test result includes an execution result of each intermediate call function that calls a change function in the target function; when the test module generates a test result according to the intermediate test result and the execution result of the target function, the test module is specifically configured to: and if the execution result of the target function is abnormal, determining the test result according to the execution result of each intermediate calling function calling the change function in the target function, wherein the test result is used for indicating the abnormal function in each intermediate calling function.
In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device including: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the method of generating test results as described above in the first aspect and in various possible designs of the first aspect.
In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement the method for generating test results as set forth in the first aspect and various possible designs of the first aspect above.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program that, when executed by a processor, implements a method of generating test results as set forth in the first aspect above and in various possible designs of the first aspect.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (12)

1. An interactive component testing method, comprising:
acquiring a change function, wherein the change function represents a function with code change in an application;
determining a target function corresponding to the modification function according to a function call chain, wherein the function call chain is used for representing a call relation among functions in the application, the target function is a function in which the modification function is called in the function, and the target function is a function called by the application in response to a trigger action of a target interaction component in an active interface;
determining the target interaction component according to a mapping relation between the target function and the target interaction component, wherein the mapping relation is established in advance;
and generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case, and generating a test result.
2. The method of claim 1, wherein determining the objective function corresponding to the altered function according to the function call chain comprises:
based on the function call chain, carrying out call detection on the change function to obtain a corresponding intermediate call function, wherein the intermediate call function is a function for calling the change function when executing;
if the intermediate calling function is not an interactive function, continuing to call and detect the intermediate calling function, and taking a function corresponding to the result of the call and detection as a new intermediate calling function until the obtained intermediate calling function is the interactive function, wherein the interactive function is a function corresponding to an interactive component in the active interface;
and if the intermediate calling function is the interactive function, determining the intermediate calling function as a target function corresponding to the change function.
3. The method of claim 1, further comprising:
acquiring an identifier of the active interface;
and acquiring a corresponding layout file according to the identifier of the active interface, wherein the mapping relation between the target interaction component in the target active interface and the target function is stored in the layout file.
4. The method of claim 3, wherein prior to retrieving the corresponding layout file based on the identification of the active interface, the method further comprises:
acquiring component identification of each interactive component in the active interface;
acquiring function identifiers of the called interactive functions when the interactive components in the active interface are triggered;
and registering and binding the function identifier of the interactive function and the component identifier of each corresponding interactive component in the active interface to generate a layout file.
5. The method of claim 3, wherein the layout file is a layout file of the target activity interface.
6. The method according to any one of claims 1 to 5, wherein the target test case includes a target component identifier and corresponding trigger information, the target component identifier is used to indicate a target interaction component, and the trigger information is used to indicate a trigger action when the target interaction component is tested;
testing the target interaction component based on the target test case to generate a test result, wherein the test result comprises the following steps:
executing a target function corresponding to the target interaction component according to the target component identification and the corresponding trigger information;
and generating a test result according to the execution result of the target function.
7. The method of claim 6, further comprising:
generating an intermediate test result according to the execution result of the called change function in the execution process of the target function;
generating a test result according to the execution result of the target function, wherein the test result comprises the following steps:
and generating a test result according to the intermediate test result and the execution result of the target function.
8. The method of claim 7, wherein the intermediate test results include results of execution of intermediate call functions of the target function that call the alter function;
generating a test result according to the intermediate test result and the execution result of the target function, wherein the test result comprises:
and if the execution result of the target function is abnormal, determining the test result according to the execution result of each intermediate calling function calling the change function in the target function, wherein the test result is used for indicating the abnormal function in each intermediate calling function.
9. An interactive component testing apparatus, comprising:
the system comprises an acquisition module, a change function and a control module, wherein the acquisition module is used for acquiring the change function, and the change function represents a function with code change in an application;
a first determining module, configured to determine, according to a function call chain, a target function corresponding to the change function, where the function call chain is used to characterize a call relationship between functions in the application, the target function is a function in which the change function is called inside the function, and the target function is a function that is called by the application in response to a trigger action of a target interaction component in an active interface;
a second determining module, configured to determine the target interaction component according to a mapping relationship between the target function and the target interaction component, where the mapping relationship is pre-established;
and the test module is used for generating a target test case corresponding to the target interaction component, testing the target interaction component based on the target test case and generating a test result.
10. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the method of any of claims 1 to 8.
11. A computer-readable storage medium having computer-executable instructions stored thereon which, when executed by a processor, implement the interactive component testing method of any one of claims 1 to 8.
12. A computer program product comprising a computer program which, when executed by a processor, implements the interactive component testing method of any of claims 1 to 8.
CN202111124019.3A 2021-09-24 2021-09-24 Interactive component testing method and device, electronic equipment and storage medium Pending CN115858329A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111124019.3A CN115858329A (en) 2021-09-24 2021-09-24 Interactive component testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111124019.3A CN115858329A (en) 2021-09-24 2021-09-24 Interactive component testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115858329A true CN115858329A (en) 2023-03-28

Family

ID=85652666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111124019.3A Pending CN115858329A (en) 2021-09-24 2021-09-24 Interactive component testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115858329A (en)

Similar Documents

Publication Publication Date Title
CN111897740B (en) User interface testing method and device, electronic equipment and computer readable medium
US9535819B2 (en) Identifying the lines of code that caused the error as identified in the stack trace in a source code version that generated the stack trace that does not reside on the user's computing device
CN107391362A (en) Application testing method, mobile terminal and storage medium
CN113449310A (en) Application program vulnerability detection method, device and equipment
CN110888731A (en) Route data acquisition method, device, equipment and storage medium
CN116225886A (en) Test case generation method, device, equipment, storage medium and program product
CN111506904A (en) Method and device for online vulnerability repair
CN116450511A (en) Information updating method, device, electronic equipment and computer readable medium
CN110908882A (en) Performance analysis method and device of application program, terminal equipment and medium
CN112084104A (en) Abnormity testing method and device
CN114296986B (en) Memory leakage positioning method, device, medium and electronic equipment
CN115858329A (en) Interactive component testing method and device, electronic equipment and storage medium
CN115422052A (en) Vehicle navigation app test system and method
CN112379967B (en) Simulator detection method, device, equipment and medium
CN109960659B (en) Method and device for detecting application program
CN116149978A (en) Service interface testing method and device, electronic equipment and storage medium
CN112306723A (en) Operation information acquisition method and device applied to small program
CN110489341B (en) Test method and device, storage medium and electronic equipment
CN110851254A (en) Equipment production method, device, server and storage medium based on microservice
CN111382017A (en) Fault query method, device, server and storage medium
CN112596966B (en) Chip verification method, device, equipment and storage medium
CN116361143A (en) Software testing method, device, equipment and storage medium
CN116501634A (en) Test case management method, device, medium and electronic equipment
CN115481007A (en) Test method, test device, storage medium and electronic equipment
CN115640204A (en) Page compatibility testing 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