Application testing method, device, computer equipment and storage medium

By acquiring and injecting exception rules in the target testing environment, simulating exception scenarios, the problem of insufficient testing of exception scenarios in the existing technology is solved, and the application robustness and stability guarantee is achieved.

CN115185815BActive Publication Date: 2025-04-18PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210682240.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-15
Publication Date
2025-04-18
Estimated Expiration
2042-06-15

AI Technical Summary

Technical Problem

The prior art is not sufficient for the exception scenarios of the test application, which makes the application robustness difficult to guarantee, especially when some test environments do not support manual simulation of exception scenarios.

Method used

By starting the target test application in the target test environment, obtaining the target exception rules from the server where the test environment is deployed, and injecting exception trigger events into the test cases to simulate the exception scenario, collect test data, and determine the test results.

Benefits of technology

It realizes that the abnormal scenario test of the application is more comprehensive and sufficient, ensures the robustness of the application, and can effectively ensure the stability of the application in various testing environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185815B_ABST
    Figure CN115185815B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an application testing method, apparatus, computer equipment and storage medium. The scheme starts a target test application in a target test environment, obtains a target exception rule of the target test application from a target test environment server that deploys the target test environment, and the target exception rule includes a target class of the target test application, a target method in the target class that needs to have an exception, and an exception triggering event of the target method; according to the exception triggering event in the target exception rule, the exception triggering event is injected into a test case corresponding to the target test application to obtain a target test case; the target test case is run through the target test application; test data in the target test case is collected, and based on the test data and the target class and target method in the target exception rule, the test result when the test data hits the target exception rule is determined, thereby ensuring the robustness of the application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to an application testing method, device, computer equipment and storage medium. Background Art

[0002] With the development of society, computer systems are applied to all aspects of people's lives, and their software forms are becoming more and more complex and diverse, such as applications, clients, etc. Since testing is an important part of the software development process, sufficient testing is required to ensure the robustness of the application.

[0003] In the process of testing applications, testing of abnormal scenarios plays a vital role. However, since many abnormal scenarios are simulated manually and some test environments do not support manual simulation of abnormal scenarios, the testing of abnormal scenarios is not sufficient, making it difficult to ensure the robustness of the application. Summary of the invention

[0004] The embodiments of the present application provide an application testing method, apparatus, computer equipment, and storage medium, which can ensure the robustness of the application.

[0005] The present application embodiment provides an application testing method, including:

[0006] Start the target test application in the target test environment, and obtain the target exception rule of the target test application from the target test environment server that deploys the target test environment, wherein the target exception rule includes the target class of the target test application, the target method in the target class that needs to have an exception, and the exception triggering event of the target method;

[0007] According to the above-mentioned exception triggering event in the above-mentioned target exception rule, inject the above-mentioned exception triggering event into the test case corresponding to the above-mentioned target test application to obtain the target test case;

[0008] Run the above target test cases through the above target test application;

[0009] The test data in the target test case is collected, and based on the test data and the target class and the target method in the target exception rule, the test result when the test data hits the target exception rule is determined.

[0010] Accordingly, the embodiment of the present application further provides an application testing device, including:

[0011] A rule acquisition module is used to start a target test application in a target test environment, and obtain a target exception rule of the target test application from a target test environment server that deploys the target test environment. The target exception rule includes a target class of the target test application, a target method in the target class that needs to have an exception, and an exception triggering event of the target method.

[0012] An exception injection module is used to inject the above exception triggering event into the test case corresponding to the above target test application according to the above exception triggering event in the above target exception rule to obtain the target test case;

[0013] A running module, used to run the above target test case through the above target test application;

[0014] The result determination module is used to collect the test data in the above-mentioned target test case, and determine the test result when the above-mentioned test data hits the above-mentioned target exception rule based on the above-mentioned test data and the above-mentioned target class and target method in the above-mentioned target exception rule.

[0015] In some embodiments, the application testing device further includes:

[0016] A first relationship configuration module, used to configure a first corresponding relationship between a test application identifier and a test environment identifier through a management platform;

[0017] A second relationship configuration module, used to configure the exception rule through the management platform, and configure a second corresponding relationship between the exception rule and the test application identifier;

[0018] An identification determination module, used to determine the test environment identification corresponding to each abnormal rule according to the first corresponding relationship and the second corresponding relationship;

[0019] The rule distribution module is used to distribute the above-mentioned exception rules to the test environment server corresponding to the above-mentioned test environment identifier.

[0020] In some embodiments, the rule acquisition module includes:

[0021] A calling unit, configured to send a target application identifier and a target test environment identifier corresponding to the target test application to a management platform by calling an agent corresponding to the target test application, so that the management platform sends the target application identifier to a target test environment server corresponding to the target test environment identifier;

