Application testing methods, apparatus, devices, storage media, and program products

By receiving code change requests, identifying target methods and component identifiers, obtaining test cases, and performing automated testing, the problem of low testing efficiency in large-scale application projects is solved, achieving accurate screening and efficient testing.

CN118193382BActive Publication Date: 2026-01-06CHERY AUTOMOBILE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410328880.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-21
Publication Date
2026-01-06
Estimated Expiration
2044-03-21

AI Technical Summary

Technical Problem

Large-scale application development projects become increasingly complex due to growing requirements, leading to high server resource consumption and long testing times for automated testing, resulting in low testing efficiency.

Method used

By receiving code change submission requests, the target methods and active component identifiers of the changes are determined based on current and historical source code files, corresponding test cases are obtained, and precise testing is performed using automated test scripts.

Benefits of technology

It improves the testing efficiency of applications, accurately identifies and tests target methods that have changed, and reduces testing time and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118193382B_ABST
    Figure CN118193382B_ABST
Patent Text Reader

Abstract

The application discloses a kind of application program's test method, device, equipment, storage medium and program product, belong to computer technical field.Method includes: receiving the code change submission request of target application program, code change submission request carries current submitted source code file;Determine the identification of target method in source code file compared with historical source code file and the identification of active component to which target method belongs based on source code file and historical source code file of historical submission;Based on the identification of target method and the identification of active component to which target method belongs, the test case corresponding to target method is acquired;Based on the test case corresponding to target method, target application program is tested by automated test script.The application is tested to target application program based on the test case corresponding to target method by determining the target method in source code file compared with historical source code file, to improve the test efficiency of target application program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device, storage medium, and program product for testing applications. Background Technology

[0002] To improve application stability, testing is typically required during application development to determine its operational stability and whether it meets expectations. To enhance testing efficiency and quality, automated test scripts are commonly used to automate the testing of the application's code.

[0003] For large-scale projects, as product requirements increase during project development, applications become more and more complex, requiring a large amount of server resources to complete automated testing of the application each time, and the testing time required also increases, resulting in low testing efficiency. Summary of the Invention

[0004] This application provides a method, apparatus, device, storage medium, and program product for testing applications, which can improve the testing efficiency of applications. The technical solution is as follows:

[0005] On the one hand, a testing method for an application is provided, the method comprising:

[0006] Receive a code change commit request for the target application, the code change commit request carrying at least one source code file currently being committed;

[0007] Based on the at least one source code file and the historical source code files of the target application submitted in the past, determine the identifier of the target method in the at least one source code file that has changed compared to the historical source code file and the identifier of the active component to which the target method belongs;

[0008] Based on the identifier of the target method and the identifier of the activity component to which the target method belongs, obtain the test cases corresponding to the target method;

[0009] Based on the test cases corresponding to the target method, the target application is tested using automated test scripts.

[0010] Optionally, determining the identifier of the target method that has changed compared to the historical source code file in the at least one source code file and the identifier of the active component to which the target method belongs, based on the at least one source code file and the historical source code files of the target application submitted previously, includes:

[0011] Based on the at least one source code file and the historical source code file, construct the application installation package of the target application;

[0012] The call relationship chain is determined based on the application installation package. The call relationship chain is used to indicate the call relationship between various methods in the target application and the active component to which each method belongs.

[0013] Based on the at least one source code file and the historical source code file, identify the target method in the at least one source code file that has been modified compared to the historical source code file;

[0014] Based on the call relationship chain and the identifier of the target method, the identifier of the activity component to which the target method belongs is determined.

[0015] Optionally, determining the identifier of the target method in the at least one source file that has changed compared to the historical source file, based on the at least one source file and the historical source file, includes:

[0016] Select a second source file corresponding to the first source file from the historical source file. The first source file refers to any source file in the at least one source file that has been changed compared to the historical source file. The second source file refers to the most recently committed source file in the historical source file that is the source file before the change corresponding to the first source file.

[0017] A first program structure interface file is determined based on the first source code file, and a second program structure interface file is determined based on the second source code file. The first program structure interface file is used to indicate each method in the first source code file, and the second program structure interface file is used to indicate each method in the second source code file.

[0018] Based on the first program structure interface file and the second program structure interface file, the target method that has been modified in the first source code file is determined.

[0019] Optionally, obtaining the test cases corresponding to the target method based on the identifier of the target method and the identifier of the activity component to which the target method belongs includes:

[0020] If the target method is the method modified in this instance, then based on the identifier of the target method and the identifier of the activity component to which the target method belongs, the test case identifier corresponding to the target method is determined through a mapping table. The mapping table is used to indicate the correspondence between the method identifier, the activity component identifier, and the test case identifier.

[0021] Based on the test case identifier corresponding to the target method, the test cases corresponding to the target method are obtained from the test case database. The test case database includes test cases corresponding to each method in each activity component, and different methods correspond to different test cases.

