A code testing system and method

CN119782170BActive Publication Date: 2026-08-28WUHAN COMPUTING ECOLOGY TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411867332.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2026-08-28
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

然而,手动构建测试环境、测试用例的过程繁琐,难以快速实现代码测试,且受限于测试人员的测试经验,构建出的测试环境和测试用例可能并不能支持对代码进行准确测试

Benefits of technology

[0015]本申请提供的代码测试系统及方法,当需求在目标测试环境中进行代码测试时,构建用于满足代码测试需求的目标测试环境。当存在需要在目标测试环境进行测试的目标代码时,基于预先管理的支持代码测试的测试用例和与测试用例相应的测试资源和用例配置信息,选取适配于测试目标代码的目标测试用例,并基于与目标测试用例相应的测试资源和用例配置信息配置目标测试用例,最后基于配置后的目标测试用例在目标测试环境对目标代码进行测试。可见,本申请提供的代码测试系统无论部署在具有何种操作系统的主机或服务器内,均可以灵活的构建出用于满足代码测试需求的测试环境来完成代码测试,因此本实施例提供的代码测试系统的可移植性较强,其在任何部署环境下均可以实现在满足代码测试需求的测试环境内实现对代码进行测试。另外,在需要进行代码测试时,代码测试系统能够为代码构建测试环境,配置测试用例,并基于配置后的测试用例在构建的测试环境对代码进行测试。这样,不仅能够提高代码测试效率,且能够使用支持对代码进行准确测试的测试环境和测试用例实现代码测试,从而提高代码测试的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782170B_ABST
    Figure CN119782170B_ABST
Patent Text Reader

Abstract

The application discloses a code testing system and method, relates to the technical field of code testing, and mainly comprises the following technical scheme: the code testing system comprises a management module, a construction module and an execution module. The management module is used for managing test cases supporting code testing and test resource and case configuration information corresponding to the test cases; the construction module is used for constructing a target test environment for meeting code testing requirements; and the execution module is used for selecting a target test case suitable for testing target code when the target code needs to be tested in the target test environment, configuring the target test case based on test resource and case configuration information corresponding to the target test case, and testing the target code in the target test environment based on the configured target test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of code testing technology, and in particular to a code testing system and method. Background Technology

[0002] During software development or before software is put into use, the software code is tested in order to analyze the correctness of the software and discover any vulnerabilities.

[0003] Traditional code testing typically relies on testers manually building test environments and test cases based on their business experience, and then using these test cases to test the code within the test environment. However, manually building test environments and test cases is cumbersome, makes it difficult to quickly implement code testing, and is limited by the testers' experience, so the built test environments and test cases may not be able to accurately test the code. Therefore, how to achieve accurate and efficient code testing has become an urgent problem to be solved. Summary of the Invention

[0004] This application proposes a code testing system and method, the main purpose of which is to achieve accurate and efficient code testing.

[0005] To achieve the above objectives, this application mainly provides the following technical solutions:

[0006] Firstly, this application provides a code testing system, which includes:

[0007] The management module is used to manage test cases that support code testing, as well as the corresponding test resources and test case configuration information.

[0008] Build modules are used to construct target test environments that meet the needs of code testing;

[0009] The execution module is used to select target test cases adapted to test the target code based on the management module when there is target code that needs to be tested in the target test environment, configure the target test cases based on the test resources and test case configuration information corresponding to the target test cases, and test the target code in the target test environment based on the configured target test cases.

[0010] Secondly, this application provides a code testing method, which includes:

[0011] Build a target testing environment that meets the requirements for code testing;

[0012] When there is target code that needs to be tested in the target testing environment, based on the pre-managed test cases that support code testing and the test resources and test case configuration information corresponding to the test cases, a target test case that is suitable for testing the target code is selected, and the target test case is configured based on the test resources and test 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 cases.

[0014] Thirdly, this application provides a computer-readable storage medium including a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the code testing method described in the second aspect.

[0015] The code testing system and method provided in this application construct a target testing environment to meet the code testing requirements when code testing is required in the target testing environment. When target code needs to be tested in the target testing environment, based on pre-managed test cases supporting code testing and corresponding test resources and test case configuration information, target test cases adapted to the target code are selected. The target test cases are then configured based on the corresponding test resources and test case configuration information. Finally, the target code is tested in the target testing environment based on the configured target test cases. Therefore, the code testing system provided in this application can flexibly construct a testing environment to meet code testing requirements regardless of the operating system of the host or server it is deployed on. Thus, the code testing system provided in this embodiment has strong portability, enabling code testing in any deployment environment. Furthermore, when code testing is required, the code testing system can construct a testing environment for the code, configure test cases, and test the code in the constructed testing environment based on the configured test cases. This not only improves code testing efficiency but also enables the use of testing environments and test cases that support accurate code testing, thereby improving the accuracy of code testing.

[0016] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

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

[0018] Figure 1 This illustration shows a schematic diagram of the structure of a code testing system provided in one embodiment of this application;

[0019] Figure 2 A schematic diagram of the structure of a code testing system provided in another embodiment of this application is shown;

[0020] Figure 3 A flowchart of a code testing method provided in one embodiment of this application is shown. Detailed Implementation

[0021] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0022] Code testing is a crucial part of the software development cycle. Traditional code testing typically relies on testers manually building test environments and test cases based on their business experience. Manually building test environments and test cases is not only cumbersome and difficult to implement quickly, but also limited by the testers' experience, the resulting test environments and test cases may not be accurate enough for effective code testing. Therefore, traditional code testing processes struggle to provide accurate and efficient code testing.

[0023] Research has shown that a code testing system can be created. When code testing is needed, the system builds a test environment, configures test cases, and then tests the code within that environment based on the configured test cases. This not only improves code testing efficiency but also enhances the accuracy of code testing by providing a supportive test environment and test cases for accurate testing.

[0024] Based on the above findings, this embodiment provides a code testing system, which specifically includes a management module, a construction module, and an execution module. The management module manages test cases supporting code testing, as well as corresponding test resources and test case configuration information. The construction module constructs a target test environment to meet the code testing requirements. The execution module, when target code needs to be tested in the target test environment, selects target test cases adapted to the target code based on the management module, configures the target test cases based on the corresponding test resources and test case configuration information, and tests the target code in the target test environment based on the configured target test cases. The code testing system provided in this embodiment can flexibly construct a test environment to meet code testing requirements regardless of the operating system of the host or server it is deployed on. Therefore, the code testing system provided in this embodiment has strong portability and can perform code testing in any deployment environment. Furthermore, 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. This not only improves code testing efficiency but also enables the use of testing environments and test cases that support accurate code testing, 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 testing environment to meet code testing requirements; when there is target code that needs to be tested in the target testing environment, selecting target test cases adapted to the target code based on pre-managed test cases supporting code testing and test resources and test case configuration information corresponding to the test cases, and configuring the target test cases based on test resources and test case configuration information corresponding to the target test cases; and testing the target code in the target testing environment based on the configured target test cases.

