Code testing system and method
By providing a code testing system, including management, construction and execution modules, the cumbersome and inaccurate problems of traditional code testing process are solved, fast and accurate code testing is achieved, and testing efficiency is improved.
Patent Information
- Application Number
- CN202411867332.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-17
AI Technical Summary
Traditional code testing process is cumbersome and difficult to quickly implement code testing. Due to the experience of testers, the built test environment and test cases may not support accurate testing.
Provides a code testing system, including management modules, building modules and execution modules. The management module is used to manage test cases and test resources, the building module is used to build a target test environment, and the execution module is used to select test cases that are suitable for the target code and test in the target test environment.
It realizes fast and accurate code testing, improves testing efficiency, and supports the construction of a test environment that meets the code testing needs in any operating system environment.
Smart Images

Figure CN119782170A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of code testing technology, and in particular to a code testing system and method. Background Art
[0002] During the software development process or before the software is put into use, the software code will be tested to analyze the correctness of the software and discover vulnerabilities in the software through code testing.
[0003] In traditional code testing, testers usually rely on manual construction of test environments and test cases based on business experience, and then use the constructed test cases to test the code in the test environment. However, the process of manually constructing test environments and test cases is cumbersome and difficult to quickly implement code testing. In addition, due to the test experience of testers, the constructed test environments and test cases may not support accurate testing of the code. Therefore, how to achieve accurate and efficient code testing has become a problem that needs to be solved urgently. Summary of the invention
[0004] The present application proposes a code testing system and method, the main purpose of which is to achieve accurate and efficient testing of codes.
[0005] In order to achieve the above objectives, this application mainly provides the following technical solutions:
[0006] In a first aspect, the present application provides a code testing system, the code testing system comprising:
[0007] A management module is used to manage test cases supporting code testing and test resources and case configuration information corresponding to the test cases;
[0008] A building module is used to build a target test environment to meet code testing requirements;
[0009] The execution module is used to select a target test case suitable for testing the target code based on the management module when there is a target code that needs to be tested in the target test environment, and configure the target test case based on the test resources and case configuration information corresponding to the target test case, and test the target code in the target test environment based on the configured target test case.
[0010] In a second aspect, the present application provides a code testing method, which includes:
[0011] Build a target test environment to meet code testing requirements;
[0012] When there is a target code that needs to be tested in the target test environment, based on the pre-managed test cases supporting code testing and the test resources and case configuration information corresponding to the test cases, a target test case suitable for testing the target code is selected, and the target test case is configured based on the test resources and case configuration information corresponding to the target test case;
[0013] The target code is tested in the target test environment based on the configured target test case.
[0014] In a third aspect, the present application provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the code testing method described in the second aspect.
[0015] The code testing system and method provided by the present application, when the code testing is required in the target testing environment, constructs a target testing environment for meeting the code testing requirements. When there is a target code that needs to be tested in the target testing environment, based on the pre-managed test cases supporting code testing and the test resources and case configuration information corresponding to the test cases, select the target test cases adapted to test the target code, and configure the target test cases based on the test resources and case configuration information corresponding to the target test cases, and finally test the target code in the target testing environment based on the configured target test cases. It can be seen that the code testing system provided by the present application can flexibly construct a test environment for meeting the code testing requirements to complete the code testing, regardless of the host or server with any operating system deployed in it, so the code testing system provided by the present embodiment has strong portability, and it can be implemented in any deployment environment to implement the testing of the code in the test environment that meets the code testing requirements. In addition, when code testing is required, the code testing system can build a test environment for the code, configure test cases, and test the code in the constructed test environment based on the configured test cases. In this way, not only can the efficiency of code testing be improved, but also code testing can be implemented using a test environment and test cases that support accurate testing of the code, thereby improving the accuracy of code testing.
[0016] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A schematic diagram of the structure of a code testing system provided by an embodiment of the present application is shown;
[0019] Figure 2 A schematic diagram of the structure of a code testing system provided by another embodiment of the present application is shown;
[0020] Figure 3 A flowchart of a code testing method provided by an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0022] Code testing is an important part of the software development cycle. In traditional code testing, testers usually rely on business experience to manually build test environments and test cases for code testing. Manually building test environments and test cases is not only cumbersome and difficult to quickly implement code testing, but also limited by the test experience of testers. The test environment and test cases built may not support accurate testing of the code. Therefore, the traditional code testing process is difficult to test the code accurately and efficiently.
[0023] After research, it was found that a code testing system can be created. When code testing is needed, a test environment is built for the code through the code testing system, test cases are configured, and the code is tested in the built test environment based on the configured test cases. In this way, not only the efficiency of code testing can be improved, but also code testing can be implemented using a test environment and test cases that support accurate testing of the code, thereby improving the accuracy of code testing.
[0024] Based on the above findings, this embodiment specifically provides a code testing system, and the code testing system provided by this embodiment specifically includes a management module, a construction module and an execution module. The management module is used to manage the test cases supporting code testing and the test resources and case configuration information corresponding to the test cases. The construction module is used to build a target test environment for meeting the code testing requirements. The execution module is used to select a target test case adapted to the test target code based on the management module when there is a target code that needs to be tested in the target test environment, and configure the target test case based on the test resources and case configuration information corresponding to the target test case, and test the target code in the target test environment based on the configured target test case. Regardless of the host or server with any operating system in which the code testing system provided by this embodiment is deployed, a test environment for meeting the code testing requirements can be flexibly constructed to complete the code testing. Therefore, the code testing system provided by this embodiment has strong portability, and it can be implemented in any deployment environment to implement the code testing in the test environment that meets the code testing requirements. In addition, when code testing is required, the code testing system can build a test environment for the code, configure test cases, and test the code in the constructed test environment based on the configured test cases. In this way, not only can the efficiency of code testing be improved, but also code testing can be implemented using a test environment and test cases that support accurate testing of the code, thereby improving the accuracy of code testing.
[0025] Based on the above findings, this embodiment also provides a code testing method, specifically, constructing a target test environment for meeting code testing requirements; when there is a target code that needs to be tested in the target test environment, based on the pre-managed test cases that support code testing and the test resources and case configuration information corresponding to the test cases, select a target test case suitable for testing the target code, and configure the target test case based on the test resources and case configuration information corresponding to the target test case; test the target code in the target test environment based on the configured target test case.
[0026] The following is a detailed description of a code testing system and method provided in this embodiment.
[0027] like Figure 1 As shown, the embodiment of the present application provides a code testing system, and the code testing system provided by the embodiment may include: a management module 11, a construction module 12 and an execution module 13. The interaction relationship between the management module 11, the construction module 12 and the execution module 13 is as follows:
[0028] The management module 11 is used to manage the test cases supporting code testing and the test resources and case configuration information corresponding to the test cases.
[0029] The construction module 12 is used to construct a target test environment for meeting code testing requirements.
[0030] The execution module 13 is used to select a target test case suitable for testing the target code based on the management module 11 when there is a target code that needs to be tested in the target test environment, and configure the target test case based on the test resources and case configuration information corresponding to the target test case, and test the target code in the target test environment based on the configured target test case.
[0031] The following is a detailed description of the specific structure and interaction relationship of each component involved in the code testing system:
[0032] Management Module 11:
[0033] The management module 11 is mainly used to manage the test cases supporting code testing and the test resources and case configuration information corresponding to the test cases.
[0034] When the management module 11 manages the test cases supporting code testing, the test cases can be associated with target factors, so that when determining the code that needs to be tested, the adaptive test cases can be automatically selected for the code based on the target factors. The target factors here can include but are not limited to at least one of the following: defects that can be detected by the test case, code functions applicable to the test case, code languages applicable to the test case, etc.
[0035] The management module 11 manages the test cases supporting the test and is also used to manage the test resources and case configuration information corresponding to the test cases.
[0036] Test resources are resources that test cases need to use when testing the code. Test resources may include but are not limited to at least one of the following: tools used during testing and objects under test during testing. Exemplarily, when testing the code, the code needs to use desensitizing algorithm 1 to desensitize sensitive data 1. The desensitizing algorithm is the tool used during testing, and sensitive data 1 is the object under test during testing. The management module 11 manages test resources in the form of key-value pairs, wherein the key is a resource identifier, and the value is resource description data corresponding to the resource identifier for describing the corresponding test resource. The resource description data may include but is not limited to at least one of the following: resource name, resource type, resource version, resource storage address, etc.
[0037] The use case configuration information is used to implement the test case to execute the corresponding test action. The management module 11 manages the use case configuration information in the form of key-value pairs, where the key is the configuration identifier and the value is the storage address corresponding to the configuration identifier, so as to extract the corresponding use case configuration information from the corresponding database based on the storage address.
[0038] In some embodiments, further, considering the passage of time and the iteration of test requirements, new test case configuration information and test resources will be added to the existing test cases, or the test cases in the code test system will be continuously supplemented. Figure 2 As shown, the management module 11 may further include at least one of the following extension units: a first extension unit 111 and a second extension unit 112 .
[0039] The first expansion unit 111 is used to, when receiving new target information for an existing test case, incrementally add the new target information to the corresponding target information of the existing test case for management so as to continuously enrich and improve the testing capabilities of the existing test case, wherein the target information may include at least one of the following: test case, test resource.
[0040] The second expansion unit 112 is used to incrementally add the newly added test cases to the existing test cases when receiving them, and manage them so as to continuously supplement the test cases in the code testing system and improve the testing capability of the code testing system.
[0041] Building Block 12:
[0042] The construction module 12 is mainly used to build a target test environment to meet the code testing requirements. When the code is automatically tested, the test environment during the test is generally built in advance to test the code in the built test environment, so as to keep the test environment unchanged during a round of code testing, thereby maintaining the stability of the code test results. If the code testing requirements are iteratively updated later, a test environment that meets the iteratively updated code testing requirements will be built again to perform code testing in the new test environment.
[0043] In some embodiments, in order to flexibly construct a target test environment that meets the code test requirements, the construction module 12 may have the following Figure 2 The structure shown in Figure 2 The construction module 12 includes a deployment unit 121, a pull unit 122 and a start unit 123. Specifically, the interaction relationship between the deployment unit 121, the pull unit 122 and the start unit 123 is as follows:
[0044] The deployment unit 121 is used to determine the operating system of the target object to deploy the code testing system when there is a need to perform code testing in the target test environment; select a container installation package suitable for the architecture of the operating system, and deploy the target container on the target object through the container installation package, or start the installation instruction of the operating system for installing the container, and deploy the target container on the target object through the installation instruction.
[0045] In actual applications, testers usually deploy the code testing system in a target object such as a physical host or server for the convenience of code testing. In order to build a target testing environment that meets the testing requirements in the target object where the code testing system is deployed, the operating system of the target object where the code testing system is deployed is determined, and then a target container is deployed in the operating system to set up a space isolated from the operating system through the target container.
[0046] The method for deploying the target container can be any of the following: one is to select a container installation package suitable for the architecture of the operating system, and deploy the target container in the target object through the container installation package. Exemplarily, the operating system is a Linux distribution system (e.g., openeuler, ubuntu, etc.), and the architecture of the operating system can be a RISC-V architecture, then select a container installation package of the RISC-V architecture suitable for the Linux distribution system, and deploy the target container isolated from the operating system of the target object in the target object. The other is to start the installation instruction of the operating system for installing the container, and deploy the target container in the target object through the installation instruction. Exemplarily, the operating system is a Linux distribution system (e.g., openeuler, ubuntu, etc.), and the architecture of the operating system is a RISC-V architecture, and start the installation instruction of the operating system for installing the container (e.g., openeuler's installation instruction dnf, ubuntu's installation instruction apt), and deploy the target container of the operating system isolated from the target object in the target object through the installation instruction. The above two methods for deploying target containers can be flexibly selected based on business needs, and this embodiment is not limited to this.
[0047] The pulling unit 122 is used to pull the operating system distribution image corresponding to the target test environment in the target container.
[0048] After the target container is deployed, there is a space that is isolated from and independently exists from the operating system of the target object. At this time, the pulling unit 122 pulls the operating system distribution image corresponding to the target test environment in the target container to deploy the operating system required by the target test environment in the target container. It should be noted that if the operating system required by the target test environment is different from the operating system of the target object, after pulling the operating system distribution image corresponding to the target test environment, the operating system in the target container is different from the operating system of the target object. If the operating system required by the target test environment is the same as the operating system of the target object, after pulling the operating system distribution image corresponding to the target test environment, the operating system in the target container is the same as the operating system of the target object.
[0049] Exemplarily, the pulling unit 122 pulls an operating system distribution image corresponding to the target test environment through the pull instruction of the target container, so that the operating system in the target container is different from the operating system of the target object. For example, the operating system distribution image can be a Linux operating system distribution image, and the operating system distribution image can include but is not limited to any of the following: ubuntu, openeuler, debian, etc.
[0050] The starting unit 123 is used to start the target container based on the operating system distribution version image, and deploy the target test environment in the started target container based on the corresponding environment parameters of the target test environment.
[0051] In order to meet the needs of personalized testing, the target test environment has corresponding environmental parameters, which may include but are not limited to: programming language (for example, Python), hardware environment parameters (for example, CPU, memory size, etc.), software environment (for example, database, middleware, etc.), network environment parameters (for example, network bandwidth, network latency, etc.), CI / CD platform (for example, Jenkins).
[0052] After the target container is successfully started based on the operating system distribution image, the target test environment is deployed in the started target container based on the corresponding environmental parameters of the target test environment, that is, the target test environment that meets the code testing requirements is obtained.
[0053] Through the interaction among the deployment unit 121, the pulling unit 122 and the starting unit 123 included in the construction module 12, the code testing system provided in this embodiment can flexibly construct a test environment that meets the code testing requirements to complete the code testing, no matter what operating system the target object has in which it is deployed. Therefore, the code testing system provided in this embodiment has strong portability, and can construct a test environment that meets the code testing requirements in any environment, and implement testing of the code in the constructed test environment.
[0054] In some embodiments, further, in order to achieve the reusability of the test environment, the code testing system can maintain and manage the constructed test environment. In this way, when there is a need to perform code testing in the target test environment, it is possible to first check whether the target test environment exists in the managed test environment. If it exists, the target test environment can be directly reused. If it does not exist, the target test environment is constructed based on the deployment unit 121, the pulling unit 122 and the starting unit 123.
[0055] Execution module 13:
[0056] The execution module 13 mainly has the following functions: First, when there is a target code that needs to be tested in the target test environment, based on the test cases supporting code testing managed by the management module 11 and the test resources and case configuration information corresponding to the test cases, a target test case suitable for testing the target code is selected. Second, the target test case is configured based on the test resources and case configuration information corresponding to the target test case. Third, the target code is tested in the target test environment based on the configured target test case.
[0057] When there is a target code that needs to be tested in the target test environment, the execution module 13 selects a target test case suitable for testing the target code based on the test cases supporting code testing managed by the management module 11 and the test resources and case configuration information corresponding to the test cases, as described below:
[0058] The execution module 13 selects a technical solution suitable for testing a target test case of the target code based on the test cases supporting code testing managed by the management module and the test resources and case configuration information corresponding to the test cases, which may include at least one of the following three types:
[0059] First, each test case managed by the management module 11 has a corresponding function and code language, and the test case is used to support the execution of a test on a code having a corresponding function and code language. Then, Figure 2 As shown, the execution module 13 may include: a first determination unit 131, used to determine the target function and target code language of the target code, and select the test cases corresponding to the target function and target code language as target test cases suitable for testing the target code.
[0060] Each test case is used to support the execution of tests on the code of the corresponding function and code language to improve the pertinence of the test case test. Based on this, when determining the target test case for the target code, the test case corresponding to the target function and target code language of the target code is determined as the target test case adapted to test the target code.
[0061] The second type, such as Figure 2 As shown, the execution module 13 may include a first display unit 132 and a second determination unit 133. The first display unit 132 is used to display the test case identifiers of the test cases supporting code testing managed by the management module 11; the second determination unit 133 is used to select the test case corresponding to the selected test case identifier among the displayed test case identifiers as the target test case adapted to test the target code.
[0062] There are numerous test cases supporting code testing managed by the management module 11. In order to enable testers to flexibly use the test cases managed by the management module 11, the use case identifiers corresponding to the test cases supporting code testing managed by the management module 11 are displayed through the first display unit 132, so as to give testers the authority to select target test cases suitable for testing the target code.
[0063] When there are selected use case identifiers among the use case identifiers displayed by the first display unit 132, it means that the tester needs to use the test cases corresponding to these selected use case identifiers to test the target code. Therefore, the second determination unit 133 selects the test cases corresponding to the selected use case identifiers among the displayed use case identifiers as target test cases suitable for testing the target code.
[0064] The third type is that each test case managed by the management module 11 has a corresponding purpose defect, and the test case is used to test whether the code has a purpose defect. If Figure 2 As shown, the execution module 13 may include: a third determining unit 134, configured to determine a target defect to be tested in the target code, and select a test case corresponding to the target defect to be tested as a target test case adapted to test the target code.
[0065] Each test case has a corresponding target defect, and the test case can accurately test whether the corresponding target defect exists in the code. Therefore, when selecting a target test case adapted to test the target code, the target defect to be tested in the target code must first be determined. Then the test case corresponding to the target defect is selected as the target test case adapted to test the target code, so as to more accurately test whether the target code has the target defect through the target test case.
[0066] The execution module 13 can select at least one of the above three technical solutions for selecting target test cases suitable for testing target codes based on business needs. It should be noted that when two or more technical solutions are selected, various technical solutions have corresponding execution orders. When the former cannot determine the target test case, the latter will be used to continue determining it. In particular, when the third technical solution is included in the selected technical solutions, the execution order of the third technical solution is last.
[0067] The execution module 13 configures the target test case based on the test resources and case configuration information corresponding to the target test case, as follows:
[0068] In some embodiments, considering that the number of test resources and use case configuration information corresponding to each test case is large, when the execution module 13 configures the target test case based on the test resources and use case configuration information corresponding to the target test case, it is necessary to first select the test resources used to configure the target test case and select the use case configuration information for configuring the target test case, so as to configure the target test case based on the selected test resources for configuring the target test case and the use case configuration information for configuring the target test case.
[0069] The technical solution selected by the execution module 13 for configuring the test resources of the target test case may include at least one of the following two:
[0070] One is that the test case managed by the management module 11 has at least one test resource corresponding to it, and each test resource has at least one corresponding resource description data, and the target code has corresponding resource description data requirements, then, Figure 2 As shown, the execution module 13 may include: a first selection unit 135, used to determine, among the test resources corresponding to the target test case, a test resource in at least one corresponding resource description data that matches the resource description data requirements of the target code, and select the determined test resource as the test resource for configuring the target test case.
[0071] The resource description data is used to describe the corresponding test resource, and at least one resource description may include but is not limited to at least one of the following: resource name, resource type, resource version, resource storage address, etc. The resource description data requirement of the target code is used to indicate the resource description data required for testing the target code.
[0072] Based on this, in order to test the target code using the test resources that meet the requirements of the target code, the test resources that match the resource description data requirements of the target code in the corresponding at least one resource description data are determined, and the determined test resources are selected as the test resources for configuring the target test case. The matching here may include but is not limited to any of the following situations: at least one resource description data of the test resource is exactly the same as the resource description data required by the resource description data requirements of the target code, and at least one resource description data of the test resource is partially the same as the resource description data required by the resource description data requirements of the target code.
[0073] Another is that the test case managed by the management module 11 has at least one test resource corresponding to it. Then, Figure 2As shown, the execution module 13 includes a second display unit 136 and a second selection unit 137. The second display unit 136 is used to display the resource identifier of the test resource corresponding to the target test case. The second selection unit 137 is used to select the test resource corresponding to the selected resource identifier from the displayed resource identifiers as the test resource for configuring the target test case.
[0074] There may be one or more test resources corresponding to the target test case. In order to enable the tester to flexibly select the test resources corresponding to the target test case, the resource identifier corresponding to the test resource corresponding to the target test case managed by the management module 11 is displayed through the second display unit 136, so as to give the tester the authority to select the test resources used to configure the target test case.
[0075] When there are selected resource identifiers among the resource identifiers displayed by the second display unit 136, it means that the tester needs to use the test resources corresponding to these selected resource identifiers to test the target code. Therefore, the second selection unit 137 selects the test resources corresponding to the selected resource identifiers among the displayed resource identifiers as the test resources for configuring the target test case.
[0076] The execution module 13 selects at least one technical solution for configuring the test resources for the target test case based on business needs. It should be noted that when two or more technical solutions are selected, the various technical solutions have a corresponding execution order. Only when the previous one cannot determine the test resources for the target test case, the latter one will be used to continue determining. In particular, when the second technical solution is included in the selected technical solutions, the execution order of the second technical solution is last.
[0077] The technical solution for the execution module 13 to select the use case configuration information for configuring the target test case may include at least one of the following two:
[0078] Solution 1: The management module 11 manages at least one test case configuration information corresponding to the test case, and each test case configuration information has a corresponding test purpose. Figure 2 As shown, the execution module 13 may include: a third selection unit 138, which is used to determine the expected test purpose of the target code, and select the use case configuration information that matches the corresponding test purpose with the expected test purpose of the target code as the use case configuration information for configuring the target test case.
[0079] Each use case configuration information can enable the corresponding test case to achieve the corresponding test purpose, and the test purpose may include but is not limited to at least one of the following: test execution defects, test code response speed, etc. Based on this, when selecting the use case configuration information for configuring the target test case, the use case configuration information that matches the corresponding test purpose with the expected test purpose of the target code is selected as the use case configuration information for configuring the target test case. The match here may include but is not limited to any of the following situations: the test purpose is exactly the same as the expected test purpose, and the semantic similarity between the test purpose and the expected test purpose reaches a similarity threshold.
[0080] Solution 2: The test case configuration information corresponding to the test case managed by the management module 11 is at least one, then, Figure 2 As shown, the execution module 13 includes a third display unit 139 and a fourth selection unit 140. The third display unit 139 is used to display the configuration identifier corresponding to the use case configuration information corresponding to the target test case; the fourth selection unit 140 is used to select the use case configuration information corresponding to the selected configuration identifier from the displayed configuration identifiers as the use case configuration information for configuring the target test case.
[0081] There may be one or more use case configuration information corresponding to the target test case. In order to enable testers to flexibly select the use case configuration information corresponding to the target test case, the configuration identifier corresponding to the use case configuration information corresponding to the target test case managed by the management module 11 is displayed through the third display unit 139 to give the tester the authority to select the use case configuration information used to configure the target test case.
[0082] When there is a selected configuration identifier among the configuration identifiers displayed by the third display unit 139, it means that the tester needs to use the use case configuration information corresponding to these selected configuration identifiers to test the target code. Therefore, the fourth selection unit 140 selects the use case configuration information corresponding to the selected configuration identifier among the displayed configuration identifiers as the use case configuration information for configuring the target test case.
[0083] The execution module 13 selects at least one of the technical solutions for configuring the use case configuration information of the target test case based on business needs. It should be noted that when two or more technical solutions are selected, the various technical solutions have a corresponding execution order. Only when the current one cannot determine the use case configuration information, the next one will be used to continue determining. In particular, when the selected technical solutions include the technical solution corresponding to Solution 2, the execution order of the technical solution corresponding to Solution 2 is last.
[0084] In some embodiments, further, considering that some test cases in some scenarios may require independent personalized customized use case configuration information, in order to implement personalized customized testing of the code through the test cases, based on this, Figure 2 As shown, the execution module 13 may also include: a fifth selection unit 141, which is used to execute separately for each target test case: whether the customization interface 142 of the monitoring execution module 13 receives the personalized customized use case configuration information for the target test case; if received, the personalized customized use case configuration information is selected as the use case configuration information for configuring the target test case; if not received, based on the use case configuration information corresponding to the target test case managed by the management module 11, the use case configuration information for configuring the target test case is selected.
[0085] For a target test case, if the customized interface is monitored to receive personalized customized use case configuration information for the target test case, it means that the target code needs to be personalized tested based on the personalized customized use case configuration information through the target test case, so the personalized customized use case configuration information is selected as the use case configuration information for configuring the target test case. If the customized interface is not monitored to receive personalized customized use case configuration information for the target test case, it means that the use case configuration information managed by the management module 11 is sufficient, and there is no need for personalized customized configuration information for the target test case. Therefore, through at least one of the above-mentioned schemes 1 and 2, based on the use case configuration information corresponding to the target test case managed by the management module 11, the use case configuration information for configuring the target test case can be selected.
[0086] The execution module 13 tests the target code in the target test environment based on the configured target test case, as described below:
[0087] In some embodiments, after selecting the test resources for configuring the target test case and selecting the use case configuration information for configuring the target test case, the execution module 13 configures the target test case based on the selected test resources for configuring the target test case and the use case configuration information for configuring the target test case. Each test resource managed by the management module 11 has a corresponding resource call address, and each use case configuration information has a corresponding storage address. Then, the technical solution for configuring the target test case by the execution module 13 can be as follows: Figure 2As shown, the execution module 13 may include a reading unit 143 and a configuration unit 144, wherein the reading unit 143 is used to read the use case configuration information corresponding to the target test case based on the storage address; the configuration unit 144 adds the calling address of the test resource corresponding to the target test case as the configuration value of the corresponding test resource configuration item in the target test case, and adds the read use case configuration information as the configuration value of the corresponding use case configuration information item in the target test case, so as to form a configured target test case.
[0088] Each use case configuration information is stored in a file at a corresponding storage address. In order to more accurately read the use case configuration information used to configure the target test case, the reading unit 143 determines the file format of the file at the storage address, and uses a data reading method corresponding to the file format to read the use case configuration information corresponding to the target test case from the file at the corresponding storage address. For example, if the file format of the file at the storage address is JSON, then the data reading method corresponding to the file format can be the json module method json.dump() and json.load() in Python. The json module method is a means of deserialization and serialization for JSON files.
[0089] The target test case includes test resource configuration items and use case configuration information items. After determining the test resource corresponding to the target test case and reading the use case configuration information corresponding to the target test case, the call address of the test resource corresponding to the target test case is added as the configuration value of the corresponding test resource configuration item in the target test case, and the read use case configuration information is added as the configuration value of the corresponding use case configuration information item in the target test case to form a configured target test case. In this way, when testing the target code based on the target test case, the test resource can be called through the call address, and the corresponding test action can be performed on the target code through the use case configuration information and the called test resource.
[0090] In some embodiments, after the target test case is configured to obtain the configured target test case, the target code can be tested in the target test environment based on the configured target test case. Considering that in actual applications, there is at least one target test instance adapted to test the target code and has a set execution order, then, Figure 2As shown, the execution module may include a sixth selection unit 145 and an execution unit 146. The sixth selection unit 145 is used to select the configured target test cases in sequence according to the execution order; the execution unit 146 is used to execute each time the sixth selection unit 145 selects a configured target test case, test the target code in the target test environment based on the currently selected configured target test case, and determine whether an exception occurs in the process of testing the target code that affects the testing of the target code by the next configured target test instance. If not, the sixth selection unit is triggered to continue selecting the next configured target test instance. If so, the test of the target code is terminated and an exception prompt is issued.
[0091] Considering the relevance of the target test case to the target code test, the sixth selection unit 145 selects a configured target test case execution unit 146 to test the target code in the target test environment based on the currently selected configured target test case, and determines whether the process of testing the target code has an exception that affects the next configured target test instance to test the target code. If it is determined that the process of testing the target code by the currently selected configured target test case does not have an exception that affects the next configured target test instance to test the target code, it means that the subsequent target test instance can be used to continue to test the target code, so the sixth selection unit 145 is triggered to continue to select the next configured target test instance. If it is determined that the process of testing the target code by the currently selected configured target test case has an exception that affects the next configured target test instance to test the target code, it means that continuing to test the target code will result in inaccurate testing, so in order to avoid generating erroneous test results, the test of the target code is terminated, and an exception prompt is issued for the tester to perform exception elimination processing based on the exception prompt.
[0092] In some embodiments, further, in order to avoid errors in the test, when the test resource is used by the test instance to perform code testing, the corresponding usage status item of the test resource is identified as a first value indicating that the resource is being used, and when the usage status item is identified as the first value, the test resource cannot be used by other test instances. At the same time, considering that the test resources of the code testing system are limited, in order to achieve the reuse of test resources, after the test case uses the test resource to test the code, the test resource can be released for use by other test cases, and the specific process of release can be to change the usage status item of the test resource from the first value to the second value indicating that the resource is not used, so as to indicate that the test resource has been released by the second value. Based on this, the execution unit 13 is also used to test the target code in the target test environment based on the target test case after the current selected configuration, and after the test is completed, the usage status item of the test resource corresponding to the target test case after the current selected configuration is changed from the first value to the second value indicating that the resource is not used, so as to release the corresponding test resource by the second value, so as to be used by the target test case whose execution order is located after the current selected configuration.
[0093] In some embodiments, after the execution module 13 tests the target code in the target test environment based on the configured target test case, a corresponding test result can be obtained, and the test result can be used as a basis for the tester to perform correctness analysis and vulnerability assessment on the code.
[0094] The code testing system provided by the embodiment of the present application, when the code testing is required in the target test environment, constructs a target test environment for meeting the code testing requirements. When there is a target code that needs to be tested in the target test environment, based on the test cases that support code testing managed in advance and the test resources and case configuration information corresponding to the test cases, select the target test cases adapted to the test target code, and configure the target test cases based on the test resources and case configuration information corresponding to the target test cases, and finally test the target code in the target test environment based on the configured target test cases. It can be seen that the code testing system provided by the embodiment of the present application, regardless of being deployed in a host or server with any operating system, can flexibly construct a test environment for meeting the code testing requirements to complete the code testing, so the code testing system provided by the embodiment of the present application has strong portability, and it can be implemented in any deployment environment to achieve the code testing in the test environment that meets the code testing requirements. In addition, when code testing is required, the code testing system can build a test environment for the code, configure test cases, and test the code in the constructed test environment based on the configured test cases. In this way, not only can the efficiency of code testing be improved, but also code testing can be implemented using a test environment and test cases that support accurate testing of the code, thereby improving the accuracy of code testing.
[0095] In some embodiments of the present application, it is considered that the logs generated during the code testing process can also be used as a basis for troubleshooting code problems. Based on this, Figure 2 As shown, the code testing system provided in this embodiment may further include: a log module 14, which is used to record the logs generated during the target code testing process and output the logs in a corresponding format.
[0096] In this embodiment, in order to facilitate the rapid use of data in the log for problem analysis, the log is formatted and output using a preset data structure, so that data for problem analysis can be quickly looked up based on the data structure.
[0097] The logs recorded by the log module 14 may include but are not limited to at least one of the following types: logs generated by the code testing system, logs generated during the target test case testing the target code, and logs of test resource usage during the target test case testing the target code. The above log types can be flexibly selected based on business needs, and this embodiment does not limit them.
[0098] In this embodiment, in order to facilitate the tester to select the log type, Figure 2 As shown, the log module 14 may include a seventh selection unit 147 and a recording unit 148, wherein the seventh selection unit 147 is used to display the type identifier corresponding to each log type, and select the log type corresponding to the selected type identifier among the displayed type identifiers as the target log type to be recorded; the recording unit 148 is used to set a corresponding log language for each target log type, and use the corresponding log language of each target log type for log recording to form a log corresponding to each target log type.
[0099] There can be at least one log type. In order to enable the tester to flexibly select the log type, the type identifier corresponding to each log type is displayed through the seventh selection unit 147 to give the tester the right to select the log type. When there is a selected type identifier among the displayed type identifiers, it means that the tester needs to use the logs corresponding to these selected type identifiers to analyze the problem of the target code. Therefore, the seventh selection unit 147 selects the log type corresponding to the selected type identifier among the displayed type identifiers as the target log type to be recorded.
[0100] Taking into account that different testers have different log viewing habits and languages, the recording unit 148 is used to set a corresponding log language (for example, Python) that meets the needs of the testers for each target log type, and use the log module library of the log language corresponding to each target log type (for example, Python's logging library) for log recording, to form a corresponding log for each target log type, so that the testers can use it to analyze problems in the target code based on the log.
[0101] In some embodiments of the present application, if the test case does not have corresponding test case configuration information or test resources, then the test case will not be able to test the code. Based on this, the management module 11 in this embodiment can also be used to detect whether there is a test case that does not have corresponding target information before the execution module 13 selects a target test case suitable for testing the target code. The target information includes at least one of the following: test case, test resource; if so, perform any of the following operations: issue an alarm for the test case that does not have target information, and set the default information to the target information corresponding to the test case that does not have target information.
[0102] If it is detected that there are test cases without corresponding target information, it means that even if these test cases are selected as target test cases adapted to the target code, the target test cases cannot be used to test the target code. Therefore, in order to ensure the smooth progress of the target code test, any of the following operations can be performed for the test cases without corresponding target information: First, an alarm is issued for the test cases without target information, so that the test personnel can complete the target information of these test cases. Second, the default information is set to the target information corresponding to the test cases without target information. It should be noted that the default information corresponding to the test resources and the test case configuration information is different, and the default information is information that can ensure that the test cases can accurately and smoothly test the target code. The default information can be flexibly selected based on the business information, and this embodiment does not limit this.
[0103] In some embodiments of the present application, in order to enable the tester to clearly view the test results of the target code and use the test results to analyze the problem of the target code, such as Figure 2 As shown, the code testing system provided in this embodiment may further include: a generation module 15, which is used to obtain the test results of the target code tested by the execution module 13, and output the test results in a preset data structure. The preset structure here can be determined based on business needs, and this embodiment does not limit this. The exemplary data structure is a JSON structure.
[0104] In some embodiments of the present application, considering that some test cases may contain target data that needs to be displayed on the interface in the test results obtained by testing the code, based on this, in order to be able to display the data more intuitively for the tester to view, then, Figure 2 As shown, the code testing system provided in this embodiment may also include: a display module 16, which is used to determine whether there is target data that needs to be displayed on the interface in the test results of the execution module 13 testing the target code; if so, the target data is displayed using a corresponding interface display method.
[0105] The interface display method is related to the configuration form of the display module 16 of the code testing system, and the configuration form may include but is not limited to any of the following: First, the display module 16 is developed based on the C / S architecture, such as Winform of Windows, AWT of JAVA, and PyQt of Python based on the C / S architecture. Second, the display module 16 is developed based on the B / S architecture, and it uses a Web page to display the target data. Third, it is developed based on a Web front-end framework, such as Bottstrap and React. Fourth, it is developed based on Python and displays the target data through the Flask front-end.
[0106] If the display module 16 determines that there is target data that needs to be displayed on the interface in the test result of the execution module 13 testing the target code, the target data is displayed in a corresponding interface display manner in order to enable the tester to view the target data more intuitively.
[0107] In some embodiments of the present application, considering that the test will occupy the hardware resources of the target object of the deployed code testing system, and the occupation of hardware resources will affect the service provided to the users of the target object, the test of the target code can be set as a scheduled task to automatically test the target code when the target object is idle. Based on this, the code testing system provided by this embodiment can also include: a timing module 17, which is used to determine whether the target code is a scheduled test task, and if so, sets a corresponding test start time for the target code, and when the test start time is reached, triggers the execution module 13 to execute the step of testing the target code in the target test environment based on the configured target test case.
[0108] The method for determining whether the target code is a timed test task may include at least one of the following two methods: one is to determine whether a timed instruction for the target code is received, if received, the target code is determined to be a timed test task, if not received, the target code is determined not to be a timed test task. The other is to set at least one target type of target code to have a corresponding timed time, determine whether the type of the target code is a target type, if so, determine that the target code is a timed test task, wherein the target type can be characterized by at least one of the following factors: code developer, code function, code development date, etc.
[0109] If the timing module 17 determines that the target code is a timed test task, the corresponding test start time is set for the target code, and when the test start time is reached, the execution module 13 is triggered to execute the step of testing the target code in the target test environment based on the configured target test case, so as to realize the timed execution of the test of the target code. If the timing module 17 determines that the target code is not a timed test task, the execution module 13 is directly triggered to execute the step of testing the target code in the target test environment based on the configured target test case, so as to realize the instant execution of the test of the target code.
[0110] The timing mechanism of the timing module 17 can be determined based on business needs, which is not limited in this embodiment. For example, the timing module 17 can introduce the CI / CD mechanism as the timing mechanism. For example, Jenkins, as a mainstream CI / CD platform in the market, can introduce the Jenkins module library to the timing module 17 in the case of Python-based development, thereby realizing the bridge between the timing module 17 and the CI / CD platform, and importing the CI / CD capability into the platform to realize the timing execution of test tasks.
[0111] In some embodiments of the present application, in order to realize automatic determination of the target code, such as Figure 2 As shown, the code testing system provided in this embodiment may also include: a monitoring module 18, which is used to determine whether new code is stored in the specified code library. If so, the new code is determined as the target code that needs to be tested in the target test environment, or the new code and the code associated with the new code in the specified code library are determined as the target code that needs to be tested in the target test environment.
[0112] When the monitoring module 18 determines that new code is stored in the specified code library, it indicates that the new code is code that has not been tested, and determines the new code as target code that needs to be tested in the target test environment, or determines the new code and the code associated with the new code in the specified code library as target code that needs to be tested in the target test environment, and tests the target code in time to perform problem analysis and vulnerability detection on the new code based on the test results.
[0113] In some embodiments of the present application, considering that testers may use configured custom test cases to test some codes, and in order to avoid building a complicated test environment during testing, the code testing system can provide a target test system for testers to use. Based on this, Figure 2 As shown, the code testing system provided in this embodiment also includes: an external interface module 19, which is used to register the external interface 20 of the code testing system in a designated gateway to provide a target testing environment to the outside through an external interface, so that testers can use custom test cases to test some codes in the target testing environment.
[0114] The form of the external interface 20 here can be flexibly selected based on business needs. For example, the external interface is a RESTful API interface. The external interface 20 can have the interface configurations shown in Table 1 and Table 2 below, so that the external interface 20 can identify custom test cases, so that the custom test cases can test some codes in the target test environment constructed by the code testing system. Table 1 illustrates the parameters and methods for the external interface 20 to set the test resources for identifying custom test cases, and Table 2 illustrates the parameters and methods for the external interface 20 to set the test resources for identifying custom test cases and case configuration information.
[0115] Table-1
[0116]
[0117] Table-2
[0118]
[0119]
[0120] It should be noted that, after the custom test case is tested in the target test environment, the management module 11 can also collect the custom test case as a test case that supports code management to continuously enrich and improve the test case. Furthermore, in order to better use the code testing platform in the future, the code testing system can be micro-serviced, and the external interface 20 can be used as the external interface of the code testing system after micro-service.
[0121] Furthermore, an embodiment of the present application also provides a code testing method, such as Figure 3 As shown, the code testing method provided in this embodiment may include the following steps 201 to 203:
[0122] 201. Build a target test environment to meet code testing requirements.
[0123] 202. When there is a target code that needs to be tested in the target test environment, based on the pre-managed test cases that support code testing and the test resources and case configuration information corresponding to the test cases, select a target test case that is suitable for testing the target code, and configure the target test case based on the test resources and case configuration information corresponding to the target test case.
[0124] 203. Test the target code in the target test environment based on the configured target test case.
[0125] The code testing method provided by the embodiment of the present application, when the code testing is required in the target test environment, constructs a target test environment for meeting the code testing requirements. When there is a target code that needs to be tested in the target test environment, based on the test cases that support code testing managed in advance and the test resources and case configuration information corresponding to the test cases, select the target test case adapted to the test target code, and configure the target test case based on the test resources and case configuration information corresponding to the target test case, and then test the target code in the target test environment based on the configured target test case. It can be seen that the method provided by the embodiment of the present application can flexibly construct a test environment for meeting the code testing requirements to complete the code testing, so it can be realized in the test environment that meets the code testing requirements to test the code. In addition, when code testing is required, a test environment can be constructed for the code, test cases can be configured, and the code can be tested in the constructed test environment based on the configured test cases. In this way, not only can the code testing efficiency be improved, but also the code testing can be realized using the test environment and test cases that support accurate testing of the code, thereby improving the accuracy of the code testing.
[0126] In some embodiments of the present application, the specific process of building a target test environment for meeting code testing requirements in step 201 may include:
[0127] When there is a need to perform code testing in a target test environment, determining an operating system of a target object for deploying the code testing system;
[0128] Selecting a container installation package suitable for the architecture of the operating system, and deploying a target container on the target object through the container installation package, or starting an installation instruction of the operating system for installing a container, and deploying the target container on the target object through the installation instruction;
[0129] Pulling an operating system distribution image corresponding to the target test environment in the target container;
[0130] The target container is started based on the operating system distribution version image, and the target test environment is deployed in the started target container based on the corresponding environmental parameters of the target test environment.
[0131] In some embodiments of the present application, the architecture of the operating system is a RISC-V architecture, and / or the operating system distribution image is a Linux operating system distribution image.
[0132] In some embodiments of the present application, each test case has a corresponding function and a code language, and the test case is used to support the execution of tests on codes having the corresponding functions and code languages. Then, the specific process of selecting a target test case suitable for testing the target code in the above step 202 may include the following steps: determining the target function and the target code language of the target code, and selecting the test case corresponding to the target function and the target code language as the target test case suitable for testing the target code.
[0133] In some embodiments of the present application, the specific process of selecting the target test case suitable for testing the target code in the above step 202 may include the following steps: displaying the use case identifier corresponding to the test case supporting code testing; and selecting the test case corresponding to the selected use case identifier among the displayed use case identifiers as the target test case suitable for testing the target code.
[0134] In some embodiments of the present application, the specific process of selecting the target test case suitable for testing the target code in the above step 201 may include the following steps: determining the expected defects of the target code, and selecting the test case corresponding to the expected defect as the target test case suitable for testing the target code.
[0135] In some embodiments of the present application, there is at least one test resource corresponding to the test case, each test resource has at least one corresponding resource description data, and the target code has corresponding resource description data requirements. The code testing method provided in this embodiment may also include the following steps: among the test resources corresponding to the target test case, determine the test resource in the corresponding at least one resource description data that matches the resource description data requirements of the target code, and select the determined test resource as the test resource for configuring the target test case.
[0136] In some embodiments of the present application, there is at least one test resource corresponding to the test case. Then, the code testing method provided in this embodiment may also include the following steps: displaying the resource identifier of the test resource corresponding to the target test case; and selecting the test resource corresponding to the selected resource identifier among the displayed resource identifiers as the test resource for configuring the target test case.
[0137] In some embodiments of the present application, there is at least one use case configuration information corresponding to the test case, and each use case configuration information has a corresponding test purpose. Then, the code testing method provided in this embodiment may also include the following steps: determining the expected test purpose of the target code, and selecting the use case configuration information that matches the corresponding test purpose with the expected test purpose of the target code as the use case configuration information for configuring the target test case.
[0138] In some embodiments of the present application, there is at least one use case configuration information corresponding to the test case. Then, the code testing method provided in this embodiment may also include the following steps: displaying the configuration identifier of the use case configuration information corresponding to the target test case; selecting the use case configuration information corresponding to the selected configuration identifier among the displayed configuration identifiers as the use case configuration information for configuring the target test case.
[0139] In some embodiments of the present application, the code testing method provided in this embodiment may also include the following steps: for each target test case, execute separately: monitor whether the customization interface receives the personalized customized use case configuration information for the target test case; if received, select the personalized customized use case configuration information as the use case configuration information for configuring the target test case; if not received, preset the use case configuration information corresponding to the target test case, and select the use case configuration information for configuring the target test case.
[0140] In some embodiments of the present application, each test resource has a corresponding resource calling address, and each use case configuration information has a corresponding storage address. Then, the specific process of configuring the target test case based on the test resources and use case configuration information corresponding to the target test case in the above step 202 may include the following steps: reading the use case configuration information corresponding to the target test case based on the storage address; adding the calling address of the test resource corresponding to the target test case as the configuration value of the corresponding test resource configuration item in the target test case, and adding the read use case configuration information as the configuration value of the corresponding use case configuration information item in the target test case, to form a configured target test case.
[0141] In some embodiments of the present application, each use case configuration information is stored in a file at a corresponding storage address. Then, the specific execution process of the above-mentioned step of reading the use case configuration information corresponding to the target test case based on the storage address may include the following steps: determining the file format of the file corresponding to the storage address, and using a data reading method corresponding to the file format to read the use case configuration information corresponding to the target test case from the file at the corresponding storage address.
[0142] In some embodiments of the present application, there is at least one target test instance adapted to test the target code and has a set execution order. Then, the specific process of the above-mentioned 203 testing the target code in the target test environment based on the configured target test case may include the following steps: selecting the configured target test cases in sequence according to the execution order; executing each time a configured target test case is selected, testing the target code in the target test environment based on the currently selected configured target test case, and determining whether an exception occurs in the process of testing the target code that affects the testing of the target code by the next configured target test instance; if not, continue to select the next configured target test instance; if so, terminate the test of the target code and issue an exception prompt.
[0143] In some embodiments of the present application, when a test resource is used by a test instance to perform code testing, the corresponding usage status item of the test resource is identified as a first value for indicating that the resource is being used, and when the usage status item is identified as the first value, the test resource cannot be used by other test instances. Then, the code testing method provided in this embodiment may further include: testing the target code in the target test environment based on the currently selected configured target test case, and after the test is completed, changing the usage status item of the test resource corresponding to the currently selected configured target test case from the first value to a second value for indicating that the resource is not in use.
[0144] In some embodiments of the present application, the code testing method provided in this embodiment may also include: when new target information for an existing test case is received, incrementally adding the new target information to the target information corresponding to the existing test case; wherein the target information includes at least one of the following: a test case, a test resource.
[0145] In some embodiments of the present application, the code testing method provided in this embodiment may further include: when a new test case is received, incrementally adding the new test case to the existing test case.
[0146] In some embodiments of the present application, the code testing method provided in this embodiment may further include: recording the logs generated during the target code testing process, and formatting the logs accordingly, wherein the logs include at least one of the following types: logs generated by the code testing system, logs generated during the target test case testing the target code, and logs of test resource usage during the target test case testing the target code.
[0147] In some embodiments of the present application, the code testing method provided in this embodiment may also include: displaying the type identifier corresponding to each log type, selecting the log type corresponding to the selected type identifier among the displayed type identifiers as the target log type to be recorded; setting a corresponding log language for each target log type, and using the corresponding log language of each target log type for log recording to form a log corresponding to each target log type.
[0148] In some embodiments of the present application, the code testing method provided in this embodiment may also include: before selecting a target test case suitable for testing the target code, detecting whether there is a preset test case that does not have corresponding target information, and the target information includes at least one of the following: test case, test resource; if so, performing any of the following operations: issuing an alarm prompt for the test case that does not have target information, and setting the default information to the target information corresponding to the test case that does not have target information.
[0149] In some embodiments of the present application, the code testing method provided in this embodiment may further include: obtaining a test result of testing the target code, and outputting the test result in a preset data structure.
[0150] In some embodiments of the present application, the code testing method provided in this embodiment may also include: determining whether there is target data that needs to be displayed on the interface in the test results of the execution module testing the target code; if so, displaying the target data in a corresponding interface display manner.
[0151] In some embodiments of the present application, the code testing method provided in this embodiment may also include: determining whether the target code is a scheduled test task, and if so, setting a corresponding test start time for the target code, and when the test start time is reached, executing the above step 203 to test the target code in the target test environment based on the configured target test case.
[0152] In some embodiments of the present application, the code testing method provided in this embodiment may also include: determining whether new code is stored in the specified code library, and if so, determining the new code as the target code that needs to be tested in the target testing environment, or determining the new code and the code associated with the new code in the specified code library as the target code that needs to be tested in the target testing environment.
[0153] In some embodiments of the present application, the code testing method provided in this embodiment may further include: registering an external interface in a designated gateway to provide a target testing environment externally through the external interface.
[0154] In the code testing method provided in the embodiment of the present application, the detailed explanations used in the execution of each step can be found in the corresponding detailed explanations of the above-mentioned code testing system embodiment, which will not be repeated here.
[0155] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the above-mentioned code testing method.
[0156] Furthermore, an embodiment of the present application also provides an electronic device, which includes: a memory for storing a program; and a processor, coupled to the memory, for running the program to execute the above-mentioned code testing method.
[0157] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0158] It is understandable that the related features in the above methods and devices can be referenced to each other. In addition, the "first", "second" and the like in the above embodiments are used to distinguish the embodiments, but do not represent the advantages and disadvantages of the embodiments.
[0159] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0160] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the application is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the application described herein, and the description of the above specific language is to disclose the preferred embodiment of the application.
[0161] In addition, the memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0162] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0163] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data cutover device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data cutover device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0164] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data switching device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0165] These computer program instructions can also be loaded onto a computer or other programmable data transfer device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0166] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0167] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0168] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0169] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0170] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0171] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A code testing system, characterized in that: The code testing system comprises: A management module is used to manage test cases supporting code testing and test resources and case configuration information corresponding to the test cases; A building module is used to build a target test environment to meet code testing requirements; An execution module is used to select a target test case suitable for testing the target code based on the management module when there is a target code that needs to be tested in the target test environment, and configure the target test case based on the test resources and case configuration information corresponding to the target test case, and test the target code in the target test environment based on the configured target test case.
2. The code testing system according to claim 1, characterized in that: The building blocks include: A deployment unit is used to determine the operating system of the target object on which the code testing system is deployed when there is a need to perform code testing in a target test environment; select a container installation package suitable for the architecture of the operating system, and deploy a target container on the target object through the container installation package, or start an installation instruction of the operating system for installing a container, and deploy the target container on the target object through the installation instruction; A pulling unit, configured to pull an operating system distribution image corresponding to the target test environment in the target container; A starting unit is used to start the target container based on the operating system distribution version image, and deploy the target test environment in the started target container based on the corresponding environmental parameters of the target test environment.
3. The code testing system according to claim 2, characterized in that: The architecture of the operating system is RISC-V architecture, and / or the operating system distribution image is a Linux operating system distribution image.
4. The code testing system according to claim 1, characterized in that: Each test case has a corresponding function and a code language, and the test case is used to support the execution of a test on a code having the corresponding function and code language. Then, the execution module includes: a first determination unit, used to determine a target function and a target code language of the target code, and select a test case corresponding to the target function and the target code language as a target test case suitable for testing the target code; and / or, The execution module includes: a first display unit, used to display the use case identifiers corresponding to the test cases managed by the management module; a second determination unit, used to select the test case corresponding to the selected use case identifier among the displayed use case identifiers as the target test case suitable for testing the target code; and / or, Each test case has a corresponding target defect, and the test case is used to test whether the code has the target defect. Then, the execution module includes: a third determination unit, used to determine the target defect to be tested in the target code, and select the test case corresponding to the target defect to be tested as the target test case suitable for testing the target code.
5. The code testing system according to claim 1, characterized in that: There is at least one test resource corresponding to the test case, each test resource has at least one corresponding resource description data, and the target code has corresponding resource description data requirements, then, the execution module includes: a first selection unit, used to determine, among the test resources corresponding to the target test case, a test resource in the at least one corresponding resource description data that matches the resource description data requirements of the target code, and select the determined test resource as the test resource for configuring the target test case; and / or, If there is at least one test resource corresponding to the test case, the execution module includes: a second display unit, used to display the resource identifier of the test resource corresponding to the target test case; and a second selection unit, used to select the test resource corresponding to the resource identifier selected from the displayed resource identifiers as the test resource for configuring the target test case.
6. The code testing system according to claim 1, characterized in that: There is at least one use case configuration information corresponding to the test case, and each use case configuration information has a corresponding test purpose, then the execution module includes: a third selection unit, which is used to determine the expected test purpose of the target code, and select the use case configuration information that matches the corresponding test purpose with the expected test purpose as the use case configuration information for configuring the target test case; and / or, If there is at least one use case configuration information corresponding to the test case, the execution module includes: a third display unit, used to display the configuration identifier of the use case configuration information corresponding to the target test case; and a fourth selection unit, used to select the use case configuration information corresponding to the selected configuration identifier from the displayed configuration identifiers as the use case configuration information for configuring the target test case.
7. The code testing system according to claim 6, characterized in that: The execution module also includes: The fifth selection unit is used to execute separately for each target test case: monitor whether the customization interface of the execution module receives the personalized customized use case configuration information for the target test case; if received, select the personalized customized use case configuration information as the use case configuration information for configuring the target test case; if not received, based on the use case configuration information corresponding to the target test case managed by the management module, select the use case configuration information for configuring the target test case.
8. The code testing system according to claim 1, characterized in that: Each test resource has a corresponding resource call address, and each use case configuration information has a corresponding storage address. Then, the execution module includes: A reading unit, configured to read the test case configuration information corresponding to the target test case based on the storage address; A configuration unit adds the calling address of the test resource corresponding to the target test case as the configuration value of the corresponding test resource configuration item in the target test case, and adds the read use case configuration information as the configuration value of the corresponding use case configuration information item in the target test case to form a configured target test case.
9. The code testing system according to claim 8, characterized in that: Each use case configuration information is stored in a file at a corresponding storage address. The reading unit is specifically used to determine the file format of the file at the storage address, and use a data reading method corresponding to the file format to read the use case configuration information corresponding to the target test case from the file at the corresponding storage address.
10. The code testing system according to claim 1, characterized in that: There is at least one target test instance adapted to test the target code and has a set execution order, then the execution module includes: A sixth selection unit, used to select the configured target test cases in sequence according to the execution order; An execution unit is used to execute each time the sixth selection unit selects a configured target test case, tests the target code in the target test environment based on the currently selected configured target test case, and determines whether an exception occurs in the process of testing the target code that affects the testing of the target code by the next configured target test instance. If not, the sixth selection unit is triggered to continue selecting the next configured target test instance. If so, the test of the target code is terminated and an exception prompt is issued.
11. The code testing system according to claim 10, characterized in that: When a test resource is used by a test instance to perform code testing, the usage status item corresponding to the test resource is identified as a first value indicating that the resource is being used, and when the usage status item is identified as the first value, the test resource cannot be used by other test instances. Then, the execution unit is further used to test the target code in the target test environment based on the currently selected configured target test case, and after the test is completed, the usage status item of the test resource corresponding to the currently selected configured target test case is changed from the first value to a second value indicating that the resource is not in use.
12. The code testing system according to any one of claims 1 to 11, characterized in that: The management module includes at least one of the following extension units: a first extension unit, for, upon receiving new target information for an existing test case, incrementally adding the new target information to the target information corresponding to the existing test case for management, wherein the target information includes at least one of the following: a test case, a test resource; a second extension unit, for, upon receiving the new test case, incrementally adding the new test case to the existing test case for management; and / or, The code testing system further includes: a log module, which is used to record the logs generated during the target code testing process and format the logs accordingly, wherein the logs include at least one of the following types: logs generated by the code testing system, logs generated during the target code testing process by the target test case, and logs of test resource usage during the target code testing process by the target test case; and / or, The code testing system further includes: a display module, which is used to determine whether there is target data that needs to be displayed on the interface in the test result of the execution module testing the target code; if so, displaying the target data in a corresponding interface display manner; and / or, The code testing system further includes: a timing module, configured to determine whether the target code is a timed test task, and if so, to set a corresponding test start time for the target code, and to trigger the execution module to execute the step of testing the target code in the target test environment based on the configured target test case when the test start time is reached; and / or, The code testing system further includes: an external interface module, which is used to register the external interface of the code testing system in a designated gateway, so as to provide a target testing environment externally through the external interface.
13. A code testing method, characterized in that: The code testing method comprises: Build a target test environment to meet code testing requirements; When there is a target code that needs to be tested in the target test environment, based on the pre-managed test cases supporting code testing and the test resources and case configuration information corresponding to the test cases, a target test case suitable for testing the target code is selected, and the target test case is configured based on the test resources and case configuration information corresponding to the target test case; The target code is tested in the target test environment based on the configured target test case.
14. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the code testing method according to claim 13.
Citation Information
Patent Citations
Code testing method and device
CN109960643A
Test case processing method and device
CN111240998A
Unit test environment container generation method, unit test method and unit test device
CN115237779A
Test method and system, storage medium and equipment
CN115629997A
Automatic testing method and device, electronic equipment and storage medium
CN118820058A