[0022] Optionally, the method further includes:

[0023] If the target method is a newly added method, a prompt message will be displayed, which is used to prompt the tester to write test cases corresponding to the target method;

[0024] Obtain the test cases written by the testers for the target method.

[0025] Optionally, the method further includes:

[0026] Obtain the identifier of the test case corresponding to the target method;

[0027] The identifier of the target method, the identifier of the activity component to which the target method belongs, and the identifier of the test case corresponding to the target method are stored in the mapping table, and the test cases corresponding to the target method are stored in the test case database.

[0028] On the other hand, an application testing apparatus is provided, the apparatus comprising:

[0029] A receiving module is used to receive a code change submission request from a target application, wherein the code change submission request carries at least one source code file currently being submitted;

[0030] The change determination module is used to determine, based on the at least one source code file and the historical source code files of the target application submitted in the past, the identifier of the target method that has changed compared to the historical source code file and the identifier of the active component to which the target method belongs.

[0031] The test case acquisition module is used to acquire the test cases corresponding to the target method based on the identifier of the target method and the identifier of the activity component to which the target method belongs;

[0032] The testing module is used to test the target application using automated test scripts based on the test cases corresponding to the target method.

[0033] Optionally, the change determination module specifically includes:

[0034] An application installation package building submodule is used to build the application installation package of the target application based on the at least one source code file and the historical source code file;

[0035] The call relationship chain determination submodule is used to determine the call relationship chain based on the application installation package. The call relationship chain is used to indicate the call relationship between various methods in the target application and the active component to which each method belongs.

[0036] The target method determination submodule is used to determine the identifier of the target method in the at least one source file that has changed compared to the historical source file, based on the at least one source file and the historical source file;

[0037] The activity component determination submodule is used to determine the identifier of the activity component to which the target method belongs based on the call relationship chain and the identifier of the target method.

[0038] Optionally, the target method determining submodule is specifically used for:

[0039] Select a second source file corresponding to the first source file from the historical source file. The first source file refers to any source file in the at least one source file that has been changed compared to the historical source file. The second source file refers to the most recently committed source file in the historical source file that is the source file before the change corresponding to the first source file.

[0040] A first program structure interface file is determined based on the first source code file, and a second program structure interface file is determined based on the second source code file. The first program structure interface file is used to indicate each method in the first source code file, and the second program structure interface file is used to indicate each method in the second source code file.

[0041] Based on the first program structure interface file and the second program structure interface file, the target method that has been modified in the first source code file is determined.

[0042] Optionally, the test case acquisition module is specifically used for:

[0043] If the target method is the method modified in this instance, then based on the identifier of the target method and the identifier of the activity component to which the target method belongs, the test case identifier corresponding to the target method is determined through a mapping table. The mapping table is used to indicate the correspondence between the method identifier, the activity component identifier, and the test case identifier.

[0044] Based on the test case identifier corresponding to the target method, the test cases corresponding to the target method are obtained from the test case database. The test case database includes test cases corresponding to each method in each activity component, and different methods correspond to different test cases.

[0045] Optionally, the test case acquisition module is further configured to:

[0046] If the target method is a newly added method, a prompt message will be displayed, which is used to prompt the tester to write test cases corresponding to the target method;

[0047] Obtain the test cases written by the testers for the target method.

[0048] Optionally, the test case acquisition module is further configured to:

[0049] Obtain the identifier of the test case corresponding to the target method;

[0050] The identifier of the target method, the identifier of the activity component to which the target method belongs, and the identifier of the test case corresponding to the target method are stored in the mapping table, and the test cases corresponding to the target method are stored in the test case database.

[0051] On the other hand, a computer device is provided, the computer device including a memory and a processor, the memory for storing a computer program, and the processor for executing the computer program stored in the memory to implement the steps of the application testing method described above.

[0052] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the steps of the test method for the application described above.

[0053] On the other hand, a computer program product containing instructions is provided, which, when run on a computer, cause the computer to perform the steps of the testing method for the application described above.

[0054] The technical solution provided in this application can bring at least the following beneficial effects:

[0055] Upon receiving a code change submission request for the target application, the system identifies the target method that has been changed in the currently submitted source code file and the identifier of the active component to which that target method belongs by using the currently submitted source code file and historical source code files. This allows for precise filtering of the target methods that have changed in the currently submitted code change request. Then, based on the identifier of the target method and the identifier of the active component to which it belongs, the system obtains the corresponding test cases for the target method. These test cases are then used to perform precise testing of the target application, thereby improving the testing efficiency of the target application. Attached Figure Description

[0056] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application;

[0058] Figure 2 This is a flowchart of a testing method for an application provided in an embodiment of this application;

[0059] Figure 3 This is a flowchart of another application testing method provided in an embodiment of this application;

[0060] Figure 4 This is a flowchart of another application testing method provided in an embodiment of this application;