[0026] The following is a detailed description of the code testing system and method provided in this embodiment.

[0027] like Figure 1 As shown in the figure, this application embodiment provides a code testing system, which may include a management module 11, a build module 12, and an execution module 13. The interaction relationship between the management module 11, the build module 12, and the execution module 13 is as follows:

[0028] The management module 11 is used to manage test cases that support code testing and the corresponding test resources and test case configuration information.

[0029] Module 12 is used to build the target test environment to meet the code testing requirements.

[0030] The execution module 13 is used to select target test cases that are suitable for the target code when there is target code that needs to be tested in the target test environment, based on the management module 11, and configure the target test cases based on the test resources and test case configuration information corresponding to the target test cases, and test the target code in the target test environment based on the configured target test cases.

[0031] The following is a detailed explanation of the specific structure and interaction relationships of each component involved in the code testing system:

[0032] The management module 11 is mainly used to manage test cases that support code testing and the corresponding test resources and test case configuration information.

[0033] When managing test cases that support code testing, the management module 11 can associate test cases with target factors. This allows for the automatic selection of suitable test cases based on these target factors when determining which code needs to be tested. These target factors may include, but are not limited to, at least one of the following: defects that the test cases can detect, the code functionality to which the test cases are applicable, and the code language to which the test cases are applicable.

[0034] The management module 11 manages the test cases that support testing, as well as the corresponding test resources and test case configuration information.

[0035] Test resources are the resources used by test cases when testing code. Test resources may include, but are not limited to, at least one of the following: tools used during testing and the object under test. For example, if code testing requires the code to use an anonymization algorithm 1 to anonymize sensitive data 1, then the anonymization algorithm is the tool used during testing, and sensitive data 1 is the object under test. The management module 11 manages test resources in the form of key-value pairs, where the key is the resource identifier, and the value is the resource description data corresponding to the resource identifier, which describes 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.

[0036] Test case configuration information is used to implement the corresponding test actions of test cases. The management module 11 manages test case configuration information in the form of key-value pairs, where the key is the configuration identifier and the value is the storage address of the configuration identifier, so as to retrieve the corresponding test case configuration information from the corresponding database based on the storage address.

[0037] In some embodiments, further considering that as testing requirements evolve over time, new test case configuration information and test resources may be added to existing test cases, or test cases in the code testing system may be continuously supplemented, based on this, such as Figure 2 As shown, the management module 11 may also include at least one of the following expansion units: a first expansion unit 111 and a second expansion unit 112.

[0038] The first extension unit 111 is used to add the incremental target information to the corresponding target information of the existing test cases when it receives new target information for the existing test cases, and manage it to continuously enrich and improve the testing capabilities of the existing test cases. The target information may include at least one of the following: test cases and test resources.

[0039] The second extension unit 112 is used to add the incremental new test cases to the existing test cases when new test cases are received, and manage them to continuously supplement the test cases in the code testing system and improve the testing capabilities of the code testing system.

[0040] Module 12 is primarily used to build the target test environment to meet the code testing requirements. When performing automated testing on code, the test environment is typically built in advance to test the code within that pre-built environment. This ensures the test environment remains unchanged throughout a round of code testing, thus maintaining the stability of the test results. If the code testing requirements are iteratively updated, a new test environment will be built to meet the updated requirements, allowing the code to be tested in the new environment.

[0041] In some embodiments, in order to flexibly construct a target test environment that meets code testing requirements, the construction module 12 may have, for example, the following features: Figure 2 The structure shown is in Figure 2 The middle construction module 12 includes a deployment unit 121, a pull unit 122, and a startup unit 123. Specifically, the interaction relationship between the deployment unit 121, the pull unit 122, and the startup unit 123 is as follows:

[0042] Deployment unit 121 is used to determine the operating system of the target object for deploying the code testing system when there is a need to perform code testing in the target testing environment; select a container installation package suitable for the architecture of the operating system; deploy the target container on the target object through the container installation package; or, start the installation instructions of the operating system for installing the container; deploy the target container on the target object through the installation instructions.

[0043] In practical applications, testers often deploy code testing systems on target objects such as physical hosts or servers to facilitate code testing. In order to build a target test environment that meets the testing requirements on the target object where the code testing system is deployed, the operating system of the target object is determined, and then a target container is deployed in the operating system to set up a space isolated from the operating system.

[0044] The deployment method for the target container can be any of the following: One method is to select a container installer suitable for the operating system architecture and deploy the target container on the target object using the installer. For example, if the operating system is a Linux distribution (e.g., OpenEuler, Ubuntu, etc.) and its architecture is RISC-V, then a RISC-V container installer suitable for the Linux distribution is selected, and the target container, isolated from the operating system, is deployed on the target object. Another method is to start the operating system's container installation command and deploy the target container on the target object using the installation command. For example, if the operating system is a Linux distribution (e.g., OpenEuler, Ubuntu, etc.) and its architecture is RISC-V, the operating system's container installation command (e.g., the dnf installation command for OpenEuler, the apt installation command for Ubuntu) is started, and the target container, isolated from the operating system, is deployed on the target object. Both deployment methods can be flexibly selected based on business needs, and this embodiment does not limit the choice.

[0045] Pull unit 122 is used to pull the operating system distribution image corresponding to the target test environment from the target container.

[0046] After deploying the target container, it has a space isolated and independent from the target object's operating system. At this point, the pull unit 122 pulls the operating system distribution image corresponding to the target test environment from the target container to deploy the operating system required by the target test environment within the target container. It should be noted that if the operating system required by the target test environment is different from the target object's operating system, then after pulling the corresponding operating system distribution image, the operating system in the target container will be different from the target object's operating system. If the operating system required by the target test environment is the same as the target object's operating system, then after pulling the corresponding operating system distribution image, the operating system in the target container will be the same as the target object's operating system.

[0047] For example, the pull unit 122 pulls an operating system distribution image corresponding to the target test environment through the pull command of the target container, so as to ensure 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 be, but is not limited to, any of the following: Ubuntu, OpenEuler, Debian, etc.

[0048] The startup unit 123 is used to start the target container based on the operating system distribution image and deploy the target test environment in the target container after startup based on the corresponding environment parameters of the target test environment.

[0049] To meet personalized testing needs, the target test environment has corresponding environment parameters, which may include, but are not limited to: programming language (e.g., Python), hardware environment parameters (e.g., CPU, memory size, etc.), software environment (e.g., database, middleware, etc.), network environment parameters (e.g., network bandwidth, network latency, etc.), and CI / CD platform (e.g., Jenkin).

