Automatic testing method, device, electronic device and storage medium
By monitoring the scene information of error reporting events and distinguishing between intermediate scenes and target scenes, the problem of reduced efficiency and missed detection caused by retries in software testing is solved, and an efficient testing process is realized.
Patent Information
- Application Number
- CN202010538236.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-12
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-06-12
AI Technical Summary
During the software testing process, directly retrying test cases leads to a reduction in the testing efficiency of the target function, and may miss critical errors in the target scenario due to retries.
By monitoring the error scenario information of the error event, the intermediate scenario and the target scenario are distinguished. If the error scenario information corresponds to the intermediate scenario, the test case will be restarted. If the error scenario information corresponds to the target scenario, the execution of the test case will be terminated directly.
It improves the testing efficiency of the target function, avoids missed detection of key errors due to retries, and ensures timely detection of key errors in the target scenario.
Smart Images

Figure CN111782508B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of software testing, and in particular to an automatic testing method, device, electronic device and storage medium. Background Art
[0002] In order to discover functional errors that may be caused by delays or product strategies during the operation of the program software, it is necessary to use test cases to test the target functions of the program software during the software development phase. During the test process, if an error event occurs, it means that there is a functional error in the scenario corresponding to the target function. In related technologies, after an error event occurs, the test case is retried until the test case ends normally or the upper limit of the number of tests is reached.
[0003] However, the target scenario corresponding to the target function to be tested in the program software usually needs to go through multiple intermediate scenarios before it can be reached, that is, the test path of the target function usually includes intermediate scenarios and target scenarios. In this case, often only the functional errors existing in the target scenario are the critical errors that really need to be solved, while non-critical errors occurring in the intermediate scenario do not require special treatment. Therefore, directly retrying the test case after an error event occurs during the test process not only reduces the overall test efficiency of the target function, but may also lead to missed detection of critical errors in the target scenario due to retrying. Summary of the invention
[0004] The present disclosure provides an automatic testing method, device, electronic device and storage medium to at least solve the technical problems in the related art. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, an automatic testing method is provided, comprising:
[0006] In response to the received test execution instruction, executing a target test case, wherein the target test case is used to test a target function implemented in a target scenario;
[0007] When an error event occurs in the target test case, obtaining error scenario information of the error event;
[0008] If the error scenario information corresponds to an intermediate scenario, the target test case is executed again, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case.
[0009] Optionally, the obtaining error scenario information of the error event includes:
[0010] Determine function call stack information generated based on the error event;
[0011] Querying the function call stack information for the error reporting function name corresponding to the error reporting event;
[0012] The error reporting scenario information of the error reporting event is determined according to the error reporting function name.
[0013] Optionally, the error reporting scenario information includes a scenario type, and the determining the error reporting scenario information of the error reporting event according to the error reporting function includes:
[0014] Determine the error reporting class name of the function class to which the error reporting function name belongs according to a first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes a correspondence between the function name and the class name of the function class;
[0015] Querying a scenario type matching the error reporting class name according to a second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes a correspondence between a class name of a function class and a scenario type, or,
[0016] According to the third mapping relationship corresponding to the target test case, the scenario type matching the error reporting function name and the error reporting class name is queried, and the third mapping relationship includes the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario.
[0017] Optionally, also include:
[0018] Determine a test path corresponding to the target scenario, and create a target mapping relationship between the target scenario and the intermediate scenario;
[0019] The target test case is constructed according to the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively.
[0020] Optionally, the target mapping relationship includes the first mapping relationship and at least one of the second mapping relationship and the third mapping relationship; wherein,
[0021] The first mapping relationship is created according to the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs;
[0022] The second mapping relationship is created according to the correspondence between the class name of the function class to which the test function in the target test case belongs and the scenario type of the test scenario corresponding to the test function;
[0023] The third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test parameter belongs, and the scenario type of the test scenario corresponding to the test function.
[0024] Optionally, also include:
[0025] If the error scenario information corresponds to the target scenario, the execution process of the target test case is terminated.
[0026] According to a second aspect of an embodiment of the present disclosure, an automatic testing device is provided, comprising:
[0027] A use case execution module is configured to execute a target test case in response to the received test execution instruction, wherein the target test case is used to test a target function implemented in a target scenario;
[0028] An error acquisition module is configured to acquire error scenario information of the error event when an error event occurs in the target test case;
[0029] The retest module is configured to restart execution of the target test case if the error scenario information corresponds to an intermediate scenario, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case.
[0030] Optionally, the error acquisition module is further configured to:
[0031] Determine function call stack information generated based on the error event;
[0032] Querying the function call stack information for the error reporting function name corresponding to the error reporting event;
[0033] The error reporting scenario information of the error reporting event is determined according to the error reporting function name.
[0034] Optionally, the error reporting scenario information includes a scenario type, and the error reporting acquisition module is further configured to:
[0035] Determine the error reporting class name of the function class to which the error reporting function name belongs according to a first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes a correspondence between the function name and the class name of the function class;
[0036] Querying a scenario type matching the error reporting class name according to a second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes a correspondence between a class name of a function class and a scenario type, or,
[0037] According to the third mapping relationship corresponding to the target test case, the scenario type matching the error reporting function name and the error reporting class name is queried, and the third mapping relationship includes the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario.
[0038] Optionally, also include:
[0039] A path determination module is configured to determine a test path corresponding to the target scene and create a target mapping relationship between the target scene and the intermediate scene;
[0040] The use case construction module is configured to construct the target test case according to the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively.
[0041] Optionally, the target mapping relationship includes the first mapping relationship and at least one of the second mapping relationship and the third mapping relationship; wherein,
[0042] The first mapping relationship is created according to the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs;
[0043] The second mapping relationship is created according to the correspondence between the class name of the function class to which the test function in the target test case belongs and the scenario type of the test scenario corresponding to the test function;
[0044] The third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test parameter belongs, and the scenario type of the test scenario corresponding to the test function.
[0045] Optionally, also include:
[0046] The test ending module is configured to end the execution process of the target test case if the error scenario information corresponds to the target scenario.
[0047] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including:
[0048] processor;
[0049] a memory for storing instructions executable by the processor;
[0050] The processor is configured to execute the instructions to implement the automatic testing method as described in any of the above embodiments.
[0051] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the automatic testing method described in any of the above embodiments.
[0052] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0053] According to an embodiment of the present disclosure, after the scenarios on the test path are pre-divided into intermediate scenarios and target scenarios, function classes are pre-defined respectively and test cases are constructed using corresponding test functions, and after the error event occurs, the scenario type corresponding to the error event is extracted from the error scenario information, so that when it is detected that the scenario type is the target scenario, the test for the target function can be directly terminated. In fact, because the purpose of testing the target function is to find the critical errors in the target scenario, it is meaningless to retry when the critical errors have occurred in the target scenario. Therefore, the above-mentioned scheme of the present disclosure directly terminates the test after detecting the critical errors occurring in the target scenario, and no subsequent meaningless retries are performed, which not only improves the overall test efficiency for the target function to a certain extent; but also fundamentally avoids the missed detection of critical errors in the target scenario due to the passing of retries.
[0054] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0056] Figure 1 It is a schematic diagram of the intermediate scene and target scene corresponding to the interactive interface;
[0057] Figure 2 is a flow chart of an automatic testing method according to an embodiment of the present disclosure;
[0058] Figure 3 is a flow chart of another automatic testing method according to an embodiment of the present disclosure;
[0059] Figure 4 is a schematic diagram of a function class inheritance relationship corresponding to an intermediate scenario according to an embodiment of the present disclosure;
[0060] Figure 5 is a schematic diagram of a function class inheritance relationship corresponding to a target scenario according to an embodiment of the present disclosure;
[0061] Figure 6 It is a schematic diagram of a function class and a function call corresponding to a test process according to an embodiment of the present disclosure;
[0062] Figure 7 is a block diagram of an automatic testing device according to an embodiment of the present disclosure;
[0063] Figure 8 is a structural diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0064] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0065] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0066] In order to discover functional errors that may be caused by delays or product strategies during the operation of the program software, it is necessary to use test cases to test the target functions of the program software during the software development phase. During the test process, if an error event occurs, it means that there is a functional error in the scenario corresponding to the target function. In related technologies, after an error event occurs, the test case is retried until the test case ends normally or the upper limit of the number of tests is reached.
[0067] However, the target scenario corresponding to the target function to be tested in the program software usually needs to go through multiple intermediate scenarios before it can be reached, that is, the test path of the target function usually includes intermediate scenarios and target scenarios. Figure 1 The interactive interface shown in the figure is used as an example to illustrate. Figure 1 As shown, the target function area corresponding to the target function to be tested in the target software is located in the target interface, and a jump interface is required to reach the target interface from the startup interface of the target software. At this time, the startup interface and the jump interface correspond to the intermediate scene 1 and the intermediate scene 2 respectively, and the target interface corresponds to the target scene, that is, the test path of the target function includes the intermediate scene 1, the intermediate scene 2 and the target scene. When using test cases to test the target function, if functional errors occur in the startup interface and the jump interface, such errors have little effect on the realization of the target function - they are called non-critical errors; and only errors that occur in the target interface have a substantial impact on the target function - they are called critical errors.
[0068] The purpose of testing the target function is to find the above critical errors. Therefore, if an error event occurs during the test, if the error event corresponds to a critical error in the target interface, the test goal has actually been achieved. At this time, if the test case is retried, it will not only increase the test workload and reduce the overall test efficiency for the target function; but also if the critical error is a probabilistic error, the retry may pass, and ultimately the critical error will not be effectively captured and missed, thus losing the meaning of testing the target function.
[0069] In order to solve the above technical problem of directly retrying after an error event occurs in the related art, the present disclosure proposes an automatic testing method, which is applied to software testing equipment. Figure 2 is a flow chart of an automatic testing method according to an embodiment of the present disclosure, such as Figure 2 As shown, the testing process may include:
[0070] Step 202: Execute a target test case in response to the received test execution instruction, wherein the target test case is used to test a target function implemented in a target scenario.
[0071] First of all, it should be explained that the scenarios involved in the scheme of the present disclosure may include a separate UI (User Interface) interface, or may include a UI interface and related non-visual steps, or may even be a non-visual scenario corresponding to background processing steps without a display interface. The present disclosure does not limit this.
[0072] During the testing process, multiple tests can be performed simultaneously for multiple target scenarios of the same program software, wherein multiple test cases can be used simultaneously for multiple target functions for the same target scenario. In the tests involved in the present disclosure, only the process of using one test case to test any target scenario of any program software is focused on. The above test cases are constructed using test functions belonging to a function subclass that inherits a preset function class, wherein the preset function class includes an intermediate function class corresponding to an intermediate scenario and a target function class corresponding to a target scenario; the above function subclass includes an intermediate function subclass that inherits the intermediate function class and a target function subclass that inherits the target function class; the above test functions include an intermediate test function belonging to an intermediate function subclass and a target test function belonging to a target function subclass. Among them, the number of the above intermediate test function class, target test function class, intermediate test function, and target test function can all be one or more. The test case constructed using the above-mentioned intermediate test function and target test function can be a targeted test case constructed only for a certain target function implemented in a certain target scenario, or it can be a general test case constructed using the above-mentioned functions that is not targeted at a specific target scenario or a specific target function. The present disclosure does not limit the number of functions and function classes used in the test case, nor the applicability of the test case.
[0073] For the sake of simplicity, the following explanatory statements will refer to the process of testing a target function implemented for a target scenario using a test case as the "test process". Obviously, in the process of testing the target function implemented for the target scenario using multiple test cases, the running process of each test case is the test process corresponding to the test case.
[0074] Step 204: when an error event is detected in the target test case, error scenario information of the error event is obtained.
[0075] During any test process, a test function may trigger an error event after discovering a functional error in the program software. The present disclosure does not limit the error type, error characteristics and other related parameters that may trigger the error event. Such parameters may be pre-set by the tester. For example, the above error may be an Error type error during the software testing process or a Warning type error.
[0076] Usually, when an error event occurs in any test process, the current test process of the test case will be stopped immediately, and corresponding error scenario information will be generated. In one embodiment, the error scenario information corresponding to the error event can be read after the test is completed. At this time, the above error scenario information can be read uniformly after all multiple test processes for the target scenario are completed to avoid affecting the ongoing test process. At the same time, when errors occur in multiple test processes of the target scenario, it is convenient to uniformly analyze multiple errors to solve functional errors as a whole.
[0077] In another embodiment, the error scenario information can also be obtained through the test listener: during the test process, the test listener is used to monitor the test. If the test listener monitors an error event, the error scenario information corresponding to the error event is obtained through the test listener. In fact, the above-mentioned test listener implements real-time monitoring of the test process. When multiple test cases are used to test the target scenario at the same time, it is not necessary to wait for all test cases to stop before the occurrence of the error event can be timely known and the corresponding error scenario information can be obtained, so that the error corresponding to the error event can be handled promptly and effectively, which improves the test efficiency for the target function to a certain extent.
[0078] Generally, the automatic testing framework of the software development system will provide a test listener to capture error events and corresponding error scenario information during the test process. For example, if the test is performed under the Android test framework, the org.junit.runner.notification.RunListener listener provided by the Android test framework can be used to obtain the error scenario information corresponding to the error event using the testRunFinish method. Using the native listener provided by the test framework as the test listener can ensure the compatibility of the listener with the program software and test cases during the test.
[0079] In one embodiment, the above-mentioned error scenario information may be function call stack information. In this case, the function call stack information generated based on the error event may be first determined, and then the error function name corresponding to the error event may be queried in the function call stack information, and the error scenario information of the error event may be determined based on the error function name. Because the function call stack information includes not only the error function that triggers the error event, but also the function call record before the function, querying the test function where the error occurs in the function call stack information corresponding to the error event helps to accurately determine the function name of the test function that triggers the error event and its corresponding function call record, thereby facilitating a more accurate analysis of the error situation.
[0080] Further, the above-mentioned error reporting scenario information may include scenario types, such as intermediate scenarios or target scenarios; when the error reporting function name is determined, the above-mentioned error reporting scenario information may be determined by a pre-established mapping relationship. For example, the error reporting class name of the function class to which the error reporting function name belongs may be determined first according to the first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes the correspondence between the function name and the class name of the function class. Then, as an exemplary embodiment, the scenario type matching the error reporting class name may be queried according to the second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes the correspondence between the class name of the function class and the scenario type. At this time, the corresponding scenario type is determined directly according to the class name of the function class to which the error reporting function belongs, and the second mapping relationship used only contains a simple function class name and scenario type, so the establishment of the second mapping relationship is relatively simple, reducing the workload of establishing the mapping relationship; and since it is only necessary to extract the class name of the function class to which the test function that triggers the error reporting event belongs from the error reporting scenario information, and use the corresponding class name to query the corresponding scenario type, the amount of information extraction and type query is less, thereby speeding up the information extraction and type query to a certain extent.
[0081] Alternatively, as another exemplary embodiment, the scenario type matching the error reporting function name and the error reporting class name may also be queried according to the third mapping relationship corresponding to the target test case, and the third mapping relationship includes the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario. At this time, querying the corresponding scenario type using the third mapping relationship that includes not only the function class and the function scenario type, but also the function name can avoid the query result errors that may be caused by the test functions with the same name in the test case, and can accurately locate the error position corresponding to the functional error after determining the scenario type, thereby not only improving the accuracy of the scenario type query, but also ensuring the efficiency of troubleshooting and processing program functional errors to a certain extent.
[0082] In one embodiment, the target test case can be pre-constructed in the following manner: determine the test path corresponding to the target scenario, and create a target mapping relationship between the target scenario and the intermediate scenario; then construct the target test case based on the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively. Wherein, the above-mentioned test path includes the intermediate scenario and the target scenario. The specific construction process of the target test case can refer to the content disclosed in the relevant technology, which will not be repeated here. The target test case for the target function implemented by the target scenario is constructed through the pre-created target mapping relationship, which ensures the correspondence between the test function in the constructed target test case, the function class to which the test function belongs, and the scenario type. Then, in the event of an error event, the scenario type corresponding to the test function of the error can be accurately determined based on the pre-established target mapping relationship, which ensures accurate and efficient processing of the error event.
[0083] Furthermore, the above-mentioned target mapping relationship may include the first mapping relationship, and may also include at least one of the second mapping relationship and the third mapping relationship; wherein the first mapping relationship is created based on the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs; the second mapping relationship is created based on the correspondence between the class name of the function class to which the test function belongs in the target test case and the scene type of the test scenario corresponding to the test function; the third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test parameter belongs, and the scene type of the test scenario corresponding to the test function. It can be understood that the above-mentioned three mapping relationships can be independent of each other, for example, the three correspond to three mapping relationship tables respectively; the three can also be interrelated, for example, the third mapping relationship can include the first mapping relationship, that is, the two correspond to the same mapping relationship table.
[0084] Step 206: If the error scenario information corresponds to an intermediate scenario, restart the execution of the target test case, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case.
[0085] If it is determined that the error scenario information corresponds to the intermediate scenario, it means that the error event occurred in the intermediate scenario, that is, the functional error that occurred in the tested program software is a non-critical error in the intermediate scenario (such as a probabilistic error). Therefore, the target test case can be restarted to test the target function again in order to eliminate the non-critical error and avoid the reduction in testing efficiency caused by subsequent detailed troubleshooting of the non-keyword error.
[0086] In one embodiment, an upper limit on the number of tests for testing a target function or an intermediate scenario corresponding to a target function using a target test case can be preset, and before each retry, it can be determined whether the current number of tests has reached the above-mentioned upper limit of the number of tests. If the number of tests has reached the preset upper limit of the number of tests, the test of the target function can be terminated to avoid an infinite loop caused by infinite retries of non-probabilistic functional errors; if the number of tests has not reached the above-mentioned upper limit of the number of tests, the target function can be retested using the target test case. The above-mentioned upper limit on the number of tests can be preset according to the actual conditions such as the nature of the program software, the attributes of the target function, the test time, the test resource occupancy rate, etc., and the present disclosure does not limit this.
[0087] In one embodiment, when the error scenario information corresponds to the target scenario, the execution process of the target test case can be directly terminated. Detecting that the error scenario information corresponds to the target scenario means that the functional error corresponding to the above error event is a critical error occurring in the target scenario. At this time, the detection purpose of discovering the critical error in the target scenario has been achieved. Therefore, the test for the target function can be directly terminated to save test time and improve test efficiency.
[0088] Furthermore, in the case where the error scene information corresponds to the target scene, error reminder information about the error scene information can also be displayed; and after receiving the troubleshooting instruction for the error scene information, the target scene is troubleshooted accordingly according to the troubleshooting instruction. Among them, the above-mentioned error reminder information can include part or all of the information in the above-mentioned error scene information, such as the error type, error object ID, the function name of the test function that triggers the error event, and the class name of the function class to which the test function belongs, etc., so as to accurately display it to the tester. At this time, the error reminder information is displayed when it is detected that the functional error corresponding to the error event is a key error located in the target scene, so that the tester can check the error reminder information to know the occurrence of the above-mentioned error event, and issue a troubleshooting instruction for the functional error corresponding to the error event, so as to manually troubleshoot and solve the above-mentioned functional error, thereby realizing the manual troubleshooting and processing of key errors for the target scene.
[0089] According to the embodiments of the present disclosure, the scenarios on the test path are divided into intermediate scenarios and target scenarios in the test case construction phase before the test, and the error scenario information used to characterize the scenario type corresponding to the error event is extracted from the error scenario information after the error event occurs. Therefore, when it is detected that the error scenario information corresponds to the intermediate scenario, the target test case can be directly re-executed, and the test is directly terminated after the critical error occurring in the target scenario is detected, and no subsequent meaningless retries are performed. This not only improves the overall test efficiency for the target function, but also fundamentally avoids the missed detection of critical errors in the target scenario due to retry passing.
[0090] Depend on Figure 1 It can be seen that the intermediate interface and the target interface correspond to the intermediate scene and the target scene in the aforementioned method respectively. It should be understood that the number of intermediate interfaces can actually be one or more. Figure 3-Figure 6 , describes in detail the process of testing the target functions implemented in the target interface using the constructed test cases. Figure 3 Another automatic testing method flow chart is shown, the method is applied to software testing equipment, the method may include:
[0091] Step 302 , predefine preset function classes corresponding to different types of interfaces, function subclasses that inherit the preset function classes, and test functions belonging to the function subclasses.
[0092] For the target function to be tested in the target software, first determine the test path corresponding to the target interface where the target function is located, then determine the target interface on the test path and the intermediate interface other than the target interface, and predefine the preset function classes corresponding to different types of interfaces, the function subclasses that inherit the preset function classes, and the test functions belonging to the function subclasses. Among them, the specific process of determining the above test path can refer to the content disclosed in the relevant technology, and the present disclosure does not limit this. For the target function implemented by the target interface, there can be multiple corresponding test paths, and accordingly, different test paths can correspond to different test cases, so as to discover functional errors related to the target function as comprehensively as possible.
[0093] Corresponds to Figure 1 The test path composed of the intermediate interface and the target interface shown in the figure can predefine the intermediate function class corresponding to the intermediate interface and the intermediate function subclass that inherits the intermediate function class. The inheritance relationship between the two can be seen in Figure 4 .like Figure 4 As shown, the intermediate function subclasses that inherit the intermediate function class MiddleTest are FirstUi and SecondUi respectively; the test functions belonging to the intermediate function subclasses FirstUi and SecondUi are the intermediate test function doNext_1() and the intermediate test function doNext_2() respectively. It can be understood that the above intermediate test functions doNext_1() and doNext_2() are used to test the startup interface and the jump interface respectively. Figure 4From the inheritance relationship between the function class and the function subclass shown, it can be seen that all function subclasses corresponding to the intermediate interface inherit from the same basic function class corresponding to the intermediate interface (i.e., the intermediate function class MiddleTest). Therefore, no matter which intermediate function subclass the detection function that triggers the error event in the error scenario information belongs to, it can be determined that the function class corresponding to the detection function is the intermediate function class according to the above inheritance relationship, and then the corresponding function is determined to be a non-critical error existing in the intermediate interface, thereby ensuring the accuracy of error judgment.
[0094] Correspondingly, you can also predefine the target function class corresponding to the target interface and the target function subclass that inherits the target function class. The inheritance relationship between the two can be seen in Figure 5 .like Figure 5 As shown, the target function subclass that inherits the target function class TargetTest is TargetUi; the test function belonging to the target function subclass TargetUi is the target test function runTest(). It can be understood that the above target test function runTest() is used to test the target function implemented by the target interface.
[0095] Whether it is an intermediate interface or a target interface, the correspondence between the test function, function subclass, and function class corresponding to the interface should conform to the correspondence between the intermediate interface and the target interface included in the test path to ensure the accuracy of subsequent interface type identification. In addition, in addition to test functions, the above-mentioned function subclasses can also contain other test-related functions such as interface class functions, which will not be described one by one.
[0096] Figure 4 and Figure 5 It is only exemplary. For the above intermediate function subclasses and target function subclasses, their number can be one or more; similarly, the test function belonging to any function subclass can also be one or more. The number of the above function classes and test functions can be reasonably selected according to the specific situation of the target scenario and the test path, and the present disclosure does not limit this. In specific use, the class name of the predefined function class and the function name of the test function can be customized according to the specific scenario, and are not limited to the above names shown in this embodiment.
[0097] Step 304: Create a target mapping relationship between the target interface and the intermediate interface.
[0098] In this embodiment, the target mapping relationship may include a first mapping relationship, and may also include at least one of a second mapping relationship and a third mapping relationship. Among them, the first mapping relationship can be created based on the correspondence between the function name of the test function in the target test case and the class name of the function subclass and / or function class to which the test function belongs; the second mapping relationship is created based on the correspondence between the class name of the function subclass and / or function class to which the test function belongs in the target test case and the scene type of the test scene corresponding to the test function; the third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function subclass and / or function class to which the test parameter belongs, and the scene type of the test scene corresponding to the test function. It can be understood that the above three mapping relationships can be independent of each other, for example, the three correspond to three mapping relationship tables respectively; the three can also be interrelated, for example, the third mapping relationship can include the first mapping relationship, that is, the two correspond to the same mapping relationship table.
[0099] Step 306: construct a target test case for the target function based on the test function and target mapping relationship.
[0100] After predefining the above function classes, function subclasses and test functions, a target test case for the target function can be constructed based on the above test function. In one embodiment, the corresponding test functions can be called in order according to the first timing relationship between the intermediate interface and the target interface on the test path, and the second timing relationship corresponding to each to-be-triggered element in the interface on the test path. Therefore, the above target test case constructed for the target function is an ordered set of test functions corresponding to the target function.
[0101] The target test case for the target function can be constructed using all the predefined test functions mentioned above, or a part of the test functions among all the test functions mentioned above can be used to construct the target test case for the target function, that is, the present disclosure does not limit the number of test functions for constructing the target test case, but it should be ensured that the correspondence between the test functions used to construct the target test case for the target function and the function subclasses and function classes to which they belong satisfy the correspondence between the above intermediate interface and the target interface, so as to ensure the effectiveness of the test case in software testing and the accuracy of the scene type corresponding to the identification interface. In one embodiment, at least one target test case can be constructed for different test paths of the target function.
[0102] Step 308: Use the test case to test the target function.
[0103] Because the target test case created for the target function is an ordered set of test functions corresponding to the target function, the process of running the above target test case to test the target function is to orderly call the test functions contained in the target test case to trigger the elements contained in the intermediate interface and the target interface on the test path to realize the target function corresponding to the triggered elements.
[0104] During the execution of the target test case for the target function, the calling sequence of the target test function and the correspondence between the test function and the function subclass can be found in Figure 6 .like Figure 6 As shown, after the test function starts running, the intermediate test function doNext_1() corresponding to the startup interface is first called and executed. After the function is executed, the display interface is transferred from the startup interface to the jump interface; then the intermediate test function doNext_2() corresponding to the jump interface is called and executed. After the function is executed, the display interface is transferred from the jump interface to the target interface; finally, the target test function runTest() corresponding to the target interface is called and executed to implement the test of the target function implemented by the target function area in the target interface. When the test function finally called finishes running, the entire test case is finished.
[0105] Step 310, determining whether an error event occurs.
[0106] Understandably, Figure 6 The target test case shown represents the test process when no error event occurs during the test process. In fact, during the execution of the above intermediate test function doNext_1(), the intermediate test function doNext_2() and the target test function runTest(), it is possible to find functional errors in the corresponding interface and trigger error events. Normally, when an error event occurs during the test process, the current test process will be stopped immediately and the corresponding error stack information will be generated.
[0107] In one embodiment, if multiple target test cases are executed simultaneously for a target function, in order to avoid affecting the target test cases in the test process and to uniformly analyze multiple errors when errors occur in multiple test processes, the error stack information corresponding to the error event can be uniformly read after the test is completed. At this time, if the test is stopped due to the occurrence of an error event, the corresponding error stack information can be obtained; conversely, if no error event occurs during the test process, that is, the test process stops normally, then there is no error stack information at this time. Therefore, after the test is completed, it is determined whether there is saved information to know whether an error event occurs during the test process.
[0108] In one embodiment, in order to promptly know the occurrence of error events and perform corresponding processing, the error stack information can be obtained through a test listener. Taking the test of the target function under the Android test framework as an example, the org.junit.runner.notification.RunListener listener provided by the Android test framework can be used as a test listener to monitor the above test process in real time. For software testing under other test frameworks, other native listeners provided by the corresponding test framework can also be used as test listeners to ensure the compatibility of the listener with the program software and the target test case during the test, thereby improving the test efficiency. Of course, instead of using the native listener provided by the test framework, a third-party listener or a custom listener can be used to monitor the error events that may occur during the above detection process, so as to better meet the test habits of the testers or the personalized needs of the target functions.
[0109] If an error event occurs during the test, the process proceeds to step 3121 ; otherwise, if no error event occurs during the test, the process proceeds to step 316 .
[0110] Step 312, obtaining error stack information corresponding to the error event.
[0111] Corresponding to different ways of determining whether an error event has occurred, if the error stack information corresponding to the error event is uniformly read after the test is completed, the error stack information can be directly obtained. If the error event that may occur in the above detection process is monitored in real time through a listener, the error stack information corresponding to the error event can be obtained immediately after the error event is monitored. For example, still taking the test for the target interface under the Android test framework as an example, after the error event is monitored, the error stack information corresponding to the error event can be obtained using the testRunFinish method.
[0112] In one embodiment, the above-mentioned error stack information may include a variety of information, for example, it may include the functional error type, the functional error location, the error object ID, the function name of the test function that triggers the error event, and the class name of the function class to which the test function belongs.
[0113] Step 314: determine the scenario type corresponding to the error event based on the error reporting function name in the error stack information.
[0114] After the error stack information is obtained, the error reporting function name corresponding to the error reporting function may be extracted from the error stack information, and then the scenario type corresponding to the function name may be determined.
[0115] In one embodiment, the error class name of the function class and / or function subclass to which the error function name belongs can be determined according to the first mapping relationship corresponding to the target test case pre-established in step 306. As an exemplary embodiment, the error scenario information can only include the class name of the function class to which the test function that triggers the error event belongs. At this time, the scenario type that matches the class name of the function class to which the test function that triggers the error event belongs can be queried according to the first mapping relationship between the preset class name and the scenario type. The above-mentioned first mapping relationship is pre-established according to the corresponding relationship between the function class to which the test function used in the test case belongs and the scenario type of the function class. At this time, the corresponding scenario type is determined directly according to the class name of the function class to which the error function belongs, and the second mapping relationship used only contains the error class name and scenario type of a simple function class and / or function subclass, so the establishment of the second mapping relationship is relatively simple, reducing the workload of establishing the mapping relationship; and since it is only necessary to extract the error class name that triggers the error event from the error scenario information, and use the corresponding error class name to query the corresponding scenario type, the amount of information extraction and type query is small, which is convenient to improve the speed of information extraction and type query.
[0116] Alternatively, as another exemplary embodiment, the error scenario information may include the function name of the test function that triggers the error event, and the class name of the function class to which the test function belongs. At this time, the scenario type that matches both the function name of the test function that triggers the error event and the class name of the function class to which the test function belongs can be queried according to the preset second mapping relationship between the function name, class name and scenario type. The above second mapping relationship is pre-established based on the correspondence between the test function used by the test case, the function class to which the test function belongs, and the scenario type of the function class. At this time, the corresponding scenario type is queried using a third mapping relationship that includes not only the function class and / or function subclass and function scenario type, but also the function name, which can avoid the query result error that may be caused by the test function with the same name in the test case, and can accurately locate the error position corresponding to the functional error after determining the scenario type, thereby not only improving the accuracy of the scenario type query, but also ensuring the efficiency of troubleshooting and processing program function errors to a certain extent.
[0117] Still taking the test of the target function under the Android test framework as an example, the corresponding error stack information is the error stack information corresponding to the error event. The corresponding error stack information is as follows:
[0118] androidx.test.uiautomator.UiObjectNotFoundException:UiSelector[CLASS=android.widg et.ImageView,RESOURCE_ID=com.smile.gifmaker:id / action_bar_share_profile]
[0119] at androidx.test.uiautomator.UiObject.click(UiObject.java:416)
[0120] at cc.AAA.testkuai.SecondUi$doNext_2$1.invoke(ShareProfileTest.kt:254)
[0121] at cc.AAA.testkuai.FirstUi$doNext_1$1.invoke(ShareProfileTest.kt:26)
[0122] at cc.AAA.testkuai.tool.ShareKt.shareImByFriends(Share.kt:80)
[0123] at cc.AAA.testkuai.ShareProfileTest.shareByImTest(ShareProfileTest.kt:110)
[0124] at java.lang.reflect.Method.invoke(Native Method)
[0125] For the above error stack information, as an exemplary embodiment, all subclass names SecondUi and FirstUi of the function subclass to which the test function that triggers the error event belongs can be extracted. At this time, the types of SecondUi and FirstUi can be queried in the first mapping relationship table corresponding to the first mapping relationship (at this time, the first mapping relationship table should store each subclass name and its corresponding type: intermediate function subclass or target function subclass); the type of the function class corresponding to SecondUi and FirstUi can also be queried in the first mapping relationship table (at this time, the first mapping relationship table should store each subclass name and the type of the inherited function class: intermediate function class or target function class). From the preset function class inheritance relationship (that is, the aforementioned agreement: the test code of the intermediate scene is placed in the function subclass SecondUi and the function subclass FirstUi, and is implemented in the functions doNext_2 and doNext_1), it can be seen that the function subclass SecondUi and the function subclass FirstUi both inherit the intermediate function class MiddleTest, so through the above query results, it can be determined that the functional error existing in the program software is a non-critical error located in the intermediate interface.
[0126] Of course, it can be known from the above error stack information that the relationship between the test function doNext_1 belonging to the intermediate function subclass FirstUi and the test function doNext_2 belonging to the intermediate function subclass SecondUi is a calling and being called relationship. Therefore, it is also possible to extract only the lowest subclass name SecondUi of the function subclass to which the test function that triggers the error event belongs from the above error stack information, and then use the above detection method to query the type of the function subclass SecondUi or the type of the function class it inherits in the first mapping relationship table. Finally, the above query results can be used to determine that the functional errors existing in the program software are non-critical errors located in the intermediate interface.
[0127] As another exemplary embodiment, all function names doNext_2 and doNext_1 of the test function that triggers the error event, as well as all subclass names SecondUi and FirstUi of the function subclasses to which the above function names belong, can be extracted from the error information. Similarly, at this time, the above query results can be used to determine that the functional error existing in the program software is a non-critical error located in the middle interface. Similarly, only the lowest function name doNext_2 of the test function that triggers the error event, as well as the lowest subclass name SecondUi of the function subclass to which the above lowest function name belongs, can be extracted from the above error stack information, and then the above detection method can be used to query the type of the function subclass corresponding to the detection function doNext_2 and the function subclass SecondUi or the type of the function class it inherits, and finally the above query results can be used to determine that the functional error existing in the program software is a non-critical error located in the middle interface.
[0128] In another embodiment, the error stack information is as follows:
[0129] androidx.test.uiautomator.UiObjectNotFoundException:UiSelector[CLASS=android.widg et.ImageView,RESOURCE_ID=com.smile.gifmaker:id / action_bar_share_profile]
[0130] at androidx.test.uiautomator.UiObject.click(UiObject.java:416)
[0131] at cc.BBB.testkuai.TargetUi$runTest$1.invoke(ShareProfileTest.kt:350)
[0132] at cc.BBB.testkuai.tool.ShareKt.shareImByFriends(Share.kt:80)
[0133] at cc.BBB.testkuai.ShareProfileTest.shareByImTest(ShareProfileTest.kt:110)
[0134] at java.lang.reflect.Method.invoke(Native Method)
[0135] For the above error stack information, the subclass name TargetUi of the function subclass to which the test function that triggered the error event belongs can be extracted. At this time, the type of TargetUi can be queried in the second mapping relationship table corresponding to the second mapping relationship (at this time, the second mapping relationship table should store each subclass name and its corresponding type: intermediate function subclass or target function subclass); the type of function class corresponding to the function subclass TargetUi can also be queried in the second mapping relationship table (at this time, the second mapping relationship table should store the type of function class inherited by the subclass name of each function subclass: intermediate function class or target function class). It can be seen from the preset function class inheritance relationship that the function subclass TargetUi inherits from the target function class TargetTest. Therefore, through the above query results, it can be determined that the functional error existing in the program software is a key error located in the target interface.
[0136] As another exemplary embodiment, the function name runTest of the test function that triggers the error event and the subclass name TargetUi of the function subclass to which the above function name belongs can be extracted. Similarly, at this time, the functional error existing in the program software can be determined to be a key error located in the target interface through the above query results.
[0137] If the extracted error scenario information corresponds to the middle interface, it means that the functional error corresponding to the error event occurs in the middle interface. At this time, go to step 308 and retest using the current test case. Before retrying, it can be determined whether the current number of executions of the test case (that is, the current number of tests) has reached the preset upper limit of the number of tests. If it has reached it, the test of the target function using the test case can be terminated; if it has not reached the preset upper limit of the number of tests, the target function can be retested using the test case. For example, the upper limit of the number of tests for the target function used for user interaction can be preset to 6 times, and the upper limit of the number of tests for the target function executed in the background can be preset to 3 times; it can also be preset that if the CPU occupancy rate of the current software testing device exceeds 50%, the upper limit of the number of tests for the target function is 8 times, if the CPU occupancy rate of the current software testing device exceeds 80%, the upper limit of the number of tests for the target function is 4 times, etc., which will not be repeated. In addition, the above-mentioned upper limit on the number of tests can also be adjusted according to the test results. For example, the upper limit on the number of tests can be initially set to 5 times. If after a round of tests is completed, more than half of the test cases pass the test within 3 times, then the subsequent tests can adjust the upper limit on the number of tests to 3 times; if after a round of tests is completed, more than 80% of the test cases fail after 5 tests, then the subsequent tests can adjust the upper limit on the number of tests to 8 times. No further details will be given.
[0138] Otherwise, if the extracted error reporting scenario information corresponds to the target interface, it means that the functional error corresponding to the error reporting event occurs in the target interface, and the process goes to step 316 .
[0139] Step 316, ending the test process for the target function.
[0140] In the case where no error event occurs during the test of the above test case, the current detection process has actually ended normally. In the case where the functional error corresponding to the error event is a critical error occurring in the target interface, the current detection process has actually been forced to end due to the occurrence of the error event, and the purpose of software testing has been achieved at this time, so there is no need to retry the test case.
[0141] It can be seen that when it is detected that the functional error corresponding to the error time is a critical error occurring in the target interface, directly ending the test process without retrying the test case not only improves the efficiency of software testing, but also avoids missing critical errors in the target scenario due to retrying.
[0142] Corresponding to the aforementioned embodiment of the automatic testing method, the present disclosure also proposes an embodiment of an automatic testing device.
[0143] Figure 7 1 is a schematic block diagram of an automatic testing device according to an embodiment of the present disclosure. The automatic testing device shown in this embodiment can be applied to software testing equipment. Figure 7 As shown, the automatic testing device may include:
[0144] The use case execution module 701 is configured to execute a target test case in response to the received test execution instruction, wherein the target test case is used to test a target function implemented in a target scenario;
[0145] The error acquisition module 702 is configured to acquire error scenario information of the error event when an error event occurs in the target test case;
[0146] The retest module 703 is configured to restart the execution of the target test case if the error scenario information corresponds to an intermediate scenario, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case.
[0147] Optionally, the error acquisition module is further configured to:
[0148] Determine function call stack information generated based on the error event;
[0149] Querying the function call stack information for the error reporting function name corresponding to the error reporting event;
[0150] The error reporting scenario information of the error reporting event is determined according to the error reporting function name.
[0151] Optionally, the error reporting scenario information includes a scenario type, and the error reporting acquisition module is further configured to:
[0152] Determine the error reporting class name of the function class to which the error reporting function name belongs according to a first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes a correspondence between the function name and the class name of the function class;
[0153] Querying a scenario type matching the error reporting class name according to a second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes a correspondence between a class name of a function class and a scenario type, or,
[0154] According to the third mapping relationship corresponding to the target test case, the scenario type matching the error reporting function name and the error reporting class name is queried, and the third mapping relationship includes the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario.
[0155] Optionally, also include:
[0156] A path determination module 704 is configured to determine a test path corresponding to the target scene and create a target mapping relationship between the target scene and the intermediate scene;
[0157] The use case construction module 705 is configured to construct the target test case according to the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively.
[0158] Optionally, the target mapping relationship includes the first mapping relationship and at least one of the second mapping relationship and the third mapping relationship; wherein,
[0159] The first mapping relationship is created according to the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs;
[0160] The second mapping relationship is created according to the correspondence between the class name of the function class to which the test function in the target test case belongs and the scenario type of the test scenario corresponding to the test function;
[0161] The third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test parameter belongs, and the scenario type of the test scenario corresponding to the test function.
[0162] Optionally, also include:
[0163] The test ending module 706 is configured to end the execution process of the target test case if the error scenario information corresponds to the target scenario.
[0164] The embodiment of the present disclosure further provides an electronic device, including:
[0165] processor;
[0166] a memory for storing instructions executable by the processor;
[0167] The processor is configured to execute the instructions to implement the automatic testing method as described in any of the above embodiments.
[0168] An embodiment of the present disclosure further provides a storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the automatic testing method described in any of the above embodiments.
[0169] An embodiment of the present disclosure further provides a computer program product, which is configured to execute the automatic testing method described in any of the above embodiments.
[0170] Figure 8 800 is a schematic block diagram of an electronic device according to an embodiment of the present disclosure. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0171] Reference Figure 8 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 818 .
[0172] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned automatic testing method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0173] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0174] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0175] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0176] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 818. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0177] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0178] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0179] The communication component 818 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 818 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 818 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0180] In one embodiment of the present disclosure, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above-mentioned automatic testing method.
[0181] In an embodiment of the present disclosure, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to complete the above automatic testing method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0182] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0183] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
[0184] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprises a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0185] The method and device provided in the embodiments of the present disclosure are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea. At the same time, for those skilled in the art, according to the idea of the present disclosure, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. An automatic testing method, It is characterized in that include: In response to the received test execution instruction, executing a target test case, wherein the target test case is used to test a target function implemented in a target scenario; When an error event occurs in the target test case, obtaining error scenario information of the error event; If the error scenario information corresponds to an intermediate scenario, restarting execution of the target test case, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case; The obtaining the error reporting scenario information of the error reporting event includes: Determine function call stack information generated based on the error event; Querying the function call stack information for the error reporting function name corresponding to the error reporting event; Determine the error scenario information of the error event according to the error function name, including: according to the first mapping relationship corresponding to the target test case, determine the error class name of the function class to which the error function name belongs, the first mapping relationship includes the correspondence between the function name and the class name of the function class; according to the third mapping relationship corresponding to the target test case, query the scenario type that matches the error function name and the error class name, the third mapping relationship includes the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario.
2. The method according to claim 1, It is characterized in that The error reporting scenario information includes a scenario type, and the error reporting scenario information of the error reporting event is determined according to the error reporting function, including: Determine the error reporting class name of the function class to which the error reporting function name belongs according to a first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes a correspondence between the function name and the class name of the function class; The scenario type matching the error reporting class name is queried according to a second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes a correspondence between a class name of a function class and a scenario type.
3. The method according to claim 1, It is characterized in that Also includes: Determine a test path corresponding to the target scenario, and create a target mapping relationship between the target scenario and the intermediate scenario; The target test case is constructed according to the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively.
4. The method according to claim 3, It is characterized in that The target mapping relationship includes a first mapping relationship and at least one of a second mapping relationship and a third mapping relationship; wherein, The first mapping relationship is created according to the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs; The second mapping relationship is created according to the correspondence between the class name of the function class to which the test function in the target test case belongs and the scenario type of the test scenario corresponding to the test function; The third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test function belongs, and the scenario type of the test scenario corresponding to the test function.
5. The method according to claim 1, It is characterized in that Also includes: If the error scenario information corresponds to the target scenario, the execution process of the target test case is terminated.
6. An automatic testing device, It is characterized in that include: A use case execution module is configured to execute a target test case in response to the received test execution instruction, wherein the target test case is used to test a target function implemented in a target scenario; An error acquisition module is configured to acquire error scenario information of the error event when an error event occurs in the target test case; A retest module is configured to restart execution of the target test case if the error scenario information corresponds to an intermediate scenario, wherein the intermediate scenario is a test scenario other than the target scenario on the test path of the target test case; The error acquisition module is further configured to: determine function call stack information generated based on the error event; query the error function name corresponding to the error event in the function call stack information; determine the error scenario information of the error event according to the error function name; The error acquisition module is also configured to: determine the error class name of the function class to which the error function name belongs according to a first mapping relationship corresponding to the target test case, the first mapping relationship including the correspondence between the function name and the class name of the function class; query the scenario type that matches the error function name and the error class name according to a third mapping relationship corresponding to the target test case, the third mapping relationship including the correspondence between the function name, the class name of the function class and the scenario type; wherein the scenario type includes the intermediate scenario and the target scenario.
7. The device according to claim 6, It is characterized in that The error reporting scenario information includes a scenario type, and the error reporting acquisition module is further configured to: Determine the error reporting class name of the function class to which the error reporting function name belongs according to a first mapping relationship corresponding to the target test case, wherein the first mapping relationship includes a correspondence between the function name and the class name of the function class; The scenario type matching the error reporting class name is queried according to a second mapping relationship corresponding to the target test case, wherein the second mapping relationship includes a correspondence between a class name of a function class and a scenario type.
8. The device according to claim 6, It is characterized in that Also includes: A path determination module is configured to determine a test path corresponding to the target scene and create a target mapping relationship between the target scene and the intermediate scene; The use case construction module is configured to construct the target test case according to the target mapping relationship and the test functions corresponding to the target scenario and the intermediate scenario respectively.
9. The device according to claim 8, It is characterized in that The target mapping relationship includes a first mapping relationship and at least one of a second mapping relationship and a third mapping relationship; wherein, The first mapping relationship is created according to the correspondence between the function name of the test function in the target test case and the class name of the function class to which the test function belongs; The second mapping relationship is created according to the correspondence between the class name of the function class to which the test function in the target test case belongs and the scenario type of the test scenario corresponding to the test function; The third mapping relationship is created based on the correspondence between the function name of the test function in the target test case, the class name of the function class to which the test function belongs, and the scenario type of the test scenario corresponding to the test function.
10. The device according to claim 6, It is characterized in that Also includes: The test ending module is configured to end the execution process of the target test case if the error scenario information corresponds to the target scenario.
11. An electronic device, It is characterized in that include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the automatic testing method according to any one of claims 1 to 5.
12. A computer-readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the automatic testing method as claimed in any one of claims 1 to 5.