[0061] Figure 5 This is a schematic diagram of the structure of a testing device for an application provided in an embodiment of this application;

[0062] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0064] Before providing a detailed explanation of the testing methods for the applications provided in the embodiments of this application, the implementation environment involved in the embodiments of this application will be introduced first.

[0065] Please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an implementation environment according to an exemplary embodiment. The implementation environment includes a processor 101 and a memory 102, and the processor 101 can communicate with the memory 102. This communication connection can be wired or wireless, and this embodiment does not limit the specific connection.

[0066] The processor 101 is used to receive a code change submission request from the target application, and based on the code change submission request, determine the identifier of the target method that has been changed in the currently submitted source code file and the identifier of the active component to which the target method belongs.

[0067] The memory 102 can record all code change submission requests of the target application. The processor 101 can determine the identifier of the target method that has been changed in the currently submitted source code file and the identifier of the activity to which the target method belongs, based on the source code file carried in the currently received code change submission request and the historical source code files recorded in the memory 102.

[0068] In some embodiments, the memory 102 may also include multiple test cases. The processor 101 may retrieve the test cases corresponding to the target method from the memory 102 based on the identifier of the target method and the identifier of the active component to which the target method belongs, so as to test the target application through automated test scripts based on the test cases corresponding to the target method.

[0069] The execution entity of the application testing method provided in this embodiment is the processor 101 described above. The processor 101 can be a general-purpose CPU (Central Processing Unit), an NP (Network Processor), a microprocessor, or one or more integrated circuits used to implement the solution of this application, such as an ASIC (Application-Specific Integrated Circuit), a PLD (Programmable Logic Device), or a combination thereof. The PLD can be a CPLD (Complex Programmable Logic Device), an FPGA (Field-Programmable Gate Array), a GAL (Generic Array Logic), or any combination thereof.

[0070] Those skilled in the art should understand that the processor 101 and memory 102 described above are merely examples. Other existing or future processors or memories that are applicable to the embodiments of this application should also be included within the scope of protection of the embodiments of this application, and are hereby incorporated by reference.

[0071] It should be noted that the application scenarios and implementation environments described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the emergence of new application scenarios and the evolution of implementation environments, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0072] The testing method for the application provided in the embodiments of this application will be explained in detail below.

[0073] Figure 2 This is a flowchart illustrating a testing method for an application provided in an embodiment of this application. The method is applied to a processor. Please refer to... Figure 2 The method includes the following steps.

[0074] Step 201: Receive a code change commit request for the target application, which carries at least one source file to be committed.

[0075] In some embodiments, the processor may include a version control system to track and manage changes to the source code in the target application. Developers (such as the developers of the target application) may submit one or more source code files to the version control system based on actual usage needs and merge these source code files into the project code via code change requests, such as MR (Merge Request).

[0076] It should be noted that developers can modify the code in the relevant source code files based on the actual needs of program development, such as optimizing the code in the application. They can then submit the modified source code files (such as Java source code files, Python source code files, etc.) to the processor. The submitted modified source code files are the source code files currently submitted in the code change request.

[0077] In some embodiments, based on actual usage needs, such as when it is necessary to change the access permissions of source code files or optimize the code style of source code files, the source code files carried in the code change request may also include unmodified source code files.

[0078] Additionally, it should be noted that since code change requests typically involve only changes to a portion of the code, the source code files included in the code change request are usually only a portion of the application's source code files.

[0079] Step 202: Based on at least one source code file and the historical source code files of the target application submitted in the past, determine the identifier of the target method in at least one source code file that has changed compared to the historical source code file, and the identifier of the active component to which the target method belongs.

[0080] In some embodiments, the identifier of the target method and the identifier of the active component to which the target method belongs can be determined through the following steps (1)-(4).

[0081] (1) Based on at least one source code file and historical source code files, build the application installation package of the target application.

[0082] Based on the above description, the source code files included in a code change request are usually only a portion of the application's source code files. Source code files not included in the code change submission request are typically those not modified in this submission.

[0083] Therefore, in some embodiments, based on the descriptive information of the source code files (such as the filename and directory path), the source code file with the same descriptive information as the current submission in the previous version can be identified as the original source code file corresponding to the current submission. Then, the source code files in the previous version whose descriptive information differs from the current submission are those not modified in the current code change submission request. Combining these unmodified source code files from the previous version with the source code files carried in the code change submission request yields all the source code files for this version (i.e., the version of the target application after this modification). These source code files are then compiled to generate an executable file, thus obtaining the application installation package for the target application.

[0084] For example, a compiler can convert the modified source code of the target application into a Dalvik executable file (i.e., a DEX file). Simultaneously, the compiler can compile other resources (such as XML, image resources, etc.) into binary resource files. Then, a packager combines these DEX files and the compiled resource files to obtain the target application's installation package, such as an APK (Android application package).