[0022] The rule acquisition unit is used to acquire the target exception rule of the target test application sent by the target test environment server according to the target application identifier.

[0023] In some embodiments, the second relationship configuration module includes:

[0024] An interface display unit, used to display an abnormal rule configuration interface in the above management platform, wherein the above configuration interface includes an acquisition control;

[0025] An operation response unit, configured to display a rule interface in the management platform in response to a trigger operation on the acquisition control, wherein the rule interface includes at least two preset rules;

[0026] The rule determination unit is used to determine the preset rule corresponding to the selection operation as the abnormal rule in response to the selection operation on the preset rule.

[0027] In some embodiments, the application testing device further includes:

[0028] A rule validation module is used to validate the above exception rules when the above exception rules are configured;

[0029] The rule failure module is used to fail the above-mentioned exception rule when the number of times the target test case is generated based on the above-mentioned exception rule is equal to a preset number of times.

[0030] In some embodiments, the above-mentioned abnormal injection module includes:

[0031] The exception injection unit is used to read the target exception rule by calling the agent corresponding to the target test application, so that the agent injects the code corresponding to the exception triggering event into the test case corresponding to the target test application through bytecode enhancement technology.

[0032] In some embodiments, the target exception rule further includes target exception processing logic after the exception triggering event occurs, and the result determination includes:

[0033] A logic acquisition unit, used to acquire, based on the test data, actual exception handling logic when the test data hits the exception rule;

[0034] The result determination unit is used to determine that the test result is an abnormal result if the target exception handling logic and the actual exception handling logic are different.

[0035] Correspondingly, an embodiment of the present application also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes any application testing method provided in the embodiments of the present application.

[0036] Correspondingly, an embodiment of the present application further provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for loading by a processor to execute the above application testing method.

[0037] The embodiment of the present application starts the target test application in the target test environment, obtains the target exception rule of the target test application from the target test environment server that deploys the target test environment, and the target exception rule includes the target class of the target test application, the target method in the target class that needs to have an exception, and the exception trigger event of the target method. By injecting the exception trigger event into the test case corresponding to the target test application according to the exception trigger event in the target exception rule, the target test case is obtained, and the target test case corresponds to the abnormal scenario of the test application, so that the target test case is run through the target test application to collect the test data in the target test case, and based on the test data and the target class and target method in the target exception rule, the test result when the test data hits the target exception rule is determined, that is, the test result of the test application in the abnormal scenario is obtained, so that the robustness of the application is guaranteed by testing the test application based on the abnormal scenario. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0039] Figure 1 A flowchart of an application testing method provided in an embodiment of the present application.

[0040] Figure 2 A schematic diagram of the structure of an application testing system provided in an embodiment of the present application.

[0041] Figure 3 A structural block diagram of an application testing device provided in an embodiment of the present application.

[0042] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0044] The embodiments of the present application provide an application testing method, device, storage medium and computer equipment. Specifically, the application testing method of the embodiments of the present application can be performed by a computer device, wherein the computer device can be a server, or a terminal or other device. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a desktop computer, a laptop computer, a tablet computer, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application is not limited here.

[0045] For example, the computer device may be a terminal, which may start a target test application under a target test environment, obtain a target exception rule for the target test application from a target test environment server that deploys the target test environment, wherein the target exception rule includes a target class for the target test application, a target method in the target class where an exception needs to occur, and an exception triggering event for the target method; according to the exception triggering event in the target exception rule, inject the exception triggering event into a test case corresponding to the target test application to obtain a target test case; run the target test case through the target test application; collect test data from the target test case, and determine a test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule.

[0046] Based on the above problems, the embodiments of the present application provide a first application testing method, apparatus, computer equipment and storage medium, which can ensure the robustness of the application.

[0047] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.

[0048] An embodiment of the present application provides an application testing method, which can be executed by a terminal or a server. The embodiment of the present application is described by taking the application testing method executed by a terminal as an example.

[0049] See also Figure 1 , Figure 1 A schematic diagram of a flow chart of an application testing method provided in an embodiment of the present application. The specific flow of the application testing method may be as follows:

[0050] 101. Start a target test application in a target test environment, and obtain a target exception rule of the target test application from a target test environment server that deploys the target test environment.

[0051] Among them, the test environment is a test environment that matches the test application. One test application corresponds to at least one set of test environments, such as Feature Acceptance Test environment (FAT), User Acceptance Test environment (UAT), System Integration Test environment (SIT), etc. The above-mentioned target test environment is the test environment required for testing the target test application at present. By starting the target test application under the target test environment, the target test application is tested under the test environment, and the test result corresponding to the test environment is obtained.