[0050] After successfully starting the target container based on the operating system distribution image, the target test environment is deployed in the target container based on the corresponding environment parameters of the target test environment, thus obtaining the target test environment that meets the code testing requirements.

[0051] Through the interaction between the deployment unit 121, the pull unit 122 and the startup unit 123 included in the construction module 12, the code testing system provided in this embodiment can flexibly build a test environment to meet the code testing requirements and complete the code testing, regardless of the target object with which operating system it is deployed. Therefore, the code testing system provided in this embodiment has strong portability. It can build a test environment to meet the code testing requirements in any environment and perform code testing in the built test environment.

[0052] In some embodiments, further, to achieve test environment reusability, the code testing system can maintain and manage the constructed test environment. Thus, when there is a need to perform code testing in the target test environment, the system can first check if the target test environment exists within the managed test environments. If it exists, the target test environment can be reused directly; if it does not exist, the target test environment can be constructed based on the deployment unit 121, the pull unit 122, and the startup unit 123.

[0053] The execution module 13 primarily functions as follows: First, when target code needs to be tested in the target testing environment, it selects target test cases suitable for the target code based on the test cases supporting code testing managed by the management module 11 and the corresponding test resources and test case configuration information. Second, it configures the target test cases based on the corresponding test resources and test case configuration information. Third, it tests the target code in the target testing environment based on the configured target test cases.

[0054] When the execution module 13 has target code that needs to be tested in the target testing environment, it selects target test cases that are suitable for the target code based on the test cases that support code testing managed by the management module 11 and the corresponding test resources and test case configuration information. The explanation is as follows:

[0055] Execution module 13, based on the test cases supporting code testing managed by the management module and the corresponding test resources and test case configuration information, selects a technical solution suitable for the target test case of the test target code, which may include at least one of the following three:

[0056] The first type involves each test case managed by management module 11 having a corresponding function and code language. These test cases are used to support the execution of tests on code with the corresponding function and code language. For example... Figure 2 As shown, the execution module 13 may include: a first determining unit 131, used to determine the target function and target code language of the target code, and select test cases corresponding to the target function and target code language as target test cases adapted to the test target code.

[0057] Each test case is designed to support the execution of tests on the corresponding functionality and code language, thereby improving the relevance of test cases. Based on this, when determining target test cases for the target code, test cases corresponding to the target functionality and target code language of the target code are identified as the target test cases adapted to the target code.

[0058] 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 test case identifiers of test cases managed by the management module 11 that support code testing; the second determination unit 133 is used to select the test case corresponding to the selected test case identifier from the displayed test case identifiers as the target test case adapted to the test target code.

[0059] The management module 11 manages a large number of test cases that support code testing. In order to enable testers to use the test cases managed by the management module 11 flexibly, the first display unit 132 displays the test case identifiers corresponding to the test cases managed by the management module 11 that support code testing, so as to give testers the authority to select target test cases that are suitable for the test target code.

[0060] When a selected test case identifier is displayed in the test case identifiers displayed by the first display unit 132, it means that the tester needs to use the test cases corresponding to these selected test case identifiers to test the target code. Therefore, the second determination unit 133 selects the test cases corresponding to the selected test case identifiers in the displayed test case identifiers as target test cases that are adapted to the test target code.

[0061] The third type involves each test case managed by management module 11 having a corresponding target defect. These test cases are used to test whether the code contains the target defect. For example... Figure 2 As shown, the execution module 13 may include: a third determining unit 134, used to determine the target defect to be tested in the target code, and select the test cases corresponding to the target defect to be tested as target test cases adapted to the test target code.

[0062] Each test case has a specific target defect, and these test cases can accurately detect whether the target defect exists in the code. Therefore, when selecting target test cases that are suitable for the target code, the first step is to determine the target defect to be tested. Then, the test cases corresponding to the target defect are selected as the target test cases to accurately test whether the target code has the target defect.

[0063] The execution module 13 can select at least one of the three technical solutions for selecting target test cases that are adapted to the test target code 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 first one fails to determine the target test case will the second one be used to continue the determination. In particular, when the selected technical solutions include the third technical solution, the execution order of the third technical solution is last.

[0064] The execution module 13 configures the target test case based on the test resources and test case configuration information corresponding to the target test case, as explained below:

[0065] In some embodiments, considering the large number of test resources and test case configuration information corresponding to each test case, the execution module 13 needs to first select the test resources used to configure the target test case and select the test case configuration information used to configure the target test case when configuring the target test case based on the test resources and test case configuration information corresponding to the target test case, so as to configure the target test case based on the selected test resources used to configure the target test case and the test case configuration information used to configure the target test case.

[0066] The technical solution selected by the execution module 13 for configuring the test resources of the target test cases may include at least one of the following two:

[0067] One scenario is that the test cases managed by management module 11 have at least one corresponding test resource, and each test resource has at least one corresponding resource description data. The target code also has corresponding resource description data requirements. Therefore, if... Figure 2 As shown, the execution module 13 may include: a first selection unit 135, used to determine, in the test resources corresponding to the target test case, at least one test resource in the 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.

[0068] Resource description data is used to describe the corresponding test resources. 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 for the target code is required to indicate the resource description data needed by the test target code.

[0069] Therefore, in order to test the target code using test resources that meet the requirements of the target code, at least one test resource from the corresponding resource description data is identified that matches the resource description data requirements of the target code. This identified test resource is then selected as the test resource for configuring the target test cases. Matching here may include, but is not limited to, any of the following: at least one resource description data of the test resource is completely identical to the resource description data required by the target code; or at least one resource description data of the test resource partially matches the resource description data required by the target code.

[0070] Another scenario is that if the test cases managed by management module 11 have at least one corresponding test resource, then, as follows: Figure 2As shown, the execution module 13 includes a second display unit 136 and a second selection unit 137. The second display unit 136 displays resource identifiers of the test resources corresponding to the target test case. The second selection unit 137 selects the test resources corresponding to the selected resource identifiers from the displayed resource identifiers as the test resources for configuring the target test case.

[0071] There may be one or more test resources corresponding to the target test case. In order to enable testers to flexibly select the test resources corresponding to the target test case, the resource identifiers corresponding to the test resources of the target test case managed by the management module 11 are displayed through the second display unit 136, so as to give the testers the authority to select the test resources used to configure the target test case.

[0072] When a selected resource identifier is displayed in 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 in the displayed resource identifiers as test resources for configuring target test cases.

[0073] The execution module 13 selects at least one technical solution for configuring 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 first one cannot determine the test resources for the target test case will the second one be used to continue the determination. In particular, when the selected technical solutions include the second technical solution, the execution order of the second technical solution is last.