[0085] (2) Determine the call chain based on the application installation package. The call chain is used to indicate the call relationship between various methods in the target application and the active component to which each method belongs.

[0086] In some embodiments, the application installation package of the target application can be parsed based on product analysis to obtain the call relationship chain.

[0087] For example, an application installation package can be parsed to obtain all bytecode files (Class files) within the package. Each Class file can then be parsed to obtain all methods. The method body of each method can then be obtained. This process iterates through the body of each method in all Classes. By analyzing the body of each method, the call relationships within the method bodies can be obtained. This means understanding the dependencies and call order between the various instructions (such as method call instructions) within the method body. These dependencies and call orders constitute the call chain, thus yielding the call chain.

[0088] It should be noted that in a call chain, method identifiers are typically used to indicate the corresponding methods. Furthermore, the dependencies and call order between method identifiers indicate the dependencies and call order between methods. Method identifiers can be parameters used to indicate the target method, such as method name, method signature, or method descriptor.

[0089] In some embodiments, open-source tools such as Soot can be used to automatically parse the application installation package and execute the above-mentioned call chain generation logic, thereby automatically generating the call relationship chain corresponding to the application installation package.

[0090] (3) Based on at least one source code file and historical source code files, identify the target method in at least one source code file that has changed compared to the historical source code file.

[0091] In some embodiments, a second source file corresponding to a first source file can be selected from historical source file files. The first source file refers to any source file that has changed compared to historical source file files, and the second source file refers to the most recently committed source file in historical source file files, the source file before the change corresponding to the first source file. A first program structure interface file is determined based on the first source file, and a second program structure interface file is determined based on the second source file. The first program structure interface file is used to indicate the various methods in the first source file, and the second program structure interface file is used to indicate the various methods in the second source file. Based on the first program structure interface file and the second program structure interface file, the target method that has changed in the first source file is determined.

[0092] In some embodiments, when a tester submits a code change submission request, a declaration file for the code change submission request can also be sent, and the first source code file that has been changed in this code change request can be declared in the declaration file.

[0093] In other embodiments, the processor can determine the description information (such as the filename and directory path of the source file) of each currently submitted source file, and identify the most recently submitted source file among the historically submitted source files that has the same description information. Then, by comparing the sizes (such as byte length and lines of code) of the two source files, it can determine whether the source file has been modified. If the two source files are the same size, the currently submitted source file is considered unchanged; if the two source files are different sizes, the currently submitted source file is considered modified. The currently submitted source file is the first source file, and the corresponding historically submitted source file is the second source file.

[0094] In some embodiments, source code files can be converted into program structure interface files using specific development tools, such as the IntelliJ SDK (Software Development Kit).

[0095] It should be noted that the Program Structure Interface (PSI) can be understood as a semantic abstraction layer, which can identify the semantics of classes, methods, parameters, conditionals, etc. in the code. Based on this, the methods in the first source file can be determined through the first PSI file, and the methods in the second source file can be determined through the second PSI file. Furthermore, by comparing the methods in the first source file and the methods in the second source file, the target method that has been changed in the first source file can be determined.

[0096] In some embodiments, the program structure interface can also be understood as an abstract syntax tree (such as a first abstract syntax tree and a second abstract syntax tree). The abstract syntax tree includes multiple method nodes. By comparing the method nodes in the two abstract syntax trees, the method node that has changed in the first abstract syntax tree compared to the second abstract syntax tree can be obtained. The method corresponding to the method node is the target method that has changed in the first source code file.

[0097] In some embodiments, the target method that has been modified in the first source code file can be determined by comparing the identifiers (such as method names) of each method in the first program structure interface file with the identifiers (such as method names) of each method in the second program structure interface file. For example, if a method name exists only in the first program structure interface file but not in the second program structure interface file, the method corresponding to that method name can be considered the target method that has been modified in the first source code file.

[0098] In other embodiments, if a method name exists in both the first program structure interface file and the second program structure interface file, it can also be determined whether the method is the target method that has been modified in the first source code file by comparing the method bodies (i.e. code blocks, also called bodies) corresponding to the two method names, such as comparing the number of bytes or lines of code (size) of the method body.

[0099] For example, if a method name exists in both the first program structure interface file and the second program structure interface file, the number of lines of code in the method body corresponding to the method name in the two program structure interface files can be calculated separately. If the number of lines of code in the two method bodies is the same, the method is considered to have not been changed. If the number of lines of code in the two method bodies is different, the method is considered to be the target method that has been changed.

[0100] It should be noted that if a method name does not exist in the first program structure interface file but exists in the second program structure interface file, then the method corresponding to the method name can be considered to be a method deleted from the source code file submitted this time. For such methods, since they have been deleted in the new version (i.e., the source code file submitted this time), there is no need to test them.

[0101] In some embodiments, combined with Figure 3 Given a first source code file and a corresponding second source code file, the first program structure interface file corresponding to the first source code file and the second program structure interface file corresponding to the second source code file can be determined separately. By comparing the two program structure interface files, the target method that has been changed in the source code file can be obtained.

