Software code automatic testing system and related testing methods
By introducing test triggering tools and scenario simulators into the code testing system, automatically triggering code subset testing and simulating application scenario data, the problem of lack of flexibility and intelligence in existing test solutions is solved, and the test coverage and efficiency are improved.
Patent Information
- Application Number
- CN202410280488.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-03-12
AI Technical Summary
Existing code testing solutions lack flexibility and intelligence, affecting the efficiency of software development and release.
Introduce test triggering tools, code testing tools and scene simulators to test automatically triggered code subsets through test tags, and use scene simulators to simulate application scenario data on demand for testing.
Improves the flexibility and intelligence of code testing, and improves test coverage and testing efficiency.
Smart Images

Figure CN118193368B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer-related technologies, and in particular, to a software code automatic testing system and related testing methods. Background Art
[0002] Software code testing is an important part of software development. Through testing, algorithm vulnerabilities or errors in software code can be discovered. Therefore, how to achieve efficient and intelligent software code testing has always been an important direction of long-term research and optimization in the industry.
[0003] Most existing code testing solutions lack flexibility and intelligence, which is likely to affect the efficiency requirements of software development and release. Summary of the invention
[0004] The embodiments of the present application provide a software code automatic testing system and related testing methods, which are conducive to improving the flexibility and intelligence of code testing.
[0005] The first aspect of the present application provides a software code automatic testing system, including: a test trigger tool, a code testing tool and a scenario simulator;
[0006] The test trigger tool is used to start a first test monitoring process when the first test tag testid11 in the first test tag pair is detected to appear in the code set, wherein the first test monitoring process is used to generate a first test instruction when the second test tag testid12 in the first test tag pair is detected to appear in the code set, and the first test instruction includes a first code subset to be tested, and the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send the first test instruction to the code testing tool;
[0007] The code testing tool is used to search for an application scenario identifier in a first code subset after receiving a first test instruction, read the first application scenario identifier searched in the first code subset, and send a first scenario simulation request containing the first application scenario identifier to a scenario simulator;
[0008] The scenario simulator is used to start a scenario simulation function after receiving a first scenario data request to simulate and obtain first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and send a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool;
[0009] The code testing tool is further used to test the first code subset after receiving the first scenario simulation request response, using the first application scenario simulation data carried in the first scenario simulation request response as a test input to obtain a first test report.
[0010] In some possible implementations, the first test report records a first test coverage rate obtained by using the first application scenario simulation data as the test input.
[0011] The code testing tool is also used to search for an application scenario identifier in the first code subset when the first test coverage recorded in the first test report is less than a threshold; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator;
[0012] The scenario simulator is further used to, after receiving the second scenario data request, start the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool;
[0013] The code testing tool is further used to test the first code subset after receiving the second scenario simulation request response, using the second application scenario simulation data carried in the second scenario simulation request response as test input to obtain a second test report.
[0014] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input;
[0015] The code testing tool is also used to search for application scenario identifiers in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset, and the second test coverage is not less than the first test coverage; send a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier to the scenario simulator;
[0016] Among them, the scenario simulator is used to start the scenario simulation function and adjust the scenario simulation parameters of the scenario simulation function according to preset rules after receiving the third scenario data request (wherein the preset rules are used, for example, to adjust the scenario simulation parameters so that the scene simulation depth and / or breadth increases step by step, and the amplitude of the step-by-step increase is positively correlated with the size of the second test coverage) to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool.
[0017] The code testing tool is further used to test the first code subset using the third application scenario simulation data carried in the third scenario simulation request response as test input after receiving the third scenario simulation request response to obtain a third test report.
[0018] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input.
[0019] The code testing tool is also used to search for an application scenario identifier in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset; send a fourth scenario simulation request that does not contain the application scenario identifier to the scenario simulator.
[0020] The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fourth scenario data request, and when receiving an application scenario selection instruction response containing a fourth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and send a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool;
[0021] The code testing tool is further used to test the first code subset using the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input after receiving the fourth scenario simulation request response to obtain a fourth test report.
[0022] In some possible implementations, the second test report records the second test coverage rate obtained by using the second application scenario simulation data as the test input. The code testing tool is also used to search for the application scenario identifier in the first code subset when the second test coverage rate recorded in the second test report is less than a threshold value; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset; combine the first application scenario simulation data and the second application scenario simulation data to obtain the sixth application scenario simulation data, wherein if the second test coverage rate is greater than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is greater than the first application scenario simulation data, and if the second test coverage rate is less than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is less than the first application scenario simulation data; use the sixth application scenario simulation data as the test input to test the first code subset to obtain the sixth test report.
[0023] In some possible implementations, the code testing tool is further configured to send a fifth scenario simulation request that does not include an application scenario identifier to the scenario simulator if no application scenario identifier is found in the first code subset;
[0024] The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fifth scenario data request, and when receiving an application scenario selection instruction response containing a fifth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fifth application scenario simulation data corresponding to the application scenario represented by the fifth application scenario identifier, and send a fifth scenario simulation request response carrying the fifth application scenario simulation data to the code testing tool;
[0025] The code testing tool is further used to test the first code subset after receiving the fifth scenario simulation request response, using the fifth application scenario simulation data carried in the fifth scenario simulation request response as test input to obtain a fifth test report.
[0026] In some possible implementations, the code testing tool is further configured to send a first test instruction response including a test completion mark to the test triggering tool after the obtained test report meets the test completion requirement;
[0027] The test trigger tool is used to delete the first test tag pair from the code set after receiving the first test instruction response including the test completion mark.
[0028] A second aspect of an embodiment of the present application provides a software code testing method, the method being applied to a software code automatic testing system, the software code automatic testing system comprising: a test trigger tool, a code testing tool, and a scenario simulator;
[0029] in,
[0030] The method comprises: the test trigger tool starts a first test monitoring process when monitoring the first test tag testid11 in the first test tag pair appears in the code set, wherein the first test monitoring process is used to generate a first test instruction when monitoring the second test tag testid12 in the first test tag pair appears in the code set, the first test instruction comprises a first code subset to be tested, the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send the first test instruction to the code testing tool;
[0031] After receiving the first test instruction, the code testing tool searches for the application scenario identifier in the first code subset, reads the first application scenario identifier searched in the first code subset, and sends a first scenario simulation request containing the first application scenario identifier to the scenario simulator;
[0032] After receiving the first scenario data request, the scenario simulator starts a scenario simulation function to simulate and obtain first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and sends a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool;
[0033] After receiving the first scenario simulation request response, the code testing tool uses the first application scenario simulation data carried in the first scenario simulation request response as a test input to test the first code subset to obtain a first test report.
[0034] In some possible implementations, the first test report records a first test coverage rate obtained by using the first application scenario simulation data as a test input;
[0035] Wherein, the method further comprises:
[0036] When the first test coverage recorded in the first test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator;
[0037] After receiving the second scenario data request, the scenario simulator starts the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and sends a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool;
[0038] After receiving the second scenario simulation request response, the code testing tool uses the second application scenario simulation data carried in the second scenario simulation request response as a test input to test the first code subset to obtain a second test report.
[0039] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input;
[0040] Wherein, the method further comprises:
[0041] When the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset, and the second test coverage is not less than the first test coverage; a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier is sent to the scenario simulator;
[0042] After receiving the third scenario data request, the scenario simulator starts the scenario simulation function and adjusts the scenario simulation parameters of the scenario simulation function according to preset rules (wherein the preset rules are, for example, used to adjust the scenario simulation parameters so that the scene simulation depth and / or breadth increases stepwise, and the magnitude of the stepwise increase is positively correlated with the size of the second test coverage), so as to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool;
[0043] After receiving the third scenario simulation request response, the code testing tool uses the third application scenario simulation data carried in the third scenario simulation request response as a test input to test the first code subset to obtain a third test report.
[0044] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input;
[0045] The method further includes: when the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset; sending a fourth scenario simulation request that does not include the application scenario identifier to the scenario simulator;
[0046] After receiving the fourth scenario data request, the scenario simulator sends an application scenario selection instruction including a set of optional application scenario identifiers to the code testing tool, and upon receiving an application scenario selection instruction response including a fourth application scenario identifier fed back by the code testing tool, starts a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and sends a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool;
[0047] After receiving the fourth scenario simulation request response, the code testing tool uses the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input to test the first code subset to obtain a fourth test report.
[0048] In some possible implementations, the second test report records the second test coverage rate obtained by using the second application scenario simulation data as the test input. The method also includes: when the second test coverage rate recorded in the second test report is less than a threshold value, the code testing tool searches for the application scenario identifier in the first code subset; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset; the first application scenario simulation data and the second application scenario simulation data are combined to obtain the sixth application scenario simulation data, wherein if the second test coverage rate is greater than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is greater than the first application scenario simulation data, and if the second test coverage rate is less than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is less than the first application scenario simulation data; the sixth application scenario simulation data is used as the test input to test the first code subset to obtain the sixth test report.
[0049] In some possible implementations, the method further includes: if the code testing tool does not search for any application scenario identifier in the first code subset, sending a fifth scenario simulation request that does not include the application scenario identifier to the scenario simulator;
[0050] Wherein, after receiving the fifth scenario data request, the scenario simulator sends an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool, and upon receiving the application scenario selection instruction response containing the fifth application scenario identifier fed back by the code testing tool, starts the scenario simulation function to simulate and obtain the fifth application scenario simulation data corresponding to the application scenario represented by the fifth application scenario identifier, and sends a fifth scenario simulation request response carrying the fifth application scenario simulation data to the code testing tool;
[0051] After receiving the fifth scenario simulation request response, the code testing tool uses the fifth application scenario simulation data carried in the fifth scenario simulation request response as test input to test the first code subset to obtain a fifth test report.
[0052] In some possible implementations, the method includes: after the obtained test report meets the test completion requirement, the code testing tool sends a first test instruction response including a test completion mark to the test triggering tool;
[0053] After receiving the first test instruction response including a test completion identifier, the test trigger tool deletes the first test tag pair from the code set.
[0054] In a third aspect, the embodiments of the present disclosure further provide a storage medium containing computer executable instructions, which, when executed by a computer processor, can be used to execute part or all of the steps of any method of the embodiments of the present application.
[0055] In a fourth aspect, the embodiments of the present disclosure further provide a computer program product, which, when executed by a computer processor, can be used to execute part or all of the steps of any method of the embodiments of the present application.
[0056] The technical solution provided by the present application introduces a scenario simulator in a software code automatic testing system, and the scenario simulator can simulate relevant application scenario data as needed; the test trigger tool in the software code automatic testing system is used to start a first test monitoring process when the first test tag testid11 in the first test tag pair is detected to appear in the code set, and the first test monitoring process is used to generate a first test instruction when the second test tag testid12 in the first test tag pair is detected to appear in the code set, and the first test instruction includes a first code subset to be tested, and the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to issue the first test instruction to the code testing tool; the code testing tool is used to search for an application scenario identifier in the first code subset after receiving the first test instruction, read the first application scenario identifier searched in the first code subset, and send a first scenario simulation request containing the first application scenario identifier to the scenario simulator; the code testing tool is also used to test the first code subset using the first application scenario simulation data carried in the first scenario simulation request response as a test input after receiving the first scenario simulation request response to obtain a first test report. The introduction of test markers can automatically trigger the testing of the corresponding code subset. During the testing process, the scenario simulator is used to simulate the relevant application scenario data on demand for testing. This mechanism is conducive to improving the flexibility and intelligence of code testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work. Figure 1 A schematic diagram of the structure of a software code automatic testing system provided by an embodiment of the present disclosure.
[0058] Figure 1 It is a flowchart of a software code automatic testing system provided by an embodiment of the present disclosure.
[0059] Figure 2 It is a flowchart of a software code testing method provided by an embodiment of the present disclosure.
[0060] Figure 3 It is a schematic diagram of a code set including a test tag pair provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0061] In order to make the technical personnel in the technical field better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention is clearly described below in conjunction with the relevant drawings. Obviously, the described embodiment is an embodiment of a part of the present invention, rather than all the embodiments. Based on some embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should belong to the scope of protection of the present invention. The terms "first", "second" and "third" etc. appearing in the specification, claims and drawings of the present invention are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusion. For example, a process, method, system or product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes or methods or products or devices.
[0062] See also Figure 1 The embodiment of the present application provides an example of a software code automatic testing system, which may include: a test trigger tool 110, a code testing tool 120 and a scenario simulator 130.
[0063] The test trigger tool 110 is used to start a first test monitoring process when the first test tag testid11 in the first test tag pair is detected to appear in the code set, wherein the first test monitoring process is used to generate a first test instruction when the second test tag testid12 in the first test tag pair is detected to appear in the code set, and the first test instruction includes a first code subset to be tested, and the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send the first test instruction to the code testing tool;
[0064] The code testing tool 120 is used to search for an application scenario identifier in the first code subset after receiving the first test instruction, read the first application scenario identifier searched in the first code subset, and send a first scenario simulation request containing the first application scenario identifier to the scenario simulator;
[0065] The scenario simulator 130 is used to start the scenario simulation function after receiving the first scenario data request to simulate and obtain the first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and send a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool;
[0066] The code testing tool 120 is further configured to, after receiving the first scenario simulation request response, use the first application scenario simulation data carried in the first scenario simulation request response as a test input to test the first code subset to obtain a first test report.
[0067] In some possible implementations, the first test report records a first test coverage rate obtained by using the first application scenario simulation data as a test input;
[0068] The code testing tool is also used to search for an application scenario identifier in the first code subset when the first test coverage recorded in the first test report is less than a threshold; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator;
[0069] The scenario simulator is further used to, after receiving the second scenario data request, start the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool;
[0070] The code testing tool is further used to test the first code subset after receiving the second scenario simulation request response, using the second application scenario simulation data carried in the second scenario simulation request response as test input to obtain a second test report.
[0071] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input;
[0072] The code testing tool is also used to search for application scenario identifiers in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset, and the second test coverage is not less than the first test coverage; send a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier to the scenario simulator;
[0073] The scenario simulator is used to start a scenario simulation function and adjust the scenario simulation parameters of the scenario simulation function according to preset rules after receiving the third scenario data request, so as to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool;
[0074] The code testing tool is further used to test the first code subset using the third application scenario simulation data carried in the third scenario simulation request response as test input after receiving the third scenario simulation request response to obtain a third test report.
[0075] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input;
[0076] The code testing tool is also used to search for an application scenario identifier in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset; send a fourth scenario simulation request that does not include the application scenario identifier to the scenario simulator;
[0077] The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fourth scenario data request, and when receiving an application scenario selection instruction response containing a fourth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and send a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool;
[0078] The code testing tool is further used to test the first code subset using the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input after receiving the fourth scenario simulation request response to obtain a fourth test report.
[0079] The optional application scenario identifier set is a subset of the application scenario identifier set supported by the scenario simulator. For example, the optional application scenario identifier set is obtained by combining the application scenario identifiers corresponding to the three application scenarios with the largest simulation depth / breadth by the scenario simulator.
[0080] In some possible implementations, the second test report records the second test coverage rate obtained by using the second application scenario simulation data as the test input. The method also includes: when the second test coverage rate recorded in the second test report is less than a threshold value, the code testing tool searches for the application scenario identifier in the first code subset; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset; the first application scenario simulation data and the second application scenario simulation data are combined to obtain the sixth application scenario simulation data, wherein if the second test coverage rate is greater than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is greater than the first application scenario simulation data, and if the second test coverage rate is less than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is less than the first application scenario simulation data; the sixth application scenario simulation data is used as the test input to test the first code subset to obtain the sixth test report.
[0081] In some possible implementations, the code testing tool is further configured to send a fifth scenario simulation request that does not include an application scenario identifier to the scenario simulator if no application scenario identifier is found in the first code subset;
[0082] The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fifth scenario data request, and when receiving an application scenario selection instruction response containing a fifth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fifth application scenario simulation data corresponding to the application scenario represented by the fifth application scenario identifier, and send a fifth scenario simulation request response carrying the fifth application scenario simulation data to the code testing tool;
[0083] The code testing tool is further used to test the first code subset after receiving the fifth scenario simulation request response, using the fifth application scenario simulation data carried in the fifth scenario simulation request response as test input to obtain a fifth test report.
[0084] The optional application scenario identifier set is a subset of the application scenario identifier set supported by the scenario simulator. For example, the optional application scenario identifier set is obtained by combining the application scenario identifiers corresponding to the three application scenarios with the largest simulation depth / breadth by the scenario simulator.
[0085] In some possible implementations, the code testing tool is further configured to send a first test instruction response including a test completion mark to the test triggering tool after the obtained test report meets the test completion requirement;
[0086] The test trigger tool is used to delete the first test tag pair from the code set after receiving the first test instruction response including the test completion mark.
[0087] See also Figure 2 , Figure 2 The present invention provides a flowchart of a software code testing method by way of example. The software code testing method is applied to a software code automatic testing system. The software code automatic testing system is as follows: Figure 1 As shown in the example.
[0088] Wherein, the software code testing method comprises:
[0089] 201. The test trigger tool starts a first test monitoring process when the first test tag testid11 in the first test tag pair is detected to appear in the code set, wherein the first test monitoring process is used to generate a first test instruction when the second test tag testid12 in the first test tag pair is detected to appear in the code set, and the first test instruction includes a first code subset to be tested, and the first code subset consists of the code located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send the first test instruction to the code testing tool.
[0090] 202. After receiving the first test instruction, the code testing tool searches for the application scenario identifier in the first code subset, reads the first application scenario identifier searched in the first code subset, and sends a first scenario simulation request containing the first application scenario identifier to the scenario simulator.
[0091] 203. After receiving the first scenario data request, the scenario simulator starts the scenario simulation function to simulate and obtain the first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and sends a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool.
[0092] 204. After receiving the first scenario simulation request response, the code testing tool uses the first application scenario simulation data carried in the first scenario simulation request response as a test input to test the first code subset to obtain a first test report.
[0093] See also Figure 3 , Figure 3 is a schematic diagram of the code set containing test tag pairs. Figure 3 The portion between the test mark pairs shown in the example is the first code subset to be tested.
[0094] In some possible implementations, the first test report records a first test coverage rate obtained by using the first application scenario simulation data as the test input.
[0095] Wherein, the method comprises:
[0096] When the first test coverage recorded in the first test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator;
[0097] After receiving the second scenario data request, the scenario simulator starts the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and sends a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool;
[0098] After receiving the second scenario simulation request response, the code testing tool uses the second application scenario simulation data carried in the second scenario simulation request response as a test input to test the first code subset to obtain a second test report.
[0099] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input.
[0100] Wherein, the method comprises:
[0101] When the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset, and the second test coverage is not less than the first test coverage; a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier is sent to the scenario simulator;
[0102] After receiving the third scenario data request, the scenario simulator starts the scenario simulation function and adjusts the scenario simulation parameters of the scenario simulation function according to preset rules to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and sends a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool;
[0103] After receiving the third scenario simulation request response, the code testing tool uses the third application scenario simulation data carried in the third scenario simulation request response as a test input to test the first code subset to obtain a third test report.
[0104] In some possible implementations, the second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input.
[0105] The method comprises: when the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset; sending a fourth scenario simulation request that does not include the application scenario identifier to the scenario simulator;
[0106] After receiving the fourth scenario data request, the scenario simulator sends an application scenario selection instruction including a set of optional application scenario identifiers to the code testing tool, and upon receiving an application scenario selection instruction response including a fourth application scenario identifier fed back by the code testing tool, starts a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and sends a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool;
[0107] After receiving the fourth scenario simulation request response, the code testing tool uses the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input to test the first code subset to obtain a fourth test report.
[0108] In some possible implementations, the second test report records the second test coverage rate obtained by using the second application scenario simulation data as the test input. The method also includes: when the second test coverage rate recorded in the second test report is less than a threshold value, the code testing tool searches for the application scenario identifier in the first code subset; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset; the first application scenario simulation data and the second application scenario simulation data are combined to obtain the sixth application scenario simulation data, wherein if the second test coverage rate is greater than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is greater than the first application scenario simulation data, and if the second test coverage rate is less than the first test coverage rate, the proportion of the second application scenario simulation data in the sixth application scenario simulation data is less than the first application scenario simulation data; the sixth application scenario simulation data is used as the test input to test the first code subset to obtain the sixth test report.
[0109] In some possible implementations, the method further includes: if the code testing tool does not search for any application scenario identifier in the first code subset, sending a fifth scenario simulation request that does not include the application scenario identifier to the scenario simulator;
[0110] Wherein, after receiving the fifth scenario data request, the scenario simulator sends an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool, and upon receiving the application scenario selection instruction response containing the fifth application scenario identifier fed back by the code testing tool, starts the scenario simulation function to simulate and obtain the fifth application scenario simulation data corresponding to the application scenario represented by the fifth application scenario identifier, and sends a fifth scenario simulation request response carrying the fifth application scenario simulation data to the code testing tool;
[0111] After receiving the fifth scenario simulation request response, the code testing tool uses the fifth application scenario simulation data carried in the fifth scenario simulation request response as test input to test the first code subset to obtain a fifth test report.
[0112] In some possible implementations, the method further includes: after the test report obtained by the code testing tool meets the test completion requirements (the test completion requirements include the test coverage exceeding a threshold, etc.), the code testing tool sends a first test instruction response including a test completion mark to the test trigger tool.
[0113] After receiving the first test instruction response including a test completion identifier, the test trigger tool deletes the first test tag pair from the code set.
[0114] In some possible implementations, the scenario simulator may include an artificial intelligence model, which is used to support the implementation of the scenario simulation function, including simulating and obtaining application scenario simulation data. The scenario simulator can train the artificial intelligence model as needed, thereby continuously optimizing the scenario simulation function of the artificial intelligence model.
[0115] The technical solution provided by the present application introduces a scenario simulator in a software code automatic testing system, and the scenario simulator can simulate relevant application scenario data as needed; the test trigger tool in the software code automatic testing system is used to start a first test monitoring process when the first test tag testid11 in the first test tag pair is detected to appear in the code set, and the first test monitoring process is used to generate a first test instruction when the second test tag testid12 in the first test tag pair is detected to appear in the code set, and the first test instruction includes a first code subset to be tested, and the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to issue the first test instruction to the code testing tool; the code testing tool is used to search for an application scenario identifier in the first code subset after receiving the first test instruction, read the first application scenario identifier searched in the first code subset, and send a first scenario simulation request containing the first application scenario identifier to the scenario simulator; the code testing tool is also used to test the first code subset using the first application scenario simulation data carried in the first scenario simulation request response as a test input after receiving the first scenario simulation request response to obtain a first test report. The introduction of test markers can automatically trigger the testing of the corresponding code subset. During the testing process, the scenario simulator is used to simulate the relevant application scenario data on demand for testing. This mechanism is conducive to improving the flexibility and intelligence of code testing.
[0116] The embodiment of the present application also provides a computer storage medium, which stores a computer program. When the computer program is executed by a computer system, it can implement part or all of the steps of any method in the embodiment of the present application.
[0117] The embodiment of the present application also provides a computer program, wherein the computer storage medium stores the computer program, and when the computer program is executed by a computer system, part or all of the steps of any one of the methods in the embodiment of the present application can be implemented.
[0118] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0119] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices, units, etc. described above can refer to the corresponding processes in the aforementioned methods or other embodiments and will not be repeated here.
[0120] For the sake of convenience and brevity, the various method embodiments can also be referenced to each other and will not be described in detail. In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0121] The unit described as a separate component may or may not be physically separated, and the component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or it may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, the functional units in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions for a computer device (such as a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a disk or an optical disk.
[0122] The above are only some specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A software code automatic testing system, characterized in that: include: A test trigger tool, a code testing tool and a scenario simulator; wherein the test trigger tool is used to start a first test monitoring process when a first test tag testid11 in a first test tag pair is detected to appear in a code set, wherein the first test monitoring process is used to generate a first test instruction when a second test tag testid12 in the first test tag pair is detected to appear in a code set, wherein the first test instruction includes a first code subset to be tested, wherein the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send a first test instruction to the code testing tool; The code testing tool is used to search for an application scenario identifier in a first code subset after receiving a first test instruction, read the first application scenario identifier searched in the first code subset, and send a first scenario simulation request containing the first application scenario identifier to a scenario simulator; The scenario simulator is used to, after receiving the first scenario data request, start the scenario simulation function to simulate and obtain the first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and send a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool; wherein the code testing tool is also used to, after receiving the first scenario simulation request response, use the first application scenario simulation data carried by the first scenario simulation request response as a test input to test the first code subset to obtain a first test report; The first test report records a first test coverage rate obtained by using the first application scenario simulation data as the test input; The code testing tool is also used to search for an application scenario identifier in the first code subset when the first test coverage recorded in the first test report is less than a threshold; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator; The scenario simulator is further used to, after receiving the second scenario data request, start the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool; The code testing tool is further used to test the first code subset using the second application scenario simulation data carried by the second scenario simulation request response as a test input after receiving the second scenario simulation request response, so as to obtain a second test report; Wherein, when the second test report records the second test coverage obtained by using the second application scenario simulation data as the test input; The code testing tool is also used to search for application scenario identifiers in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifiers different from the read application scenario identifiers are found in the first code subset, and the second test coverage is not less than the first test coverage; send a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier to the scenario simulator; The scenario simulator is used to start the scenario simulation function and adjust the scenario simulation parameters of the scenario simulation function according to preset rules after receiving the third scenario data request, so as to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and send a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool; wherein the preset rules are used to adjust the scenario simulation parameters so that the depth and breadth of the scenario simulation increase step by step, and the magnitude of the step-by-step increase is positively correlated with the size of the second test coverage; The code testing tool is further used to test the first code subset using the third application scenario simulation data carried in the third scenario simulation request response as test input after receiving the third scenario simulation request response to obtain a third test report.
2. The system according to claim 1, characterized in that The second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input; The code testing tool is also used to search for an application scenario identifier in the first code subset when the second test coverage recorded in the second test report is less than a threshold; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset; send a fourth scenario simulation request that does not include the application scenario identifier to the scenario simulator; The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fourth scenario data request, and when receiving an application scenario selection instruction response containing a fourth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and send a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool; The code testing tool is further used to test the first code subset using the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input after receiving the fourth scenario simulation request response to obtain a fourth test report.
3. The system according to claim 1, characterized in that The code testing tool is further configured to send a fifth scenario simulation request that does not include an application scenario identifier to the scenario simulator if no application scenario identifier is found in the first code subset; The scenario simulator is further used to send an application scenario selection instruction containing a set of optional application scenario identifiers to the code testing tool after receiving a fifth scenario data request, and when receiving an application scenario selection instruction response containing a fifth application scenario identifier fed back by the code testing tool, start a scenario simulation function to simulate and obtain fifth application scenario simulation data corresponding to the application scenario represented by the fifth application scenario identifier, and send a fifth scenario simulation request response carrying the fifth application scenario simulation data to the code testing tool; The code testing tool is further used to test the first code subset after receiving the fifth scenario simulation request response, using the fifth application scenario simulation data carried in the fifth scenario simulation request response as test input to obtain a fifth test report.
4. The system according to any one of claims 1 to 3, characterized in that: The code testing tool is further configured to send a first test instruction response including a test completion mark to the test triggering tool after the obtained test report meets the test completion requirement; The test trigger tool is used to delete the first test tag pair from the code set after receiving the first test instruction response including the test completion mark.
5. A software code testing method, characterized in that: The method is applied to a software code automatic testing system, which includes: a test trigger tool, a code testing tool and a scenario simulator; in, The method comprises: the test trigger tool starts a first test monitoring process when monitoring the first test tag testid11 in the first test tag pair appears in the code set, wherein the first test monitoring process is used to generate a first test instruction when monitoring the second test tag testid12 in the first test tag pair appears in the code set, the first test instruction comprises a first code subset to be tested, the first code subset consists of codes located between the first test tag testid11 and the second test tag testid12 in the code set; the test trigger tool is also used to send the first test instruction to the code testing tool; After receiving the first test instruction, the code testing tool searches for the application scenario identifier in the first code subset, reads the first application scenario identifier searched in the first code subset, and sends a first scenario simulation request containing the first application scenario identifier to the scenario simulator; After receiving the first scenario data request, the scenario simulator starts a scenario simulation function to simulate and obtain first application scenario simulation data corresponding to the application scenario represented by the first application scenario identifier, and sends a first scenario simulation request response carrying the first application scenario simulation data to the code testing tool; After receiving the first scenario simulation request response, the code testing tool uses the first application scenario simulation data carried in the first scenario simulation request response as a test input to test the first code subset to obtain a first test report; The first test report records a first test coverage rate obtained by using the first application scenario simulation data as the test input; Wherein, the method further comprises: When the first test coverage recorded in the first test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if a second application scenario identifier different from the first application scenario identifier is searched in the first code subset; read the second application scenario identifier searched in the first code subset, and send a second scenario simulation request containing the second application scenario identifier to the scenario simulator; After receiving the second scenario data request, the scenario simulator starts the scenario simulation function to simulate and obtain the second application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and sends a second scenario simulation request response carrying the second application scenario simulation data to the code testing tool; After receiving the second scenario simulation request response, the code testing tool uses the second application scenario simulation data carried in the second scenario simulation request response as a test input to test the first code subset to obtain a second test report; The second test report records the second test coverage obtained by using the second application scenario simulation data as the test input; Wherein, the method further comprises: When the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset, and the second test coverage is not less than the first test coverage; a third scenario simulation request including the second application scenario identifier and a scenario simulation parameter adjustment identifier is sent to the scenario simulator; After receiving the third scenario data request, the scenario simulator starts the scenario simulation function and adjusts the scenario simulation parameters of the scenario simulation function according to preset rules to simulate and obtain the third application scenario simulation data corresponding to the application scenario represented by the second application scenario identifier, and sends a third scenario simulation request response carrying the third application scenario simulation data to the code testing tool; wherein the preset rules are used to adjust the scenario simulation parameters so that the depth and breadth of the scenario simulation increase stepwise, and the magnitude of the stepwise increase is positively correlated with the size of the second test coverage; After receiving the third scenario simulation request response, the code testing tool uses the third application scenario simulation data carried in the third scenario simulation request response as a test input to test the first code subset to obtain a third test report.
6. The method according to claim 5, characterized in that The second test report records a second test coverage rate obtained by using the second application scenario simulation data as the test input; The method further includes: when the second test coverage recorded in the second test report is less than a threshold, the code testing tool searches for an application scenario identifier in the first code subset; if no other application scenario identifier different from the read application scenario identifier is found in the first code subset; sending a fourth scenario simulation request that does not include the application scenario identifier to the scenario simulator; After receiving the fourth scenario data request, the scenario simulator sends an application scenario selection instruction including a set of optional application scenario identifiers to the code testing tool, and upon receiving an application scenario selection instruction response including a fourth application scenario identifier fed back by the code testing tool, starts a scenario simulation function to simulate and obtain fourth application scenario simulation data corresponding to the application scenario represented by the fourth application scenario identifier, and sends a fourth scenario simulation request response carrying the fourth application scenario simulation data to the code testing tool; After receiving the fourth scenario simulation request response, the code testing tool uses the fourth application scenario simulation data carried in the fourth scenario simulation request response as test input to test the first code subset to obtain a fourth test report.
Citation Information
Patent Citations
MOCK testing method and device
CN106528400A
Interface test method, interface test device, interface test equipment and computer readable storage medium
CN107908556A
Multi-scene simulation response method, device, computer equipment and storage medium
CN110532184A
Code coverage rate testing method and device, computer equipment and storage medium
CN113946515A
Simulation test message generation method and device
CN115587021A