[0074] The technical solution for selecting the test case configuration information for configuring the target test cases by the execution module 13 may include at least one of the following two:

[0075] Option 1: If the test cases managed by management module 11 have at least one corresponding test case configuration information, and each test case configuration information has a corresponding test purpose, then, for example... Figure 2 As shown, the execution module 13 may include: a third selection unit 138, used to determine the expected test purpose of the target code, and select the test case configuration information that matches the expected test purpose of the target code as the test case configuration information for configuring the target test cases.

[0076] Each test case configuration enables the corresponding test case to achieve its designated testing objective. This objective may include, but is not limited to, at least one of the following: testing execution defects, testing code response speed, etc. Therefore, when selecting test case configuration information for configuring target test cases, the test case configuration information whose testing objective matches the expected testing objective of the target code is selected as the test case configuration information for configuring the target test cases. This matching may include, but is not limited to, any of the following: the testing objective is exactly the same as the expected testing objective; or the semantic similarity between the testing objective and the expected testing objective reaches a similarity threshold.

[0077] Option 2: If the test case configuration information managed by management module 11 is at least one, then, for example... 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 identifiers corresponding to the test case configuration information of the target test case; the fourth selection unit 140 is used to select the test case configuration information corresponding to the selected configuration identifier from the displayed configuration identifiers as the test case configuration information for configuring the target test case.

[0078] The target test case may have one or more test case configuration information. In order to enable testers to flexibly select the test case configuration information corresponding to the target test case, the configuration identifier corresponding to the test case configuration information of the target test case managed by the management module 11 is displayed through the third display unit 139, so as to give testers the authority to select the test case configuration information used to configure the target test case.

[0079] When a selected configuration identifier is displayed in the third display unit 139, it means that the tester needs to use the test case configuration information corresponding to the selected configuration identifier to test the target code. Therefore, the fourth selection unit 140 selects the test case configuration information corresponding to the selected configuration identifier in the displayed configuration identifier as the test case configuration information for configuring the target test case.

[0080] The execution module 13 can select at least one technical solution for configuring test case information for the target test cases 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 first one cannot determine the test case configuration information will the next one be used to continue determining it. In particular, when the selected technical solutions include the corresponding technical solution of solution two, the execution order of the corresponding technical solution of solution two is last.

[0081] In some embodiments, further considering that some test cases may require independent and customized test case configuration information in certain scenarios, so as to achieve customized testing of the code through test cases, based on this, such as Figure 2 As shown, the execution module 13 may further include: a fifth selection unit 141, used to perform the following for each target test case: monitoring whether the customized interface 142 of the execution module 13 receives personalized customized test case configuration information for the target test case; if received, selecting the personalized customized test case configuration information as the test case configuration information for configuring the target test case; if not received, selecting the test case configuration information for configuring the target test case based on the test case configuration information corresponding to the target test case managed by the management module 11.

[0082] For a target test case, if the monitoring shows that the customized interface receives personalized test case configuration information for that target test case, it indicates that personalized testing of the target code is required based on the personalized test case configuration information. Therefore, the personalized test case configuration information is selected as the test case configuration information for configuring the target test case. If the monitoring shows that the customized interface does not receive personalized test case configuration information for that target test case, it indicates that the test case configuration information managed by management module 11 is sufficient. There is no need for personalized configuration information for the target test case. Therefore, by using at least one of the above schemes one and two, the test case configuration information for configuring the target test case can be selected based on the test case configuration information managed by management module 11 corresponding to the target test case.

[0083] The following describes how execution module 13 tests the target code in the target test environment based on the configured target test cases:

[0084] In some embodiments, after selecting test resources for configuring target test cases and test case configuration information for configuring target test cases, execution module 13 configures target test cases based on the selected test resources and test case configuration information. Each test resource managed by management module 11 has a corresponding resource call address, and each test case configuration information has a corresponding storage address. Therefore, the technical solution for execution module 13 to configure target test cases can be as follows: Figure 2As shown, the execution module 13 may include a reading unit 143 and a configuration unit 144. The reading unit 143 is used to read the test case configuration information corresponding to the target test case based on the storage address. The configuration unit 144 adds the call 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 test case configuration information as the configuration value of the corresponding test case configuration information item in the target test case, thereby forming the configured target test case.

[0085] Each test case configuration information is stored in a file at a corresponding storage address. To more accurately retrieve the test 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 test 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 Python json module methods json.dump() and json.load(). The json module methods are for deserializing and serializing JSON files.

[0086] The target test case includes test resource configuration items and test case configuration information items. After determining the corresponding test resources and reading the corresponding test case configuration information, the call address of the corresponding test resource is added as the configuration value of the corresponding test resource configuration item in the target test case, and the read test case configuration information is added as the configuration value of the corresponding test case configuration information item in the target test case, thus forming the configured target test case. In this way, when testing the target code based on the target test case, the test resource can be invoked through the call address, and the corresponding test actions can be executed on the target code through the test case configuration information and the invoked test resource.

[0087] In some embodiments, after configuring the target test cases to obtain the configured target test cases, the target code can be tested in the target test environment based on the configured target test cases. Considering that in practical applications, there is at least one target test instance adapted to the test target code, and they have a set execution order, then, as 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 sequentially select configured target test cases according to the execution order. The execution unit 146 is executed each time the sixth selection unit 145 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 any exception occurs during the testing of the target code that would affect the testing of the target code by the next configured target test instance. If no exception occurs, the sixth selection unit is triggered to continue selecting the next configured target test instance; if an exception occurs, the testing of the target code is terminated, and an exception prompt is issued.

[0088] Considering the correlation between the target test cases and the testing of the target code, the sixth selection unit 145 selects a configured target test case each time, and the execution unit 146 tests the target code in the target test environment based on the currently selected configured target test case. It then determines whether any exceptions occur during the testing process that would affect the testing of the target code by the next configured target test instance. If it is determined that no exceptions occur during the testing process of the currently selected configured target test case that would affect the testing of the target code by the next configured target test instance, it means that subsequent target test instances can be used to continue testing the target code, thus triggering the sixth selection unit 145 to select the next configured target test instance. If it is determined that an exception occurs during the testing process of the currently selected configured target test case that would affect the testing of the target code by the next configured target test instance, it means that continuing to test the target code would result in inaccurate testing. Therefore, to avoid erroneous test results, the testing of the target code is terminated, and an exception message is issued for testers to troubleshoot based on the exception message.