[0102] It should be noted that since a source file usually contains multiple methods, for any first source file and its corresponding second source file, multiple target methods may be obtained through comparison. That is, compared with the corresponding second source file, there are multiple target methods in the first source file that have changed. Alternatively, no target methods may be obtained through comparison. For example, although the first source file has changed, the change only involves parameter changes and does not involve method changes compared with the corresponding second source file.

[0103] (4) Based on the call relationship chain and the identifier of the target method, determine the identifier of the activity component to which the target method belongs.

[0104] In some embodiments, the identifier of the activity component to which the target method belongs can be determined by analyzing the call chain to identify which activity component the identifier of the target method was ultimately invoked to.

[0105] For example, since the lifecycle of an activity component is implemented through various callback methods, for any given method, the lifecycle methods of the activity components that directly or indirectly call that method can be found based on the call chain, thereby determining the identifier of the activity component to which that method belongs.

[0106] It should be noted that the identifier of the activity component to which the target method belongs refers to the unique name that indicates the activity component in an application, such as the FQN (Fully Qualified Name) of the class corresponding to the activity component. This fully qualified name includes the package name and the class name of the class.

[0107] Step 203: Based on the identifier of the target method and the identifier of the activity component to which the target method belongs, obtain the test cases corresponding to the target method.

[0108] In some embodiments, if the target method is the method modified in this instance, the test case identifier corresponding to the target method is determined by a mapping table based on the identifier of the target method and the identifier of the activity component to which the target method belongs. The mapping table is used to indicate the correspondence between the method identifier, the activity component identifier, and the test case identifier. Based on the test case identifier corresponding to the target method, the test case corresponding to the target method is obtained from the test case database. The test case database includes test cases corresponding to each method in each activity component, and different methods correspond to different test cases.

[0109] It should be noted that the method changed in this instance is the method mentioned above, which has a corresponding method name in both the first program structure interface file and the second program structure interface file, but the number of bytes or lines of code in the method body is different.

[0110] If the target method is the method being changed in this update, since it already exists in the previously submitted source code files, it can be assumed that the target method has already been tested. In other words, the test case database already contains test cases for the target method. Therefore, if the target method is the method being changed in this update, the test cases for that target method can be directly retrieved from the test case database.

[0111] In other embodiments, if the target method is a newly added method, a prompt message is displayed to prompt the tester to write test cases corresponding to the target method; and the test cases written by the tester for the target method are obtained.

[0112] It should be noted that the newly added method is the method corresponding to the method name that exists in the first program structure interface file but does not exist in the second program structure interface file.

[0113] If the target method is a newly added method, and it doesn't exist in the previously submitted source code files, it can be assumed that this target method has not been tested before. Typically, there are no corresponding test cases for this target method in the test case database either. Therefore, in this case, testers need to write test cases for this target method to test the method.

[0114] In some embodiments, the at least one source code file carried in the code change submission request may also include a newly added first source code file (i.e., there is no second source code file before the change in the historical source code files that corresponds to this source code file). For such a first source code file, a first program interface file can be determined based on the first source code file, and all methods in the first program structure interface file can be determined as the methods newly added in this instance.

[0115] Considering that in some scenarios, testers may have already written test cases for various methods in advance; or that a previously submitted source code file may have included and tested the method corresponding to the target method, but this method was deleted from a subsequent submission, the test case database may still contain test cases for that method even though it was not previously submitted. Therefore, in some embodiments, the existence of test cases for the target method in the test case database can be determined based on the identifier of the target method and the identifier of the activity component to which it belongs, using a mapping table.

[0116] For example, when it is determined that a test case representation corresponding to the target method exists in the mapping table by using the identifier of the target method and the identifier of the activity component to which the target method belongs, even if the target method is a newly added method (i.e., a method whose name exists in the first program structure interface file but not in the second program interface file), since the test case identifier corresponding to the target method exists in the mapping table, it indicates that the test case corresponding to the target method has been written in advance. Therefore, the test case corresponding to the target method can still be obtained from the test case database based on the identifier of the test case corresponding to the target method.

[0117] In some embodiments, the identifier of the test case corresponding to the target method can also be obtained; the identifier of the target method, the identifier of the activity component to which the target method belongs, and the identifier of the test case corresponding to the target method are stored in a mapping table, and the test case corresponding to the target method is stored in a test case database.

[0118] For test cases corresponding to a target method that have already been written, to facilitate subsequent testing of the target method, the identifier of the target method, the identifier of the activity component to which the target method belongs, and the identifier of the test case can be stored in a mapping table, and the test case can be stored in a test case database. This way, when testing the target method is required, the corresponding test case identifier can be determined based on the mapping table, and the test case can be retrieved from the test case database based on that identifier, allowing the target method to be tested using that test case.