[0052] Among them, the exception rule is a rule configured by the user based on the exception scenario he wants to verify, so that the test application is forced to face the corresponding exception scenario through the rule. The exception rule includes the class, method and exception triggering event of the test application, and accordingly, the target exception rule includes the target class of the target test application, the target method in the target class where an exception needs to occur, and the exception triggering event of the target method. The above class is defined by abstracting some things with the same characteristics, the above method is the same function or characteristic corresponding to the class, and the above exception triggering event is the event that causes the method to be abnormal. The exception triggering event varies according to the test application, including but not limited to the thread pool being occupied, the connection pool being occupied, the method delay, the CPU being full, the memory overflow and other exception triggering events.

[0053] It is understandable that there are many classes in the test application, and different classes implement different functions, and usually need to call each other to implement specific functions, such as class A calls class B, and class B calls class C. At this time, there will be two situations when executing class A. The first is that when class A calls class B, it can return normally, indicating that there is no exception at present, and then class B will continue to process; the second is that if class A calls class B, class B triggers the exception triggering event in the above target exception rule, so it is necessary to perform corresponding exception handling through the corresponding exception handling logic in the test application. The exception handling method can be to return the exception information about class B. For example, if class B is a class used for file writing and the exception triggering event of class B is set to insufficient disk space, the corresponding exception handling logic of class B can return "writing failed due to insufficient disk space". However, in the production environment, it is impossible to predict at which link the exception will suddenly occur, so the exception handling logic in each class needs to be covered by the test, so it is necessary to set the class in the exception rule to facilitate targeted testing of each class.

[0054] Exemplarily, humans can be abstracted as an object, thereby defining a target class of humans. Since humans eat, run, etc., the target methods corresponding to this target class can be eating and running. However, when a person is running, there is a small probability that he or she will not be able to complete the run. The reason for not being able to complete the run may be abnormal triggering events such as spraining the ankle or meeting an acquaintance.

[0055] In this embodiment, since different test environments are deployed in different servers, in order to test the target test application in the corresponding test environment, the exception rules pre-configured by the user need to be placed in the test environment server corresponding to the test environment. Therefore, when testing the target test application in a certain target test environment, it is only necessary to obtain the target exception rules pre-configured by the user from the target test environment server where the environment is deployed.

[0056] In some embodiments, before obtaining the target exception rule of the target test application, at least one exception rule needs to be pre-configured, and the at least one configured exception rule is distributed to the corresponding test environment server. For example, the configuration operation of the exception rule can be obtained through the touch screen of the terminal. After the exception rule is configured based on the configuration operation, the exception rule is stored in the corresponding test environment server. Alternatively, the configuration can be performed through a third-party device. The third-party configuration can be a management platform. After the exception rule is configured through the management platform, the exception rule is stored in the corresponding test environment server. Figure 2 As shown, Figure 2 This is a schematic diagram of the application test system. Figure 2 The management platform and agent in the application testing method are implemented.

[0057] Specifically, the test application identifier of the test application can be obtained, and the test application identifier is used to represent the test application, and then the IP address of the test environment server and the corresponding exception rule are obtained, so as to associate the three, and store the associated exception rule in the test environment server. Among them, the above-mentioned test application identifier can be a test application ID, such as 60458, 60001, and the specific identifier can be set according to user needs, including but not limited to a combination of letters, numbers, and symbols, which is not limited here.

[0058] Furthermore, since the test application corresponds to multiple test environments, and different test environments are deployed in different test environment servers, it is not easy to clearly locate the test environment server currently required by the target test application only through the IP address of the test environment server. Therefore, it is necessary to further locate the test environment server in combination with the test environment, that is, to use the test environment name of the test environment server for identification, that is, to combine the test environment name and the IP address of the test environment server as the test environment identifier, and associate it with the test application identifier, thereby establishing a relationship between the test application and the test environment server.

[0059] Specifically, it may include: configuring a first correspondence between a test application identifier and a test environment identifier through an application management module in a management platform; configuring exception rules through an exception rule configuration management module in the management platform, and configuring a second correspondence between the exception rules and the test application identifier; determining the test environment identifier corresponding to each exception rule according to the first correspondence and the second correspondence; and distributing the exception rules to the test environment server corresponding to the test environment identifier through an exception rule distribution module in the management platform.

[0060] In this embodiment, a first correspondence between a test application identifier and a test environment identifier, and a second correspondence between an exception rule and a test application identifier are established respectively to facilitate user management. Thus, the test environment corresponding to the exception rule can be obtained through the application identifier and the test environment identifier in the first correspondence and the second correspondence, and the exception rule is distributed to the corresponding test environment service according to the IP address in the test environment identifier.