[0089] In some embodiments, further, to avoid test errors, when a test resource is used by a test instance for code testing, the corresponding usage status item of the test resource is marked with a first value indicating that the resource is being used, and when the usage status item is marked with the first value, the test resource cannot be used by other test instances. Considering the limited test resources of the code testing system, to achieve test resource reuse, after a test case has completed testing the code using the test resource, the test resource can be released for use by other test cases. The specific release process can be to change the usage status item of the test resource from the first value to a second value indicating that the resource is not being used, so that the second value indicates that the test resource has been released. Based on this, the execution unit 146 is also configured to test the target code in the target test environment based on the currently selected configuration target test case, and after the test is completed, change the usage status item of the corresponding test resource of the currently selected configuration target test case from the first value to the second value indicating that the resource is not being used, so that the corresponding test resource is released through the second value for use by the target test case whose execution order is next to the currently selected configuration target test case.

[0090] In some embodiments, after the execution module 13 tests the target code in the target test environment based on the configured target test cases, the corresponding test results can be obtained. The test results can be used as the basis for testers to perform correctness analysis and vulnerability assessment of the code.

[0091] The code testing system provided in this application constructs a target testing environment to meet the code testing requirements when code testing is required in the target testing environment. When target code needs to be tested in the target testing environment, based on pre-managed test cases supporting code testing and corresponding test resources and test case configuration information, target test cases suitable for the target code are selected. The target test cases are then configured based on the corresponding test resources and test case configuration information. Finally, the target code is tested in the target testing environment based on the configured target test cases. Therefore, the code testing system provided in this application can flexibly construct a testing environment to meet code testing requirements regardless of the operating system of the host or server it is deployed on. Thus, the code testing system provided in this embodiment has strong portability and can perform code testing in any deployment environment that meets the code testing requirements. Furthermore, 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. This not only improves code testing efficiency but also enables the use of testing environments and test cases that support accurate code testing, thereby improving the accuracy of code testing.

[0092] In some embodiments of this application, considering that logs generated during code testing can also be used as a basis for excluding problems in the code, based on this, such as Figure 2 As shown, the code testing system provided in this embodiment may further include: a log module 14, used to record logs generated during the target code testing process and to output the logs in a corresponding format.

[0093] In this embodiment, in order to facilitate quick use of the data in the logs for problem analysis, the logs are formatted and output using a preset data structure so that the data for problem analysis can be quickly retrieved based on the data structure.

[0094] The logs recorded by the logging 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 testing of the target code by the target test cases, and logs of the usage of test resources during the testing of the target code by the target test cases. The above log types can be flexibly selected based on business needs, and this embodiment does not impose any limitations.

[0095] In this embodiment, to facilitate testers in selecting log types, the following is provided: Figure 2 As shown, the log module 14 may include a seventh selection unit 147 and a recording unit 148. 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 from the displayed type identifiers as the target log type to be recorded. The recording unit 148 is used to set the corresponding log language for each target log type, and use the corresponding log language for each target log type to record logs, forming the corresponding log for each target log type.

[0096] There can be at least one log type. To allow testers to flexibly select log types, the seventh selection unit 147 displays a type identifier corresponding to each log type, thus giving testers the authority to select log types. When a selected type identifier is among the displayed type identifiers, it means that the testers need to use the logs corresponding to these selected type identifiers to analyze the target code. Therefore, the seventh selection unit 147 selects the log type corresponding to the selected type identifier from the displayed type identifiers as the target log type to be recorded.