[0119] Step 204: Based on the test cases corresponding to the target method, test the target application using automated test scripts.

[0120] In some embodiments, the processor may further include a test program to perform tests on the target application.

[0121] Considering that testers may submit multiple source code files at once, and each source code file may involve multiple modified target methods, in some embodiments, the identifiers of all modified target methods in the source code files carried in the code change submission request, as well as the test cases corresponding to each target method, can be determined based on all the test cases corresponding to all target methods. Then, the target application can be tested using automated test scripts.

[0122] In some embodiments, testers can write automated test scripts in advance and write them into memory. The processor can call the automated test scripts to import all test cases corresponding to the target methods into the automated test scripts, so as to perform automated testing on the target application through the automated test scripts.

[0123] In other embodiments, after obtaining the test cases corresponding to the target method, if the processor does not detect the automated test script, it can display automated test prompts to remind testers to write automated test scripts and perform testing on the target application based on the automated test scripts written by the testers and the test cases corresponding to the target method.

[0124] In some embodiments, combined with Figure 4Upon receiving a code change commit request, the processor can determine the first source file in the current commit and the corresponding second source file from previous commits based on the request. It then determines the first program structure interface file based on the first source file and the second program structure interface file based on the second source file. By comparing the first and second program structure interfaces, the processor obtains the identifier of the target method and, based on the call chain, the identifier of the active component to which the target method belongs. If the target method is a modified method, the processor determines the identifier of the corresponding test case based on the identifier of the target method and the identifier of the active component to which it belongs. Based on the identifier of the test case corresponding to the target method, test cases are retrieved from the test case database. If the target method is a newly added method, test cases written by testers are retrieved, thus accurately filtering the test cases corresponding to the target method. Finally, based on the automated test scripts and the filtered test cases corresponding to the target method, automated testing is implemented for this version (i.e., the modified version corresponding to this code change commit request).

[0125] In this embodiment, upon receiving a code change submission request for the target application, the identifier of the changed target method in the currently submitted source code file is determined using the currently submitted source code file and historically submitted source code files. This accurately identifies the changed target method in the current code change submission request, allowing testing of the target application to be performed only on test cases corresponding to the changed target method. However, considering that accurately identifying the changed target method in the source code file based solely on the source code file is insufficient, the system identifies the first changed source code file in the currently submitted source code file and the second source code file corresponding to the first source code file in historical source code files. Then, based on the first source code file, a first program structure interface file is determined, and based on the second source code file, a second program structure interface file is determined. This allows for accurate identification of the changed target method in the first source code file based on both the first and second program structure interface files.

[0126] Furthermore, considering that the methods for obtaining test cases will differ depending on the type of method change, the target methods are further subdivided into methods that have been modified in this instance and methods that have been added in this instance. Based on the different types of method changes, different test case acquisition processes are executed to improve the efficiency of test case acquisition. This allows for the rapid acquisition of test cases corresponding to all target methods that have been modified in the current code change submission request, thereby improving the accuracy of test cases. Based on the test cases corresponding to the target methods, automated test scripts are used to automate the testing of the target application, improving the testing efficiency of the application.

[0127] Figure 5This is a schematic diagram of the structure of an application testing device provided in an embodiment of this application. The application testing device can be implemented as part or all of the application testing equipment by software, hardware, or a combination of both. The application testing equipment can be... Figure 1 The processor shown. Please refer to... Figure 5 The device includes: a receiving module 501, a change determination module 502, a test case acquisition module 503, and a test module 504.

[0128] The receiving module 501 is used to receive code change submission requests from the target application, the code change submission requests carrying at least one source code file currently being submitted;

[0129] The change determination module 502 is used to determine, based on at least one source file and the historical source file of the target application submitted in the past, the identifier of the target method that has changed compared to the historical source file and the identifier of the active component to which the target method belongs.

[0130] The test case acquisition module 503 is used to acquire the test cases corresponding to the target method based on the identifier of the target method and the identifier of the activity component to which the target method belongs;

[0131] Test module 504 is used to test the target application using automated test scripts based on the test cases corresponding to the target method.

[0132] Optionally, the change determination module 502 specifically includes:

[0133] The application installer build submodule is used to build the application installer of the target application based on at least one source code file and historical source code files.

[0134] The Call Relationship Determination Submodule is used to determine the call relationship chain based on the application installation package. The call relationship chain is used to indicate the call relationship between various methods in the target application and the active component to which each method belongs.

[0135] The target method determination submodule is used to determine the identifier of the target method in at least one source file that has changed compared to the historical source file, based on at least one source file and historical source files;

[0136] The Activity Component Determination Submodule is used to determine the identifier of the activity component to which the target method belongs, based on the call relationship chain and the identifier of the target method.

[0137] Optionally, the target method determines the submodule, specifically for:

[0138] Select the second source file corresponding to the first source file from the historical source file files. The first source file refers to any source file in at least one source file that has changed compared to the historical source file files. The second source file refers to the most recently committed source file in the historical source file files, which is the source file before the change corresponding to the first source file files.

[0139] A first program structure interface file is determined based on a first source code file, and a second program structure interface file is determined based on a second source code file. The first program structure interface file is used to indicate the various methods in the first source code file, and the second program structure interface file is used to indicate the various methods in the second source code file.

[0140] Based on the first program structure interface file and the second program structure interface file, the target method that has been modified in the first source code file is determined.

[0141] Optionally, the test case acquisition module 503 is specifically used for:

[0142] If the target method is the method that has been modified in this operation, the test case identifier corresponding to the target method is determined through a mapping table based on the identifier of the target method and the identifier of the activity component to which the target method belongs. The mapping table is used to indicate the correspondence between the method identifier, the activity component identifier, and the test case identifier.

[0143] Based on the test case identifier corresponding to the target method, the test cases corresponding to the target method are retrieved from the test case database. The test case database includes test cases corresponding to each method in each activity component, with different methods corresponding to different test cases.

[0144] Optionally, the test case acquisition module 503 is also used for:

[0145] If the target method is a newly added method, a prompt message will be displayed, which will prompt the testers to write test cases for the target method.

[0146] Obtain the test cases written by the testers for the target method.

[0147] Optionally, the test case acquisition module 503 is also used for:

[0148] Obtain the identifier of the test case corresponding to the target method;

[0149] Store the identifier of the target method, the identifier of the activity component to which the target method belongs, and the identifier of the test case corresponding to the target method in the mapping table, and store the test cases corresponding to the target method in the test case database.

[0150] In this embodiment, upon receiving a code change submission request for the target application, the identifier of the changed target method in the currently submitted source code file is determined using the currently submitted source code file and historically submitted source code files. This accurately identifies the changed target method in the current code change submission request, allowing testing of the target application to be performed only on test cases corresponding to the changed target method. However, considering that accurately identifying the changed target method in the source code file based solely on the source code file is insufficient, the system identifies the first changed source code file in the currently submitted source code file and the second source code file corresponding to the first source code file in historical source code files. Then, based on the first source code file, a first program structure interface file is determined, and based on the second source code file, a second program structure interface file is determined. This allows for accurate identification of the changed target method in the first source code file based on both the first and second program structure interface files.

[0151] Furthermore, considering that the methods for obtaining test cases will differ depending on the type of method change, the target methods are further subdivided into methods that have been modified in this instance and methods that have been added in this instance. Based on the different types of method changes, different test case acquisition processes are executed to improve the efficiency of test case acquisition. This allows for the rapid acquisition of test cases corresponding to all target methods that have been modified in the current code change submission request, thereby improving the accuracy of test cases. Based on the test cases corresponding to the target methods, automated test scripts are used to automate the testing of the target application, improving the testing efficiency of the application.

[0152] It should be noted that the application testing device provided in the above embodiments is only illustrated by the division of the above functional modules when testing applications. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the application testing device and the application testing method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0153] Figure 6 This is a structural block diagram of a computer device 600 provided in an embodiment of this application. The terminal 600 can be a portable mobile terminal, such as a smartphone, tablet computer, laptop computer, or desktop computer. The computer 600 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.

[0154] Typically, computer device 600 includes a processor 601 and a memory 602.

[0155] Processor 601 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 601 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 601 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 601 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 601 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0156] Memory 602 may include one or more computer-readable storage media, which may be non-transitory. Memory 602 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in memory 602 is used to store at least one instruction, which is executed by processor 601 to implement the test method of the application provided in the method embodiments of this application.

[0157] In some embodiments, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of the testing method for the application program in the above embodiments. For example, the computer-readable storage medium may be a ROM, RAM, CD-ROM, magnetic tape, floppy disk, or optical data storage device.

[0158] It is worth noting that the computer-readable storage medium mentioned in the embodiments of this application can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.

[0159] It should be understood that all or part of the steps of the above embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-described computer-readable storage medium.

[0160] That is, in some embodiments, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the steps of the application testing method described above.

[0161] It should be understood that "at least one" as mentioned herein refers to one or more, and "multiple" refers to two or more. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. In addition, in order to clearly describe the technical solutions of the embodiments of this application, the terms "first," "second," etc., are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and the terms "first," "second," etc., are not necessarily different.