[0061] In the embodiment of the present invention, "first" and "second" are only used to distinguish the corresponding relationship and have no other special meanings.

[0062] For example, the first correspondence can be set to "60001-FAT-192.0.0.1", "60458-FAT-192.0.0.2", etc., where "FAT" is the name of the test environment, that is, the functional acceptance test environment; "192.0.0.1" and "192.0.0.2" are the IP addresses of the test environment servers. The second correspondence can be set to 60001-class-method-abnormal trigger event, where "class-method-abnormal trigger event" is an abnormal rule.

[0063] Specifically, the test application identifier and the test environment identifier may be added, deleted, modified, etc. in advance through a corresponding configuration interface in the management platform, thereby constructing the above-mentioned first corresponding relationship and the above-mentioned second corresponding relationship.

[0064] In some embodiments, since the above-mentioned management platform is connected to multiple sets of test environment servers, and the management platform is connected to different test environment servers through different interfaces, in order to facilitate the call identification of the corresponding interface and obtain the target exception rules from the correct target test environment server, it is necessary to obtain the target exception rules of the target test application from the target test environment server that deploys the target test environment based on the test environment identifier obtained above.

[0065] Specifically, it may include: calling the agent corresponding to the target test application to send the target application identifier and the target test environment identifier corresponding to the target test application to the management platform through a message queue, so that the management platform sends the target application identifier to the target test environment server corresponding to the target test environment identifier; obtaining the target exception rule of the target test application sent by the target test environment server according to the target application identifier through the agent's receiving exception rule module, thereby storing the target exception rule locally and using it when the target test application needs to be tested.

[0066] Specifically, it may also include: calling the agent corresponding to the target test application to send the target application identifier corresponding to the target test application to the target test environment server corresponding to the target test environment identifier through a message queue; obtaining the target exception rule of the target test application sent by the target test environment server according to the target application identifier through the agent's receiving exception rule module, thereby storing the target exception rule locally and using it when the target test application needs to be tested.

[0067] In some embodiments, the above-mentioned configuration of exception rules through the management platform can select pre-set rules through the management platform, or modify the pre-set rule template through the management platform, or configure the exception rules by itself based on the blank template, and further configure the exception rules in the rule template or blank template by adding operations, deleting operations, modifying operations, taking effect operations, and invalidating operations.

[0068] Specifically, it may include: displaying an abnormal rule configuration interface in the management platform, the configuration interface may include a first acquisition control, the user may trigger the first acquisition control, and thus in response to the triggering operation of the first acquisition control, a corresponding rule interface is displayed, the rule interface may include at least two preset rules, that is, rules pre-set by the user and rules that can be used directly, receiving a user's selection operation on the preset rule, and responding to the selection operation on the preset rule to determine the preset rule corresponding to the selection operation as an abnormal rule.

[0069] Specifically, it may also include: displaying the exception rule configuration interface in the management platform, the configuration interface may include a second acquisition control, the user can trigger the second acquisition control, so as to display the corresponding template interface in response to the triggering operation of the second acquisition control, and receive the user's operation information on the template interface to modify the rule template corresponding to the template interface according to the operation information, so as to finally obtain the exception rules of the test application.

[0070] In the embodiment of the present invention, "first" and "second" are only used to distinguish the acquisition controls and have no other special meanings.

[0071] In some embodiments, since there are many people testing the test application based on the same test environment, in order to avoid affecting other people's tests, the exception rules configured by the user can be managed by setting the effective state and the invalid state, that is, by only reading the exception rules in the effective state, the exception rules in the effective state can be processed accordingly, that is, the exception rule is set to the effective state when the user needs to use it, and the exception rule is set to the invalid state when the user does not need to use it, such as when the test is completed. After being set to the invalid state, if the user needs the exception rule in the invalid state again, the exception rule in the invalid state can be reset to the effective state.

[0072] Specifically, after configuring the exception rules through the management platform, the method may further include: when the exception rule configuration is completed, taking effect on the exception rule; when the number of target test cases generated based on the exception rule is equal to a preset number, making the exception rule invalid.

[0073] The above-mentioned validation process is to set the rule state of the exception rule to the validation state; the above-mentioned invalidation process is to set the rule state of the exception rule to the invalid state. For example, if the exception rule needs to be used for two consecutive tests, the target test case needs to be generated twice based on the exception rule. When it is detected that the number of times the exception rule generates the target test case is two times, the rule state of the exception rule is set to the invalid state.