[0097] Considering that different testers have different log viewing habits and languages, the recording unit 148 is used to set a corresponding logging language (e.g., Python) that meets the needs of testers for each target log type. The logging module library (e.g., Python's logging library) of the corresponding logging language for each target log type is used to record logs, forming logs corresponding to each target log type, so that testers can use the logs to analyze problems in the target code.

[0098] In some embodiments of this application, if a 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 are test cases that do not have corresponding target information before the execution module 13 selects target test cases adapted to the test target code. The target information includes at least one of the following: test cases, test resources; if there are, then perform any of the following operations: issue an alarm prompt for test cases that do not have target information, or set the default information to the target information corresponding to the test cases that do not have target information.

[0099] If test cases lack corresponding target information, it means that even if these test cases are selected as target test cases adapted to the target code, they cannot be used to test the target code. Therefore, to ensure the smooth testing of the target code, any of the following operations can be performed on test cases lacking corresponding target information: First, issue an alarm for test cases lacking target information so that testers can complete the target information for these test cases. Second, set the default information to the corresponding target information of the test cases lacking target information. It should be noted that the default information for test resources and test case configuration information is different, and the default information is always information that ensures the test cases can accurately and smoothly test the target code. The default information can be flexibly selected based on business information, and this embodiment does not limit this.

[0100] In some embodiments of this application, in order to enable testers to clearly view the test results of the target code and use the test results to analyze problems in the target code, such as... Figure 2 As shown, the code testing system provided in this embodiment may further include: a generation module 15, used to obtain the test results of the execution module 13 testing the target code, and output the test results in a preset data structure. The preset structure can be determined based on business needs; this embodiment does not limit it. An exemplary data structure is a JSON structure.

[0101] In some embodiments of this application, considering that the test results obtained from testing the code by some test cases may contain target data that needs to be displayed on the interface, in order to display the data more intuitively for testers to view, as follows: Figure 2 As shown, the code testing system provided in this embodiment may further include: a display module 16, 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 the corresponding interface display method.

[0102] The interface display method is related to the configuration of the display module 16 of the code testing system, and the configuration can include, but is not limited to, any of the following: First, the display module 16 is developed based on a C / S architecture, such as Windows Winform, Java AWT, or Python PyQt. Second, the display module 16 is developed based on a B / S architecture, using a web page to display the target data. Third, it is developed based on a web front-end framework, such as Bottstrap or React. Fourth, it is developed based on Python, using a Flask front-end to display the target data.

[0103] If the display module 16 determines that 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, then in order to make the target data more intuitive for the testers, the corresponding interface display method is used to display the target data.

[0104] In some embodiments of this application, considering that testing will consume the hardware resources of the target object deploying the code testing system, and the consumption of hardware resources will affect the provision of services to users of the target object, the testing 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 in this embodiment may further include: a timing module 17, used to determine whether the target code is a scheduled test task; if so, it sets a corresponding test start time for the target code, and when the test start time is reached, it 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 cases.

[0105] Methods for determining whether target code is a scheduled test task can include at least one of the following two approaches: One approach is to determine whether a timing instruction for the target code has been received. If received, the target code is determined to be a scheduled test task; otherwise, it is not. The other approach is to assign a corresponding timing interval to target code of at least one target type, and then determine whether the target code's type matches the target type. If it does, the target code is determined to be a scheduled test task. The target type can be characterized by at least one of the following factors: code developer, code function, code development date, etc.

[0106] If the timing module 17 determines that the target code is a scheduled test task, it sets a corresponding test start time for the target code. When the test start time is reached, it triggers the execution module 13 to execute the steps of testing the target code in the target test environment based on the configured target test cases, thereby achieving scheduled execution of the target code test. If the timing module 17 determines that the target code is not a scheduled test task, it directly triggers the execution module 13 to execute the steps of testing the target code in the target test environment based on the configured target test cases, thereby achieving immediate execution of the target code test.

[0107] The timing mechanism of the timing module 17 can be determined based on business needs. This embodiment does not limit this. For example, the timing module 17 can introduce a CI / CD mechanism as its timing mechanism. For example, Jenkins, as a mainstream CI / CD platform, can be integrated into the timing module 17 when developed based on Python. This bridges the timing module 17 with the CI / CD platform, importing CI / CD capabilities into the platform to achieve scheduled execution of test tasks.

[0108] In some embodiments of this application, in order to achieve automatic determination of the target code, such as Figure 2 As shown, the code testing system provided in this embodiment may further include: a monitoring module 18, used to determine whether new code has been added to a specified code library. If so, the new code is identified as the target code that needs to be tested in the target testing environment, or the new code and the code in the specified code library that is associated with the new code are identified as the target code that needs to be tested in the target testing environment.

[0109] When the monitoring module 18 determines that new code has been added to the specified code library, it indicates that the new code is code that has not yet been tested, and identifies the new code as target code that needs to be tested in the target testing environment. Alternatively, it identifies the new code and the code in the specified code library that is associated with the new code as target code that needs to be tested in the target testing environment, so as to test the target code in a timely manner and perform problem analysis and vulnerability detection on the new code based on the test results.

[0110] In some embodiments of this application, considering that testers may use pre-configured custom test cases to test some code, and to avoid building a complex test environment during testing, the code testing system can provide the target testing system for testers to use. Based on this, such as 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 with a designated gateway so as to provide a target testing environment to the outside world through the external interface, so that testers can use custom test cases to test some code in the target testing environment.

[0111] The form of the external interface 20 can be flexibly selected based on business needs. For example, the external interface is a RESTful API interface. This external interface 20 can have the interface configurations shown in Tables-1 and-2 below, so that the external interface 20 can recognize custom test cases, enabling the custom test cases to test some code in the target test environment built by the code testing system. Table-1 illustrates the parameters and methods for setting the test resources of the external interface 20 to recognize custom test cases, and Table-2 illustrates the parameters and methods for setting the external interface 20 to recognize custom test cases and test case configuration information.

[0112] Table 1

[0113]

[0114] Table 2

[0115]

[0116] It should be noted that after the custom test cases have completed testing in the target testing environment, the management module 11 can also collect the custom test cases into test cases that can be used in the code for management, so as to continuously enrich and improve the test cases. Furthermore, in order to better use the code testing platform, the code testing system can be microservice-based, and the external interface 20 can serve as the external interface of the microservice-based code testing system.

[0117] Furthermore, one embodiment of this 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:

[0118] 201. Build a target test environment to meet the code testing requirements.

[0119] 202. When there is target code that needs to be tested in the target testing environment, based on the pre-managed test cases that support code testing and the test resources and test case configuration information corresponding to the test cases, select target test cases that are suitable for testing the target code, and configure the target test cases based on the test resources and test case configuration information corresponding to the target test cases.

[0120] 203. Test the target code in the target test environment based on the configured target test cases.

[0121] The code testing method provided in this application constructs a target testing environment to meet the code testing requirements when code testing is required in the target testing environment. When target code needs to be tested in the target testing environment, based on pre-managed test cases supporting code testing and corresponding test resources and test case configuration information, target test cases adapted to the target code are selected. These target test cases are then configured based on the corresponding test resources and test case configuration information, and finally, the target code is tested in the target testing environment based on the configured target test cases. Therefore, the method provided in this application can flexibly construct a testing environment to meet code testing requirements, thus enabling code testing within a suitable testing environment. Furthermore, when code testing is required, a testing environment can be built for the code, test cases can be configured, and the code can be tested in the constructed testing environment based on the configured test cases. This not only improves code testing efficiency but also allows the use of a testing environment and test cases that support accurate code testing, thereby improving the accuracy of code testing.

[0122] In some embodiments of this application, the specific process of step 201 above, which constructs a target testing environment to meet code testing requirements, may include:

[0123] When there is a need to perform code testing in the target testing environment, determine the operating system of the target object where the code testing system is deployed;

[0124] Select a container installation package suitable for the architecture of the operating system, and deploy the target container on the target object using the container installation package; or, start the installation instructions of the operating system for installing the container, and deploy the target container on the target object using the installation instructions.

[0125] Pull the operating system distribution image corresponding to the target test environment from the target container;

[0126] The target container is started based on the operating system distribution image, and the target test environment is deployed in the target container after startup based on the corresponding environment parameters of the target test environment.

[0127] In some embodiments of this application, the architecture of the operating system is RISC-V, and / or the operating system distribution image is a Linux operating system distribution image.

[0128] In some embodiments of this application, each test case has a corresponding function and code language. The test case is used to support the execution of tests on code with the corresponding function and code language. Then, the specific process of selecting target test cases adapted to test the target code in step 202 above may include the following steps: determining the target function and target code language of the target code, and selecting the test cases corresponding to the target function and the target code language as target test cases adapted to test the target code.

[0129] In some embodiments of this application, the specific process of selecting target test cases adapted to test the target code in step 202 above may include the following steps: displaying test case identifiers corresponding to test cases that support code testing; selecting the test cases corresponding to the selected test case identifiers from the displayed test case identifiers as target test cases adapted to test the target code.

[0130] In some embodiments of this application, the specific process of selecting target test cases adapted to test the target code in step 201 above may include the following steps: determining the expected defects of the target code, and selecting test cases corresponding to the expected defects as target test cases adapted to test the target code.

[0131] In some embodiments of this 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 further include the following steps: among the test resources corresponding to the target test case, determine the test resource that matches the resource description data requirements of the target code from the at least one corresponding resource description data, and select the determined test resource as the test resource for configuring the target test case.

[0132] In some embodiments of this application, there is at least one test resource corresponding to the test case. Therefore, the code testing method provided in this embodiment may further include the following steps: displaying the resource identifier of the test resource corresponding to the target test case; selecting the test resource corresponding to the selected resource identifier from the displayed resource identifiers as the test resource for configuring the target test case.

[0133] In some embodiments of this application, there is at least one test case configuration information corresponding to the test case, and each test case configuration information has a corresponding test purpose. Therefore, the code testing method provided in this embodiment may further include the following steps: determining the expected test purpose of the target code, and selecting the test case configuration information that matches the expected test purpose of the target code as the test case configuration information for configuring the target test case.

[0134] In some embodiments of this application, the test case configuration information corresponding to the test case is at least one. Therefore, the code testing method provided in this embodiment may further include the following steps: displaying the configuration identifier of the test case configuration information corresponding to the target test case; selecting the test case configuration information corresponding to the selected configuration identifier in the displayed configuration identifier as the test case configuration information for configuring the target test case.

[0135] In some embodiments of this application, the code testing method provided in this embodiment may further include the following steps: for each target test case, execute: monitor whether the customized interface receives personalized customized test case configuration information for the target test case; if received, select the personalized customized test case configuration information as the test case configuration information for configuring the target test case; if not received, select the preset test case configuration information corresponding to the target test case as the test case configuration information for configuring the target test case.

[0136] In some embodiments of this application, each test resource has a corresponding resource call address, and each test case configuration information has a corresponding storage address. Therefore, the specific process of configuring the target test case based on the test resources and test case configuration information corresponding to the target test case in step 202 above may include the following steps: reading the test case configuration information corresponding to the target test case based on the storage address; adding the call 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 test case configuration information as the configuration value of the corresponding test case configuration information item in the target test case, thus forming the configured target test case.

[0137] In some embodiments of this application, each test case configuration information is stored in a file at a corresponding storage address. The specific execution process of reading the test 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 test case configuration information corresponding to the target test case from the file at the corresponding storage address.

[0138] In some embodiments of this application, there is at least one target test instance adapted to test the target code, and they have a set execution order. Then, the specific process of testing the target code in the target test environment based on the configured target test cases in the above-mentioned 203 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 during the testing of the target code that affects the testing of the target code by the next configured target test instance. If no exception occurs, the next configured target test instance is selected. If an exception occurs, the testing of the target code is terminated, and an exception prompt is issued.

[0139] In some embodiments of this application, when a test resource is used by a test instance for code testing, the corresponding usage status item of the test resource is marked with a first value indicating that the resource is being used. When the usage status item is marked with the first value, the test resource cannot be used by other test instances. Therefore, the code testing method provided in this embodiment may further include: testing the target code in the target test environment based on the target test case with the currently selected configuration, and after the test is completed, changing the usage status item of the test resource corresponding to the currently selected target test case with the current configuration from the first value to a second value indicating that the resource is not being used.

[0140] In some embodiments of this application, the code testing method provided in this embodiment may further include: when receiving new target information for existing test cases, adding the new target information incrementally to the corresponding target information of the existing test cases; wherein, the target information includes at least one of the following: test cases, test resources.

[0141] In some embodiments of this application, the code testing method provided in this embodiment may further include: when a new test case is received, adding the new test case increment to the existing test cases.

[0142] In some embodiments of this application, the code testing method provided in this embodiment may further include: recording logs generated during the testing of the target code, and outputting the logs in a corresponding format, wherein the logs include at least one of the following types: logs generated by the code testing system, logs generated during the testing of the target code by the target test cases, and logs of the usage of test resources during the testing of the target code by the target test cases.

[0143] In some embodiments of this application, the code testing method provided in this embodiment may further include: displaying a type identifier corresponding to each log type, selecting the log type corresponding to the selected type identifier from 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 for each target log type to record logs, thereby forming a log corresponding to each target log type.

[0144] In some embodiments of this application, the code testing method provided in this embodiment may further include: before selecting target test cases adapted to test the target code, detecting whether there are any preset test cases that do not have corresponding target information, wherein the target information includes at least one of the following: test cases, test resources; if so, performing any of the following operations: issuing an alarm prompt for test cases that do not have target information, or setting the default information to the target information corresponding to the test cases that do not have target information.

[0145] In some embodiments of this application, the code testing method provided in this embodiment may further include: obtaining test results of testing the target code, and outputting the test results in a preset data structure.

[0146] In some embodiments of this application, the code testing method provided in this embodiment may further 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 using an appropriate interface display method.

[0147] In some embodiments of this application, the code testing method provided in this embodiment may further include: determining whether the target code is a timed test task; 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 cases.

[0148] In some embodiments of this application, the code testing method provided in this embodiment may further include: determining whether new code has been added to a specified code library; if so, determining the new code as target code that needs to be tested in the target testing environment; or determining the new code and the code in the specified code library that is associated with the new code as target code that needs to be tested in the target testing environment.

[0149] In some embodiments of this application, the code testing method provided in this embodiment may further include: registering an external interface with a designated gateway to provide a target testing environment to the outside world through the external interface.

[0150] For detailed explanations of the code testing methods provided in this application embodiment, please refer to the corresponding detailed explanations of the above-mentioned code testing system embodiment, which will not be repeated here.

[0151] Furthermore, one embodiment of this application also provides a computer-readable storage medium, the storage medium including a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to execute the above-described code testing method.

[0152] Furthermore, one embodiment of this application also provides an electronic device, the electronic device comprising: a memory for storing a program; and a processor coupled to the memory for running the program to execute the above-described code testing method.

[0153] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0154] It is understood that the relevant features in the above methods and apparatus can be referenced interchangeably. Furthermore, the terms "first," "second," etc., in the above embodiments are used to distinguish between embodiments and do not represent the superiority or inferiority of any particular embodiment.