[0162] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0163] The above descriptions are embodiments provided in this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A test method of an application program, characterized by, The method comprises: receiving a code change submission request of a target application, the code change submission request carrying at least one source code file of a current submission; based on the at least one source code file and historical source code files of the target application of historical submissions, determining the identification of a target method in the at least one source code file that has changed compared to the historical source code files and the identification of an active component to which the target method belongs; based on the identification of the target method and the identification of the active component to which the target method belongs, obtaining a test case corresponding to the target method; based on the test case corresponding to the target method, testing the target application through an automated test script; the method further comprises: obtaining the identification of the test case corresponding to the target method; storing the identification of the target method, the identification of the active component to which the target method belongs, and the identification of the test case corresponding to the target method to the mapping relationship table, and storing the test case corresponding to the target method to the test case database. based on the at least one source code file and the historical source code files, constructing an application installation package of the target application; based on the at least one source code file and the historical source code files, constructing an application installation package of the target application; based on the identification of the target method and the identification of the active component to which the target method belongs, determining whether the test case corresponding to the target method exists in the test case database through the mapping relationship table; if the test case corresponding to the target method exists in the test case database, even if the target method is a newly added method, the test case corresponding to the target method is still obtained from the test case database based on the identification of the test case corresponding to the target method; if the test case corresponding to the target method does not exist in the test case database and the target method is a newly added method, a prompt information is displayed, the prompt information is used to prompt a test personnel to write the test case corresponding to the target method; obtaining the test case written by the test personnel for the target method; 2. The method of claim 1, wherein, the method further comprises: obtaining the identification of the test case corresponding to the target method; storing the identification of the target method, the identification of the active component to which the target method belongs, and the identification of the test case corresponding to the target method to the mapping relationship table, and storing the test case corresponding to the target method to the test case database. determine a calling relationship chain based on the application installation package, the calling relationship chain being used to indicate a calling relationship between methods in the target application program and an activity component to which each method belongs; determine an identifier of a target method in the at least one source code file that has changed compared to the historical source code file based on the at least one source code file and the historical source code file; determine an identifier of an activity component to which the target method belongs based on the calling relationship chain and the identifier of the target method.

3. The method of claim 2, wherein, The method further includes: selecting a second source code file corresponding to a first source code file from the historical source code file, the first source code file being any one of the at least one source code file that has changed compared to the historical source code file, and the second source code file being a source code file that has been most recently committed and that is before the change of the first source code file in the historical source code file; determining a first program structure interface file based on the first source code file and determining a second program structure interface file based on the second source code file, the first program structure interface file being used to indicate methods in the first source code file, and the second program structure interface file being used to indicate methods in the second source code file; determining the target method in the first source code file that has changed based on the first program structure interface file and the second program structure interface file.

4. A test apparatus for an application program, characterized by comprising: The apparatus includes: a receiving module configured to receive a code change submission request of a target application program, the code change submission request carrying at least one source code file that is currently submitted; a change determination module configured to determine an identifier of a target method in the at least one source code file that has changed compared to a historical source code file of the target application program that is historically submitted and an identifier of an activity component to which the target method belongs based on the at least one source code file and the historical source code file of the target application program that is historically submitted; a test case acquisition module configured to acquire a test case corresponding to the target method based on the identifier of the target method and the identifier of the activity component to which the target method belongs; a testing module configured to test the target application program through an automated test script based on the test case corresponding to the target method; The test case acquisition module is configured to: if the target method is a method that is changed this time, determine an identifier of a test case corresponding to the target method based on the identifier of the target method and the identifier of the activity component to which the target method belongs through a mapping relationship table, the mapping relationship table being used to indicate a corresponding relationship between a method identifier, an activity component identifier, and a test case identifier; and acquire the test case corresponding to the target method from a test case database based on the identifier of the test case corresponding to the target method, the test case database including test cases corresponding to methods in each activity component, different methods corresponding to different test cases. determining, based on the identification of the target method and the identification of the activity component to which the target method belongs, whether the test case corresponding to the target method exists in the test case database according to the mapping relationship table; if the test case corresponding to the target method exists in the test case database, obtaining the test case corresponding to the target method from the test case database based on the identification of the test case corresponding to the target method, even if the target method is a newly added method this time; if the test case corresponding to the target method does not exist in the test case database and the target method is a newly added method this time, displaying prompt information for prompting a tester to write the test case corresponding to the target method; and obtaining the test case written by the tester for the target method. The apparatus further includes modules for performing the following operations: obtaining the identification of the test case corresponding to the target method; storing the identification of the target method, the identification of the activity component to which the target method belongs, and the identification of the test case corresponding to the target method into the mapping relationship table, and storing the test case corresponding to the target method into the test case database.

5. A computer device, comprising: The computer device includes a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to realize the steps of the method in any one of claims 1-3.

6. A computer-readable storage medium, characterized in that, The storage medium has a computer program stored therein, and the computer program is executed by the processor to realize the steps of the method in any one of claims 1-3.

7. A computer program product comprising instructions, characterized in that, When the instructions run on the computer, the computer executes the steps of the method in any one of claims 1-3. When the instructions run on the computer, the computer executes the steps of the method in any one of claims 1-3.

Citation Information

Patent Citations

  • Unit testing method and device, equipment, storage medium and program product

    CN113127357A

  • Regression testing method and device of application program, computer equipment and storage medium

    CN116107889A