[0074] In some embodiments, since different users have different needs for using exception rules, the corresponding usage time of the exception rules may also be different. Therefore, for the convenience of management, a corresponding timestamp can be further configured in the exception rules, and the timestamp is the time when the exception rule can be used. Accordingly, before using the target exception rule, it is necessary to determine the timestamp corresponding to the target exception, so as to judge the timestamp corresponding to the target exception rule. When the time corresponding to the timestamp is within the validity period, the target exception rule can be subsequently processed, that is, the target test case is obtained based on the target exception rule; when the time corresponding to the timestamp has expired, the target exception rule can be deleted from the local, and when there is a demand next time, it can be obtained again from the corresponding server.

[0075] 102. According to the exception triggering event in the target exception rule, the exception triggering event is injected into the test case corresponding to the target test application to obtain the target test case.

[0076] Among them, a test case refers to a description of a test task for a pending software product, which embodies the test plan, method, technology and strategy, etc. Therefore, by injecting an abnormal trigger event into the test case, the target test case is obtained, so as to trigger the abnormal trigger event during the execution of the target test case.

[0077] Specifically, injecting an exception trigger event into a test case corresponding to a target test application may include: reading a target exception rule by calling an injection exception module in an agent corresponding to the target test application, so that the agent injects a code corresponding to the exception trigger event into the test case corresponding to the target test application through bytecode enhancement technology. The agent may inject the exception trigger event into the test case through bytecode enhancement technology based on the secondary development test tool ChaosBlade.

[0078] Exemplarily, if the above-mentioned abnormal trigger event is an event of encountering an acquaintance during running, that is, a person is unable to complete the run due to encountering an acquaintance, then injecting the abnormal trigger event into the test case is equivalent to implanting an acquaintance in the running scene corresponding to the test case, thereby obtaining the target test case corresponding to the abnormal scene.

[0079] In some embodiments, when testing a target test application, it may be necessary to verify the phenomenon of abnormal scenarios corresponding to at least two target exception rules of the target test application at one time. Therefore, when there are at least two target exception rules, it is necessary to obtain the priorities corresponding to the at least two target exception rules, so as to inject exception trigger events into the test cases corresponding to the target test application in sequence according to the priorities.

[0080] 103. Run the target test case through the target test application.

[0081] 104. Collect test data in the target test case, and determine the test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule.

[0082] In this embodiment, test data of the target test application will be collected during the testing process, including test data of each class of the target test application corresponding to the test case. When the test data hits the target exception rule, it means that the current application has run to the exception scenario required by the user. The actual exception handling logic corresponding to the exception scenario is determined from the test data, and the corresponding test result is determined according to the actual exception handling logic.

[0083] In some embodiments, since the exception handling logic of the test application for the exception triggering event is originally provided by the application, and the role of the target exception rule is to prompt the application to trigger the exception triggering event, so as to feedback the corresponding exception handling logic of the application to verify whether the exception handling logic of the application is robust, that is, to determine the corresponding test results, that is, to judge whether the exception handling logic is consistent with expectations. Therefore, the above-mentioned target exception rule can also include the target exception handling logic after the exception triggering event occurs, that is, if the corresponding exception triggering event is insufficient disk space under the file writing method, the corresponding target exception handling logic may return "writing failed due to insufficient disk space".

[0084] The above-mentioned determination of the test result when the test data hits the target exception rule may specifically include: based on the test data, obtaining the actual exception processing logic when the test data hits the exception rule; if the target exception processing logic and the actual exception processing logic are different, determining that the test result is a result exception.

[0085] For example, if the current target exception rule corresponds to an abnormal scenario of file writing failure, and the target exception handling logic in the target exception rule is that the application returns a friendly prompt message, such as "Writing failed due to insufficient disk space", and the actual exception handling logic in the test data is that the test application returns an "error", therefore, by comparing the target exception handling logic and the actual exception handling logic, they are different, indicating that the test result is abnormal, and relevant staff need to continue to process the test application based on the test result.

[0086] It is understandable that the test application will handle some abnormal scenarios. For example, when the program is running, the disk space is full and the file cannot be written. At this time, the application will recognize that an exception occurred when writing the file, and will perform corresponding processing according to its exception processing logic, and return an error message to the caller "Writing failed due to insufficient disk space". By verifying the processing logic of the test application under abnormal scenarios, it is verified whether the test application will cause program crashes, no response, etc. due to abnormal scenarios, and whether the application is processed as expected. Then, by judging whether the test application handles the abnormal scenarios correctly, the robustness of the test application is guaranteed.