[0155] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0156] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this application is not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing preferred embodiments of this application.

[0157] In addition, the memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0158] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0159] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data cutover device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data cutover device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0160] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data cutover device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0161] These computer program instructions can also be loaded onto a computer or other programmable data cutover device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0162] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0163] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0164] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0165] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0166] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A code testing system, characterized in that, The code testing system includes: The management module is used to manage test cases that support code testing, as well as the corresponding test resources and test case configuration information. The test resources are the resources that the test cases need to use when testing the code, and the test resources include at least one of the following: the tools used during testing and the object under test during testing. The test case configuration information is used to enable the test cases to perform corresponding test actions. Build modules are used to construct target test environments that meet the needs of code testing; The execution module is used to, when there is target code that needs to be tested in the target testing environment, select target test cases adapted to test the target code based on the management module, and configure the target test cases based on the test resources and test case configuration information corresponding to the target test cases. This allows the configured target test cases to execute the corresponding test actions of the test case configuration information on the target code through the invoked test resources, and to test the target code in the target testing environment based on the configured target test cases. A target test case refers to a test case selected and adapted to test the target code based on the target function, target code language, and the intended defect to be tested. The building module includes: The deployment unit is used to determine the operating system of the target object for deploying the code testing system when there is a need to perform code testing in the target testing environment; select a container installation package suitable for the architecture of the operating system; deploy the target container on the target object through the container installation package; or, start the installation instructions of the operating system for installing the container; deploy the target container on the target object through the installation instructions. A pull unit is used to pull an operating system distribution image corresponding to the target test environment from the target container; The startup unit is used to start the target container based on the operating system distribution image and deploy the target test environment in the target container after startup based on the corresponding environment parameters of the target test environment.