[0087] It is understandable that since the classes in the test application do not correspond to only one method, when executing the target test case, there will be some classes that include methods that will not hit the target exception rule. Therefore, if a class or a method in a class does not hit the exception rule, it can be processed according to the normal processing logic of the test application under this method. For example, suppose that there is a class A calling class B in the test application, and class B calling class C. If the target class in the current target exception rule is class C, then when class A calls class B, it will not hit the target exception rule. Therefore, it can be processed according to the normal processing logic of the test application until the process reaches class B calling class C, and it is determined whether the exception rule is hit according to the test data corresponding to class C.

[0088] An embodiment of the present application discloses an application testing method, which includes: starting a target test application in a target test environment, obtaining a target exception rule for the target test application from a target test environment server that deploys the target test environment, wherein the target exception rule includes a target class for the target test application, a target method in the target class that needs to have an exception, and an exception triggering event for the target method; injecting the exception triggering event into a test case corresponding to the target test application according to the exception triggering event in the target exception rule to obtain a target test case; running the target test case through the target test application; collecting test data in the target test case, and determining a test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule, thereby ensuring the robustness of the application.

[0089] In order to better implement the application testing method provided in the embodiment of the present application, the embodiment of the present application also provides an application testing device based on the above application testing method. The meanings of the terms are the same as those in the above application testing method, and the specific implementation details can refer to the description in the method embodiment.

[0090] See also Figure 3 , Figure 3 A structural block diagram of an application testing device provided in an embodiment of the present application, the device comprising:

[0091] The rule acquisition module 301 is used to start the target test application in the target test environment, and obtain the target exception rules of the target test application from the target test environment server that deploys the target test environment. The target exception rules include the target class of the target test application, the target method in the target class that needs to have an exception, and the exception triggering event of the target method.

[0092] The exception injection module 302 is used to inject the exception triggering event into the test case corresponding to the target test application according to the exception triggering event in the target exception rule to obtain the target test case.

[0093] The running module 303 is used to run the above target test case through the above target test application.

[0094] The result determination module 304 is used to collect the test data in the target test case, and determine the test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule.

[0095] In some embodiments, the application testing device further includes:

[0096] The first relationship configuration module is used to configure a first corresponding relationship between a test application identifier and a test environment identifier through a management platform.

[0097] The second relationship configuration module is used to configure the exception rules through the above management platform, and configure the second corresponding relationship between the above exception rules and the above test application identifier.

[0098] The identification determination module is used to determine the test environment identification corresponding to each abnormal rule according to the first corresponding relationship and the second corresponding relationship.

[0099] The rule distribution module is used to distribute the above-mentioned exception rules to the test environment server corresponding to the above-mentioned test environment identifier.

[0100] In some embodiments, the rule acquisition module includes:

[0101] The calling unit is used to send the target application identifier and target test environment identifier corresponding to the target test application to the management platform by calling the agent corresponding to the target test application, so that the management platform sends the target application identifier to the target test environment server corresponding to the target test environment identifier.

[0102] The rule acquisition unit is used to acquire the target exception rule of the target test application sent by the target test environment server according to the target application identifier.

[0103] In some embodiments, the second relationship configuration module includes:

[0104] The interface display unit is used to display the abnormal rule configuration interface in the above management platform, and the above configuration interface includes an acquisition control.

[0105] The operation response unit is used to display the rule interface in the management platform in response to the trigger operation of the acquisition control, and the rule interface includes at least two preset rules.

[0106] The rule determination unit is used to determine the preset rule corresponding to the selection operation as the abnormal rule in response to the selection operation on the preset rule.

[0107] In some embodiments, the application testing device further includes:

[0108] The rule validation module is used to validate the above exception rules when the above exception rules are configured.

[0109] The rule failure module is used to fail the above-mentioned exception rule when the number of times the target test case is generated based on the above-mentioned exception rule is equal to a preset number of times.

[0110] In some embodiments, the above-mentioned abnormal injection module includes:

[0111] The exception injection unit is used to read the target exception rule by calling the agent corresponding to the target test application, so that the agent injects the code corresponding to the exception triggering event into the test case corresponding to the target test application through the enhancement technology.

[0112] In some embodiments, the target exception rule further includes target exception processing logic after the exception triggering event occurs, and the result determination includes:

[0113] The logic acquisition unit is used to acquire, based on the test data, the actual exception handling logic when the test data hits the exception rule.

[0114] The result determination unit is used to determine that the test result is an abnormal result if the target exception handling logic and the actual exception handling logic are different.

[0115] The embodiment of the present application discloses an application testing device, which is used to start the target test application in the target test environment through the rule acquisition module 301, and obtain the target exception rule of the target test application from the target test environment server that deploys the target test environment. The target exception rule includes the target class of the target test application, the target method in the target class that needs to have an exception, and the exception triggering event of the target method; the exception injection module 302 is used to inject the above-mentioned exception triggering event into the test case corresponding to the above-mentioned target test application according to the above-mentioned exception triggering event in the above-mentioned target exception rule to obtain the target test case; the running module 303 is used to run the above-mentioned target test case through the above-mentioned target test application; the result determination module 304 is used to collect the test data in the above-mentioned target test case, and determine the test result when the above-mentioned test data hits the above-mentioned target exception rule based on the above-mentioned test data and the above-mentioned target class and target method in the above-mentioned target exception rule. In this way, the robustness of the application is guaranteed.

[0116] Accordingly, the embodiment of the present application also provides a computer device, which may be a terminal. Figure 4 As shown, Figure 4A schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device 400 includes a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. It will be understood by those skilled in the art that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0117] The processor 401 is the control center of the computer device 400. It uses various interfaces and lines to connect the various parts of the entire computer device 400, executes various functions of the computer device 400 and processes data by running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the computer device 400 as a whole.

[0118] In the embodiment of the present application, the processor 401 in the computer device 400 will load instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to implement various functions:

[0119] Start the target test application in the target test environment, and obtain the target exception rule of the target test application from the target test environment server that deploys the target test environment, wherein the target exception rule includes the target class of the target test application, the target method in the target class that needs to have an exception, and the exception triggering event of the target method;

[0120] According to the above-mentioned exception triggering event in the above-mentioned target exception rule, inject the above-mentioned exception triggering event into the test case corresponding to the above-mentioned target test application to obtain the target test case;

[0121] Run the above target test cases through the above target test application;

[0122] The test data in the target test case is collected, and based on the test data and the target class and the target method in the target exception rule, the test result when the test data hits the target exception rule is determined.

[0123] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0124] Optional, such as Figure 4As shown, the computer device 400 further includes: a touch screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407, respectively. Those skilled in the art can understand that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0125] The touch display screen 403 can be used for displaying a graphical user interface and receiving an operation instruction generated by the user acting on the graphical user interface. The touch display screen 403 can include a display panel and a touch panel. Wherein, the display panel can be used for displaying a message input by a user or a message provided to a user and various graphical user interfaces of a computer device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and other forms can be used to configure the display panel. The touch panel can be used to collect the touch operation of the user on or near it (such as the operation of any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch message from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 401, and can receive the command sent by the processor 401 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event, and then the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 403 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 403 can also be used as a part of the input unit 406 to realize the input function.

[0126] In the embodiment of the present application, the processor 401 executes the application test program to generate an abnormal rule configuration interface on the touch screen 403, and the abnormal rule configuration interface includes a get control. The touch screen 403 is used to present the abnormal rule configuration interface and receive operation instructions generated by the user acting on the abnormal rule configuration interface.

[0127] The radio frequency circuit 404 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other computer devices through wireless communication, and to send and receive signals between the network device or other computer devices.

[0128] The audio circuit 405 can be used to provide an audio interface between the user and the computer device through a speaker and a microphone. The audio circuit 405 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and converted into audio data, and then the audio data is output to the processor 401 for processing, and then sent to another computer device through the radio frequency circuit 404, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earphone jack to provide communication between an external headset and the computer device.

[0129] The input unit 406 may be used to receive input numbers, character messages or user feature messages (such as fingerprint, iris, facial messages, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0130] The power supply 407 is used to supply power to various components of the computer device 400. Optionally, the power supply 407 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 407 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0131] although Figure 4 Not shown, the computer device 400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.

[0132] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0133] As can be seen from the above, the computer device provided in this embodiment starts the target test application in the target test environment, obtains the target exception rule of the target test application from the target test environment server that deploys the target test environment, and the target exception rule includes the target class of the target test application, the target method in the target class where an exception needs to occur, and the exception trigger event of the target method; according to the exception trigger event in the target exception rule, the exception trigger event is injected into the test case corresponding to the target test application to obtain the target test case; runs the target test case through the target test application; collects the test data in the target test case, and determines the test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule.

[0134] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0135] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any application testing method provided in the embodiment of the present application. For example, the computer program can execute the following steps:

[0136] Start the target test application in the target test environment, and obtain the target exception rule of the target test application from the target test environment server that deploys the target test environment, wherein the target exception rule includes the target class of the target test application, the target method in the target class that needs to have an exception, and the exception triggering event of the target method;

[0137] According to the above-mentioned exception triggering event in the above-mentioned target exception rule, inject the above-mentioned exception triggering event into the test case corresponding to the above-mentioned target test application to obtain the target test case;

[0138] Run the above target test cases through the above target test application;

[0139] The test data in the target test case is collected, and based on the test data and the target class and the target method in the target exception rule, the test result when the test data hits the target exception rule is determined.