2. The code testing system according to claim 1, characterized in that, The operating system is based on the RISC-V architecture, and / or the operating system distribution image is a Linux operating system distribution image.

3. The code testing system according to claim 1, characterized in that, Each test case has a corresponding function and code language. The test cases are used to support the execution of tests on code with corresponding functions and code languages. Then, the execution module includes: a first determining unit, 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 the target code language as target test cases adapted to test the target code; And / or, The execution module includes: a first display unit, used to display test case identifiers corresponding to the test cases managed by the management module; and a second determination unit, used to select the test cases corresponding to the selected test case identifiers from the displayed test case identifiers as target test cases adapted to test the target code. And / or, Each test case has a corresponding target defect. The test cases are used to test whether the code has the target defect. Then, the execution module includes: a third determining unit, used to determine the target defect to be tested in the target code, and select the test cases corresponding to the target defect to be tested as target test cases adapted to test the target code.

4. The code testing system according to claim 1, characterized in that, The test case has at least one corresponding test resource, 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, the test resource that matches the resource description data requirements of the target code from the at least one corresponding resource description data, 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, then 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 selected resource identifier from the displayed resource identifiers as the test resource for configuring the target test case.

5. The code testing system according to claim 1, characterized in that, The test case configuration information corresponding to the test case is at least one, and each test case configuration information has a corresponding test purpose. Then, the execution module includes: a third selection unit, used to determine the expected test purpose of the target code, and select the test case configuration information that matches the expected test purpose as the test case configuration information for configuring the target test case. And / or, If the test case configuration information corresponding to the test case is at least one, then the execution module includes: a third display unit, used to display the configuration identifier of the test case configuration information corresponding to the target test case; and a fourth selection unit, used to select the test case configuration information corresponding to the selected configuration identifier from the displayed configuration identifiers as the test case configuration information for configuring the target test case.

6. The code testing system according to claim 5, characterized in that, The execution module further includes: The fifth selection unit is used to perform the following for each target test case: monitor whether the customized interface of the execution module receives personalized customized test case configuration information for the target test case; if it receives it, select the personalized customized test case configuration information as the test case configuration information for configuring the target test case; if it does not receive it, select the test case configuration information for configuring the target test case based on the test case configuration information corresponding to the target test case managed by the management module.

7. The code testing system according to claim 1, characterized in that, Each test resource has a corresponding resource call address, and each test case configuration information has a corresponding storage address. Therefore, the execution module includes: The reading unit is used to read the test case configuration information corresponding to the target test case based on the storage address; The configuration unit adds the call address of the corresponding test resource of the target test case to the configuration value of the corresponding test resource configuration item in the target test case, and adds the read test case configuration information to the configuration value of the corresponding test case configuration information item in the target test case, thus forming the configured target test case.

8. The code testing system according to claim 7, characterized in that, Each test 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 to read the test case configuration information corresponding to the target test case from the file at the corresponding storage address using a data reading method corresponding to the file format.

9. The code testing system according to claim 1, characterized in that, If there is at least one target test instance adapted to test the target code, and they have a set execution order, then the execution module includes: The sixth selection unit is used to select the configured target test cases sequentially according to the execution order. The execution unit is executed when the sixth selection unit selects a configured target test case. Based on the currently selected configured target test case, it tests the target code in the target test environment and determines whether an exception occurs during the testing of the target code that would affect the testing of the target code by the next configured target test instance. If no exception occurs, the sixth selection unit is triggered to continue selecting the next configured target test instance. If an exception occurs, the testing of the target code is terminated and an exception prompt is issued.

10. The code testing system according to claim 9, characterized in that, When a test resource is used by a test instance for code testing, the corresponding usage status item of the test resource is marked with a first value indicating that the resource is being used. When the usage status item is marked with the first value, the test resource cannot be used by other test instances. Then, the execution unit is further configured to test the target code in the target test environment based on the target test case with the currently selected configuration. After the test is completed, the usage status item of the test resource corresponding to the currently selected target test case with the configuration is changed from the first value to a second value indicating that the resource is not being used.

11. The code testing system according to any one of claims 1-10, characterized in that, The management module includes at least one of the following extension units: a first extension unit, used to add the incremental new target information to the corresponding target information of the existing test cases when new target information for existing test cases is received, for management purposes, wherein the target information includes at least one of the following: test cases, test resources; a second extension unit, used to add the incremental new test cases to the existing test cases when new test cases are received, for management purposes. And / or, The code testing system further includes a log module, used to record logs generated during the testing of the target code and to output the logs in a corresponding format. The logs include at least one of the following types: logs generated by the code testing system, logs generated during the testing of the target code by the target test cases, and logs of the usage of test resources during the testing of the target code by the target test cases. And / or, The code testing system further includes a display module, used to determine 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, the target data is displayed using an appropriate interface display method. And / or, The code testing system further includes a timing module, which is used to determine whether the target code is a scheduled test task. If so, it sets a corresponding test start time for the target code and, when the test start time is reached, triggers the execution module to execute the step of testing the target code in the target test environment based on the configured target test cases. And / or, The code testing system also includes an external interface module, which is used to register the external interface of the code testing system with a designated gateway so as to provide the target testing environment to the outside world through the external interface.

12. A code testing method, characterized in that, The code testing methods include: Constructing a target testing environment to meet code testing requirements includes: when there is a need to perform code testing in the target testing environment, determining the operating system of the target object for deploying the code testing system; selecting a container installation package suitable for the architecture of the operating system, and deploying the target container on the target object using the container installation package; or, starting the installation instructions for the operating system to install the container, and deploying the target container on the target object using the installation instructions; pulling the operating system distribution image corresponding to the target testing environment from the target container; starting the target container based on the operating system distribution image, and deploying the target testing environment within the started target container based on the corresponding environment parameters of the target testing environment; When target code exists that needs to be tested in the target testing environment, based on pre-managed test cases supporting code testing and corresponding test resources and test case configuration information, target test cases adapted to test the target code are selected. The target test cases are then configured based on the corresponding test resources and test case configuration information, so that the configured target test cases execute the corresponding test actions of the test case configuration information on the target code through the invoked test resources. The test resources are those required by the test cases when testing the code, and include at least one of the following: tools used during testing and the object under test during testing. The test case configuration information is used to enable the test cases to execute corresponding test actions. A target test case refers to a test case selected and adapted to test the target code based on the target function, target code language, and the defect to be tested. The target code is tested in the target test environment based on the configured target test cases.

13. A computer-readable storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to execute the code testing method of claim 12.

Citation Information

Patent Citations

  • Unit test environment container generation method, unit test method and unit test device

    CN115237779A

  • Automatic testing method and device, electronic equipment and storage medium

    CN118820058A