[0140] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0141] The storage medium may include: a read-only memory (ROM), a random access memory (Random access Memory), a disk or an optical disk, etc.

[0142] Since the computer program stored in the storage medium can execute the steps in any application testing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any application testing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0143] The above is a detailed introduction to an application testing method, device, storage medium and computer equipment provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. An application testing method, characterized in that: The method comprises: Start a target test application in a target test environment, and obtain a target exception rule of the target test application from a target test environment server that deploys the target test environment, wherein the target exception rule includes a target class of the target test application, a target method in the target class where an exception needs to occur, and an exception triggering event of the target method; According to the exception triggering event in the target exception rule, injecting the exception triggering event into the test case corresponding to the target test application to obtain the target test case; Run the target test case through the target test application; Collecting test data in the target test case, and determining a test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule; Configure a first correspondence between a test application identifier and a test environment identifier through a management platform; Configuring an exception rule through the management platform, and configuring a second correspondence between the exception rule and the test application identifier; Determine a test environment identifier corresponding to each abnormal rule according to the first corresponding relationship and the second corresponding relationship; Distributing the exception rule to the test environment server corresponding to the test environment identifier; The acquiring the target exception rule of the target test application from the target test environment server that deploys the target test environment includes: Sending the target application identifier and the target test environment identifier corresponding to the target test application to the management platform by calling the agent corresponding to the target test application, so that the management platform sends the target application identifier to the target test environment server corresponding to the target test environment identifier; Obtain a target exception rule of the target test application sent by the target test environment server according to the target application identifier.

2. The method according to claim 1, characterized in that The configuring of the exception rules through the management platform includes: Displaying an exception rule configuration interface in the management platform, wherein the configuration interface includes an acquisition control; In response to a triggering operation on the acquisition control, displaying a rule interface in the management platform, the rule interface including at least two preset rules; In response to a selection operation on the preset rule, the preset rule corresponding to the selection operation is determined as the abnormal rule.

3. The method according to claim 1, characterized in that After configuring the exception rules through the management platform, it also includes: When the abnormal rule configuration is completed, the abnormal rule is put into effect; When the number of times the target test case is generated based on the exception rule is equal to a preset number, the exception rule is invalidated.

4. The method according to any one of claims 1 to 3, characterized in that: The injecting the abnormal triggering event into the test case corresponding to the target test application includes: The target exception rule is read by calling the agent corresponding to the target test application, so that the agent injects the code corresponding to the exception triggering event into the test case corresponding to the target test application through the bytecode enhancement technology.

5. The method according to any one of claims 1 to 3, characterized in that: The target exception rule also includes a target exception processing logic after the exception triggering event occurs, and the test result when the test data hits the target exception rule is determined, including: Based on the test data, obtaining actual exception handling logic when the test data hits the exception rule; If the target exception handling logic is different from the actual exception handling logic, the test result is determined to be an abnormal result.

6. An application testing device, characterized in that: The device comprises: A rule acquisition module is used to start a target test application in a target test environment, and acquire a target exception rule of the target test application from a target test environment server that deploys the target test environment, wherein the target exception rule includes a target class of the target test application, a target method in the target class that needs to have an exception, and an exception triggering event of the target method; An exception injection module, used to inject the exception triggering event into the test case corresponding to the target test application according to the exception triggering event in the target exception rule, so as to obtain the target test case; A running module, used to run the target test case through the target test application; A result determination module, used to collect the test data in the target test case, and determine the test result when the test data hits the target exception rule based on the test data and the target class and target method in the target exception rule; A first relationship configuration module, used to configure a first corresponding relationship between a test application identifier and a test environment identifier through a management platform; A second relationship configuration module, used to configure an exception rule through the management platform, and to configure a second corresponding relationship between the exception rule and the test application identifier; an identification determination module, used to determine the test environment identification corresponding to each abnormal rule according to the first corresponding relationship and the second corresponding relationship; A rule distribution module, used to distribute the exception rule to the test environment server corresponding to the test environment identifier; The rule acquisition module includes: A calling unit, configured to send a target application identifier and a target test environment identifier corresponding to the target test application to a management platform by calling an agent corresponding to the target test application, so that the management platform sends the target application identifier to a target test environment server corresponding to the target test environment identifier; A rule acquisition unit is used to acquire a target exception rule of the target test application sent by the target test environment server according to the target application identifier.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and running on the processor, wherein: When the processor executes the program, the application testing method according to any one of claims 1 to 5 is implemented.

8. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are executed by a processor to implement the application testing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method, apparatus and system for collecting application exception information in application test

    CN105159832A

  • Credit card strategy package test adjustment method and device, electronic equipment and medium

    CN110347584A