Code publishing method, device, electronic device and storage medium
By obtaining the mapping relationship between code functions and test cases and automating the test code, the problem of low testing efficiency caused by code changes in software development is solved, and efficient code release is achieved.
Patent Information
- Application Number
- CN202211304510.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-24
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-10-24
AI Technical Summary
During the software development process, code changes lead to low testing efficiency, and relying on manual testing cannot meet the high-frequency continuous integration requirements.
By obtaining the mapping relationship between code functions and test cases, test cases are automatically determined, and code testing is performed in a preset test environment to achieve automated code testing.
It improves the efficiency of code release, reduces testing time, and improves test quality and the degree of automation of code release.
Smart Images

Figure CN115543834B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a code publishing method, device, electronic device, and storage medium. Background Art
[0002] In recent years, the development of software, such as fintech, has necessitated software updates to add or change functionality. These updates involve code changes relative to the previous version. Specifically, these changes may include code for new functionality added to the previous version. When these code changes are made, they must be tested, and only after passing these tests can the code be released to update the software.
[0003] However, when changing the code, it is necessary to go through complicated and multiple tests to change the code. Currently, the code mainly relies on manual testing, resulting in low testing efficiency. Summary of the Invention
[0004] The embodiments of the present application provide a code publishing method, device, electronic device and storage medium that can be used in financial technology or other related fields, which can improve the efficiency of code publishing.
[0005] The present invention provides a method for publishing a code, including:
[0006] Obtaining a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, where the first code is used to update the second code, and the first function has a new function compared to the second function;
[0007] Determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship;
[0008] Testing the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case;
[0009] According to the first code after the test passes, the second code is updated using the first code to obtain an updated code;
[0010] Testing the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case;
[0011] Release the updated code based on the second code in the updated code after the test passes.
[0012] The present application also provides a code issuing device, including:
[0013] an acquisition unit, configured to acquire a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, wherein the first code is used to update the second code, and the first function has a new function compared to the second function;
[0014] a use case determination unit, configured to determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship;
[0015] A first testing unit, configured to test the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case;
[0016] a code updating unit, configured to update the second code with the first code according to the first code that passes the test, to obtain an updated code;
[0017] A second testing unit, configured to test the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case;
[0018] The code issuing unit is used to issue the updated code according to the second code in the updated code after passing the test.
[0019] An embodiment of the present application also provides an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps of any code publishing method provided in the embodiment of the present application.
[0020] An embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any code publishing method provided in the embodiment of the present application.
[0021] The embodiment of the present application can obtain the first code, the second code, the first function corresponding to the first code, the second function corresponding to the second code, and the mapping relationship between the preset code function and the test case, the first code is used to update the second code, and the first function has a new function compared to the second function; according to the mapping relationship, the first test case corresponding to the first function and the second test case corresponding to the second function are determined from the test case; the first test case is used to test the first code in a first preset test environment, and the second preset test environment corresponds to the second test case; according to the first code after the test passes, the first code is used to update the second code to obtain the updated code; the second test case is used to test the second code in the updated code in the second preset test environment, and the second preset test environment corresponds to the second test case; according to the second code in the updated code after the test passes, the updated code is released.
[0022] In this application, the first function can be used to determine the first test case for testing the first code, and the second function can be used to determine the second test case for testing the second code. In this way, the first code can be tested in a first preset test environment through the first test case. After the first code test passes, the first code is aggregated to the second code through update to obtain updated code. The second code in the updated code is tested in the second preset test environment through the second test case to determine that after the first code is added to the second code, the second code can also run normally, thereby releasing the updated code that can run normally, thereby realizing automated testing of the code and reducing the time spent on testing the code. As a result, the efficiency of releasing code is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1a This is a flowchart of the code publishing method provided in the embodiment of the present application;
[0025] Figure 1b Schematic diagram of the test environment of the first code provided in an embodiment of the present application;
[0026] Figure 2 This is a schematic diagram of the structure of the code issuing device provided in an embodiment of the present application;
[0027] Figure 3 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0029] Embodiments of the present application provide a code publishing method, device, electronic device, and storage medium.
[0030] The code issuing device may be integrated into an electronic device, such as a terminal or a server. The terminal may be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, or personal computer (PC); the server may be a single server or a server cluster consisting of multiple servers.
[0031] In some embodiments, the code publishing device may also be integrated into multiple electronic devices. For example, the code publishing device may be integrated into multiple servers, and the code publishing method of the present application may be implemented by multiple servers.
[0032] In some embodiments, the server may also be implemented in the form of a terminal.
[0033] Currently, functional changes are inevitable during software development, and these changes are likely to impact other features. Therefore, testing is necessary to verify that these changes do not introduce new errors. This ensures that newly completed changes do not introduce or reintroduce errors into previously tested code. Currently, many companies use a process where developers submit new code, frequently integrate it into the mainline (unchanged code) multiple times a day, and then testers deploy a test environment to perform regression tests. This entire testing process is largely manual. While this testing process is manageable, the introduction of continuous integration practices will significantly increase the frequency of daily integrations, requiring regression and retesting after resubmissions. Given the current reality of tester manpower and the squeeze on testing cycles, this not only increases the burden on testers but also reduces test quality. Ensuring comprehensiveness and accuracy within limited time and resources is crucial. Furthermore, with the increasing number of long-term business processes, manual testing is inefficient in terms of data preparation and business verification.
[0034] For example, the electronic device can obtain a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, where the first code is used to update the second code, and the first function has a new function compared to the second function; according to the mapping relationship, a first test case corresponding to the first function and a second test case corresponding to the second function are determined from the test cases; the first test case is used to test the first code in a first preset test environment, and the first preset test environment corresponds to the first test case; based on the first code after the test passes, the first code is updated with the second code to obtain an updated code; the second test case is used to test the second code in the updated code in a second preset test environment, and the second preset test environment corresponds to the second test case; based on the second code in the updated code after the test passes, the updated code is released.
[0035] Among them, the first function can be used to determine the first test case for testing the first code (newly added code), and the second function can be used to determine the second test case for testing the second code (unchanged code). In this way, the first code can be tested in the first preset test environment through the first test case. After the first code test passes, the first code is aggregated to the second code through update to obtain updated code. The second code in the updated code is tested in the second preset test environment through the second test case to determine that after the first code is added to the second code, the second code can also run normally, so as to release the updated code that can run normally, thereby realizing automated testing of the code and reducing the time spent on testing the code. As a result, the efficiency of releasing code is improved.
[0036] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0037] In this embodiment, a code publishing method is provided, such as Figure 1a As shown, the specific process of the code publishing method can be as follows:
[0038] 110. Obtain a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases. The first code is used to update the second code, and the first function has a new function compared to the second function.
[0039] The first code is a code corresponding to a new function. For example, the first code is a code corresponding to a new function that has not been tested yet, and the first code is waiting to be aggregated to the second code.
[0040] The second code is a code waiting for a new function to be added. For example, the second code can be a code on a software that has been released, or a code after a test has passed.
[0041] The first function is the function corresponding to the first code.
[0042] The second function is the function corresponding to the second code.
[0043] The preset code function is a preset code function.
[0044] Test cases are used to test the code for a specific function. For example, test cases can be applied to integration testing, system testing, and regression testing. Test cases can include associated test scripts, regression scripts, and returned results.
[0045] The mapping relationship is used to indicate the association between the preset code function and the test case.
[0046] For example, the second function presented by the second code at runtime includes function A, function B, and function C. In order to enable the second code to have the newly added function D at runtime, it is necessary to aggregate the first code on the second code so that the first function (function D) corresponding to the first code can be presented on the second code.
[0047] 120. Determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship.
[0048] The first test case is used to test the first code.
[0049] The second test case is used to test the second code.
[0050] For example, the first function includes function D, and the second function includes function A, function B, and function C. The first test case for testing function D is determined from the mapping relationship, and then the second test case corresponding to the second function is determined from the mapping relationship. The second test case includes a test case for testing function A, a test case for testing function B, and a test case for testing function C.
[0051] 130. Test the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case.
[0052] The first preset test environment is a pre-set test environment for testing the first code, and the first preset test environment corresponds to the first test case.
[0053] It is understandable that there are multiple test cases, each test case corresponds to a test environment, multiple test cases may correspond to one test environment, or one test case may correspond to one test environment.
[0054] For example, the first code needs to be run in a first preset test environment. Therefore, the first code needs to be transferred to the first preset test environment and then tested using a first test case.
[0055] In some embodiments, considering the need to test the code in a stable and controllable test environment, testing the first code using a first test case in a first preset test environment includes:
[0056] Performing mirroring processing on the first code to obtain a mirror code of the first code;
[0057] Determine the upload status of the image code into the first preset test environment;
[0058] According to the upload status, the mirror code is run in the first preset test environment to obtain a first state of the mirror code running in the first preset test environment;
[0059] According to the first state, the first code is tested using a first test case in a first preset test environment.
[0060] The mirror code is a code obtained by mirroring the first code, and the mirror code is the same as the first code.
[0061] The upload status is the status of the image code being uploaded to the first preset test environment. For example, the first status may be that the image code is waiting to be uploaded to the first preset test environment, that the image code has failed to be uploaded to the first preset test environment, or that the image code has been successfully uploaded to the first preset test environment, etc.
[0062] The first state is the state of the mirror code running in the first preset test environment. For example, the first state may be that the mirror code is stuck in the first preset test environment, or the mirror code runs sequentially in the first preset test environment, or the mirror code crashes in the first preset test environment, etc.
[0063] For example, when the first state is that the mirror code is sequentially executed in the first preset test environment, the first test case is used to test the first code in the first preset test environment.
[0064] In some embodiments, in order to improve the efficiency of testing the code, the mirror code is run in a first preset test environment according to the upload status, and a first state of the mirror code running in the first preset test environment is obtained, including:
[0065] If the upload status is that the mirror code is uploaded successfully, the mirror code is run in the first preset test environment to obtain a first status of the mirror code running in the first preset test environment;
[0066] If the upload status is that the mirror code has not been uploaded successfully, a problem detection process is performed on the first code to obtain a position to be corrected in the first code;
[0067] Re-mirroring the first code according to the position to be corrected to obtain a new mirrored code;
[0068] Determine the new upload status of the new image code uploaded to the first preset test environment;
[0069] If the new upload status is that the new image code is uploaded successfully, the new image code is run in the first preset test environment to obtain a first status of the new image code running in the first preset test environment.
[0070] The position to be corrected is a position where there is a problem with the writing of the first code. For example, the position to be corrected may be a position where there is a logic problem in the first code, or a position where there is a character problem in the first code, and so on.
[0071] It is understandable that the position to be modified can be presented in the first code in a special color, can be presented in the first code in the form of an annotation, can be presented in the first code in the form of a revision, and so on.
[0072] The new mirror code is a code obtained by re-mirroring the first code.
[0073] The new upload status is the status of the new image code being uploaded to the first preset test environment.
[0074] For example, when the mirror code is successfully uploaded, the mirror code can be run in the first preset test environment. If the mirror code is not successfully uploaded, the first code needs to be detected and processed to obtain the position to be corrected in the first code. If the mirror code is not successfully uploaded because the first preset test environment does not run stably, then the first code does not have a position to be corrected. The first code is mirrored to obtain a new mirror code, and the new mirror code is re-uploaded in the first preset test environment. If the upload is successful, the first state of the new mirror code running in the first preset test environment is determined. If the first code has a position to be corrected, the first code will not be re-mirrored. The position to be corrected needs to be fed back to the developer who developed the first code so that the developer can modify the first code according to the position to be corrected and then re-mirror the modified first code.
[0075] In some embodiments, in order to improve the efficiency of code testing, if the upload status is that the mirror code has not been uploaded successfully, a problem detection process is performed on the first code to obtain a position to be corrected in the first code, including:
[0076] If the upload status is that the mirror code has not been uploaded successfully, the first code is detected for problems to obtain the position of the first code to be corrected;
[0077] According to the position to be corrected, the first code is re-mirrored to obtain a new mirrored code, including:
[0078] When there is no position to be corrected, re-mirroring the first code to obtain a new mirrored code;
[0079] When there are locations to be corrected, the locations to be corrected are sent to the developer of the first code.
[0080] Among them, developers are the people who develop the first code.
[0081] For example, if the mirror code is not successfully uploaded, the first code is checked to see if there are any locations to be corrected. If so, the locations to be corrected are fed back to the developer. The developer modifies the first code based on the locations to be corrected and sends the modified first code to the tester. The tester re-enters the test phase with the modified first code, i.e., the modified first code is re-mirrored to obtain a new mirror code. If there are no locations to be corrected, the first code does not need to be returned to the developer, but is re-mirrored.
[0082] In some embodiments, considering that an unstable test environment may affect the testing of the first code, testing the first code using a first test case in a first preset test environment according to the first state includes:
[0083] When the first state is normal, testing the first code using the first test case;
[0084] When the first state is abnormal, performing problem detection processing on the first code to obtain a position to be corrected in the first code;
[0085] When the position to be revised is stored, the position to be revised is sent to the developer of the first code;
[0086] When there is no position to be corrected, re-running the first code in the first preset test environment to obtain a new first state;
[0087] When the new first state is normal, the first code is retested using the first test case.
[0088] The new first state is a state in which the first code is re-run in the first preset test environment.
[0089] For example, when the first state is normal, it means that the first code can run smoothly in the first preset test environment, so that the first test case can be used to test the first code. When the first state is abnormal, it means that the first code is stuck or crashes when running in the first preset test environment, so as to detect the position to be corrected in the first code. If there is a position to be corrected, the position to be corrected will be fed back to the developer of the first code so that the developer can modify the first code according to the position to be corrected. After the developer modifies the first code, the modified first code is put back into the test environment, that is, the modified first code is uploaded to the first preset test environment again.
[0090] It can be understood that in order to avoid the first code being lost during testing, when the first code is uploaded to the first preset test environment for testing, the first code can be mirrored so that the mirror code of the first code is tested in the first preset test environment, and the state of the mirror code running in the first preset test environment can indicate the first state of the first code running in the first preset test environment.
[0091] 140. Based on the first code that passes the test, the second code is updated using the first code to obtain an updated code.
[0092] The updated code is the code corresponding to the first code after being aggregated into the second code.
[0093] 150. Test the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case.
[0094] The second preset test environment is a pre-set test environment for testing the second code in the updated code, and the second preset test environment corresponds to the second test case.
[0095] In some embodiments, considering that after the first code is aggregated into the second code, it is necessary to test whether the second code can operate normally, the second code in the updated code is tested using a second test case in a second preset test environment, including:
[0096] Running the updated code in a second preset test environment to obtain a second state of the updated code running in the second test environment;
[0097] According to the second state, the second code in the updated code is tested using a second test case in a second preset test environment.
[0098] The second state is a state in which the updated code is running in the second preset test environment. For example, the second state can be normal operation or abnormal operation, where the abnormal operation mainly refers to the update code crashing or freezing in the second preset test environment.
[0099] For example, if the updated code can run normally in the second preset test environment, the second test case can be used to test the second code in the updated code in the second preset test environment. If the updated code fails to run abnormally in the second preset test environment, the second code cannot be tested in the second preset test environment, and problems with the second code need to be detected.
[0100] In some embodiments, considering that an unstable test environment may affect the testing of the second code, testing the second code in the updated code using a second test case in a second preset test environment according to the second state includes:
[0101] When the second state is normal, testing the second code in the updated code using a second test case in a second preset test environment;
[0102] When the second state is abnormal, a problem detection process is performed on the first code in the updated code to obtain a position to be corrected in the first code;
[0103] When there are locations to be corrected, sending the locations to be corrected to the developer of the first code;
[0104] When there is no position to be corrected, re-running the update code in the second preset test environment to obtain a new second state;
[0105] When the new second state is normal, the second code in the updated code is tested using a second test case in a second preset test environment.
[0106] The new second state is a state in which the updated code is run again in the second preset test environment.
[0107] It is understandable that in order to avoid the loss of the update code during testing, the update code can be mirrored to obtain the mirrored update code, and the state of the mirrored update code running in the second preset test environment can indicate the second state of the update code running in the second preset test environment.
[0108] For example, when the second state of the updated code running in the second preset test environment is abnormal, it is necessary to detect problems with the second code in the updated code. If there are locations that need to be corrected, it means that when the first code is aggregated into the second code, there is incompatibility between the first code and the second code. Therefore, it is necessary to feedback the locations that need to be corrected to the developer, so that the developer can modify the first code to improve the incompatibility between the first code and the second code, and then put the modified first code back into the test environment. The test environment includes the test of the first code and the test after the first code is aggregated into the second code. If there are no locations that need to be corrected, the second code is re-run in the second preset test environment.
[0109] 160. Release the updated code according to the second code in the updated code after the test passes.
[0110] For example, if the second code in the updated code passes the test, it means that the first code has not affected the normal operation of the second code after being integrated into the second code, and the updated code is released.
[0111] In some embodiments, as Figure 1bAs shown, in the testing phase of the first code, the mapping relationship between the preset code function and the test case can be obtained through the change of the functional requirements of the software and the change of the test interface. The test case includes three parts in sequence: the associated test script, the regression script and the result return. The developer develops the code according to the demand change, submits the first code, generates the mirror code of the first code, and uploads the mirror code to the first preset test environment. It is judged whether the mirror code is successfully uploaded. If it is successfully uploaded, the mirror code is run in the first preset test environment. If it runs successfully, the first test case corresponding to the first function of the first code is obtained through the mapping relationship. The first test case is used to test the first code. After the first code passes the test, the first code is merged into the second code to obtain the updated code, and the updated code is uploaded to the second preset test environment. If it is not successfully uploaded or not run successfully, it is necessary to determine the position to be corrected in the first code, so that the developer can modify the first code according to the development position and resubmit the modified first code so that the modified first code can be retested.
[0112] In this way, the efficiency of software testing and release in this application has been greatly improved compared with traditional methods. For testers, more time is invested in regression testing. Distributed sustainable integrated automated testing greatly improves testing efficiency in regression testing and meets the needs of agile development models. While increasing the number of tests, it also reduces the repetitive workload of testers. While improving test efficiency, it also increases the problem (bug) discovery rate, greatly improving software quality. Continuous construction and continuous testing are achieved. Adding development regression automation can automate test access before the test is actually involved, without directly returning to modify the code, to help testers perform pre-testing. At the same time, during the execution of automated testing, by analyzing code changes and based on the functions of the test code, the code is specially tested using test cases corresponding to the functions of the test code.
[0113] From the above, it can be seen that the embodiment of the present application can obtain the first code, the second code, the first function corresponding to the first code, the second function corresponding to the second code, and the mapping relationship between the preset code function and the test case, the first code is used to update the second code, and the first function has a new function compared to the second function; according to the mapping relationship, the first test case and the second test case are determined from the test case; the first test case is used to test the first code in the first preset test environment, and the second preset test environment corresponds to the second test case; according to the first code after the test passes, the first code is used to update the second code to obtain the updated code; the second test case is used to test the second code in the updated code in the second preset test environment, and the second preset test environment corresponds to the second test case; according to the second code in the updated code after the test passes, the updated code is released.
[0114] Therefore, this solution can use the first function to determine the first test case for testing the first code, and the second function to determine the second test case for testing the second code. In this way, the first code can be tested in a first preset test environment through the first test case. After the first code test passes, the first code is aggregated to the second code through update to obtain updated code. The second code in the updated code is tested in the second preset test environment through the second test case to determine that after the first code is added to the second code, the second code can also run normally, thereby releasing the updated code that can run normally, thereby realizing automated testing of the code, reducing the time spent on testing the code, and improving the efficiency of releasing the code.
[0115] To better implement the above method, the present application also provides a code publishing device. The code publishing device can be integrated into an electronic device, such as a terminal or a server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc. The server can be a single server or a server cluster consisting of multiple servers.
[0116] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the specific integration of the code issuing device into an electronic device as an example.
[0117] For example, Figure 2 As shown, the code release apparatus may include an acquisition unit 210, a use case determination unit 220, a first test unit 230, a code update unit 240, a second test unit 250, and a code release unit 260, as follows:
[0118] (1) Acquisition unit 210.
[0119] The acquisition unit 210 is used to obtain the first code, the second code, the first function corresponding to the first code, the second function corresponding to the second code, and the mapping relationship between the preset code function and the test case. The first code is used to update the second code, and the first function has an additional function compared to the second function.
[0120] (2) Use case determination unit 220.
[0121] The use case determination unit 220 is configured to determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship.
[0122] (3) First testing unit 230.
[0123] The first testing unit 230 is configured to test the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case.
[0124] In some embodiments, testing the first code using the first test case in the first preset test environment includes:
[0125] Performing mirroring processing on the first code to obtain a mirror code of the first code;
[0126] Determine the upload status of the image code into the first preset test environment;
[0127] According to the upload status, the mirror code is run in the first preset test environment to obtain a first state of the mirror code running in the first preset test environment;
[0128] According to the first state, the first code is tested using a first test case in a first preset test environment.
[0129] In some embodiments, according to the upload status, running the mirror code in the first preset test environment to obtain a first state of the mirror code running in the first preset test environment includes:
[0130] If the upload status is that the mirror code is uploaded successfully, the mirror code is run in the first preset test environment to obtain a first status of the mirror code running in the first preset test environment;
[0131] If the upload status is that the mirror code has not been uploaded successfully, a problem detection process is performed on the first code to obtain a position to be corrected in the first code;
[0132] Re-mirroring the first code according to the position to be corrected to obtain a new mirrored code;
[0133] Determine the new upload status of the new image code uploaded to the first preset test environment;
[0134] If the new upload status is that the new image code is uploaded successfully, the new image code is run in the first preset test environment to obtain a first status of the new image code running in the first preset test environment.
[0135] In some embodiments, if the upload status is that the mirror code has not been uploaded successfully, a problem detection process is performed on the first code to obtain a position to be corrected in the first code, including:
[0136] If the upload status is that the mirror code has not been uploaded successfully, the first code is detected for problems to obtain the position of the first code to be corrected;
[0137] According to the position to be corrected, the first code is re-mirrored to obtain a new mirrored code, including:
[0138] When there is no position to be corrected, re-mirroring the first code to obtain a new mirrored code;
[0139] When there are locations to be corrected, the locations to be corrected are sent to the developer of the first code.
[0140] In some embodiments, testing the first code using a first test case in a first preset test environment according to the first state includes:
[0141] When the first state is normal, testing the first code using the first test case;
[0142] When the first state is abnormal, performing problem detection processing on the first code to obtain a position to be corrected in the first code;
[0143] When there are locations to be corrected, sending the locations to be corrected to the developer of the first code;
[0144] When there is no position to be corrected, re-running the first code in the first preset test environment to obtain a new first state;
[0145] When the new first state is normal, the first code is retested using the first test case.
[0146] (4) Code updating unit 240.
[0147] The code updating unit 240 is configured to update the second code with the first code according to the first code that has passed the test, to obtain an updated code.
[0148] (5) Second testing unit 250.
[0149] The second testing unit 250 is configured to test the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case.
[0150] In some embodiments, testing the second code in the updated code using the second test case in the second preset test environment includes:
[0151] Running the updated code in a second preset test environment to obtain a second state of the updated code running in the second test environment;
[0152] According to the second state, the second code in the updated code is tested using a second test case in a second preset test environment.
[0153] In some embodiments, according to the second state, testing the second code in the updated code using a second test case in a second preset test environment includes:
[0154] When the second state is normal, testing the second code in the updated code using a second test case in a second preset test environment;
[0155] When the second state is abnormal, a problem detection process is performed on the first code in the updated code to obtain a position to be corrected in the first code;
[0156] When there are locations to be corrected, sending the locations to be corrected to the developer of the first code;
[0157] When there is no position to be corrected, re-running the update code in the second preset test environment to obtain a new second state;
[0158] When the new second state is normal, the second code in the updated code is tested using a second test case in a second preset test environment.
[0159] (6) Code issuing unit 260.
[0160] The code issuing unit 260 is configured to issue the updated code according to the second code in the updated code after the test passes.
[0161] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can be found in the previous method embodiments and will not be repeated here.
[0162] As can be seen from the above, the code publishing device of this embodiment obtains the first code, the second code, the first function corresponding to the first code, the second function corresponding to the second code, and the mapping relationship between the preset code function and the test case by the acquisition unit, the first code is used to update the second code, and the first function has a new function compared to the second function; the use case determination unit determines the first test case corresponding to the first function and the second test case corresponding to the second function from the test case according to the mapping relationship; the first test unit uses the first test case to test the first code in the first preset test environment, and the first preset test environment corresponds to the first test case; the code update unit uses the first code to update the second code according to the first code after the test passes, to obtain the updated code; the second test unit uses the second test case to test the second code in the updated code in the second preset test environment, and the second preset test environment corresponds to the second test case; the code publishing unit is used to publish the updated code according to the second code in the updated code after the test passes.
[0163] Therefore, the embodiments of the present application can improve the efficiency of publishing codes.
[0164] Accordingly, an embodiment of the present application also provides an electronic device, which may be a terminal or a server, and the terminal may be a smart phone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA) and other terminal devices.
[0165] like Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 300 includes a processor 310 having one or more processing cores, a memory 320 having one or more computer-readable storage media, and a computer program stored in the memory 320 and executable on the processor. The processor 310 is electrically connected to the memory 320. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0166] The processor 310 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300. By running or loading software programs and / or modules stored in the memory 320 and calling data stored in the memory 320, it executes various functions of the electronic device 300 and processes data, thereby monitoring the electronic device 300 as a whole.
[0167] In the embodiment of the present application, the processor 310 in the electronic device 300 loads instructions corresponding to one or more application processes into the memory 320 according to the following steps, and the processor 310 runs the application stored in the memory 320 to implement various functions:
[0168] Obtaining a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, where the first code is used to update the second code, and the first function has a new function compared to the second function;
[0169] Determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship;
[0170] Testing the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case;
[0171] According to the first code after the test passes, the second code is updated using the first code to obtain an updated code;
[0172] Testing the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case;
[0173] Release the updated code based on the second code in the updated code after the test passes.
[0174] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0175] Optional, such as Figure 3 As shown, the electronic device 300 further includes: a touch screen 330, a radio frequency circuit 340, an audio circuit 350, an input unit 360, and a power supply 370. Among them, the processor 310 is electrically connected to the touch screen 330, the radio frequency circuit 340, the audio circuit 350, the input unit 360, and the power supply 370 respectively. Those skilled in the art will understand that Figure 3 The electronic device structure shown in the figure does not constitute a limitation to the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0176] The touch display screen 330 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 330 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect the user's touch operations on or near it (such as the user uses any suitable object or accessory such as a finger, a stylus, etc. on the touch panel or near the touch panel) and generate corresponding operation instructions, and the operation instructions execute the corresponding program. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 310, and can receive the command sent by the processor 310 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 310 to determine the type of touch event, and then the processor 310 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 330 to realize input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize input and output functions. That is, the touch display screen 330 can also be used as part of the input unit 360 to realize the input function.
[0177] The radio frequency circuit 340 may be used to transmit and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to transmit and receive signals with the network device or other electronic devices.
[0178] The audio circuit 350 can be used to provide an audio interface between the user and the electronic device through a speaker and microphone. The audio circuit 350 can convert the received audio data into an electrical signal and transmit it to the speaker, which then converts it into a sound signal for output. On the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 350 and converted into audio data. The audio data is then output to the processor 310 for processing, and then sent to another electronic device through the radio frequency circuit 340, or the audio data is output to the memory 320 for further processing. The audio circuit 350 may also include an earphone jack to provide communication between external headphones and the electronic device.
[0179] The input unit 360 can be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0180] The power supply 370 is used to supply power to the various components of the electronic device 300. Optionally, the power supply 370 can be logically connected to the processor 310 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 370 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0181] although Figure 3 Not shown in the figure, the electronic device 300 may further include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0182] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0183] As can be seen from the above, the electronic device provided in this embodiment can use the first function to determine the first test case for testing the first code, and the second function to determine the second test case for testing the second code. In this way, the first code can be tested in a first preset test environment through the first test case. After the first code test passes, the first code is aggregated to the second code through update to obtain the updated code. The second code in the updated code is tested in the second preset test environment through the second test case to determine that after the first code is added to the second code, the second code can also run normally, thereby releasing the updated code that can run normally, thereby realizing automated testing of the code and reducing the time spent on testing the code. As a result, the efficiency of releasing the code is improved.
[0184] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0185] To this end, an embodiment of the present application provides a computer-readable storage medium storing a plurality of computer programs, which can be loaded by a processor to execute the steps of any of the code publishing methods provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0186] Obtaining a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, where the first code is used to update the second code, and the first function has a new function compared to the second function;
[0187] Determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship;
[0188] Testing the first code using a first test case in a first preset test environment, where the first preset test environment corresponds to the first test case;
[0189] According to the first code after the test passes, the second code is updated using the first code to obtain an updated code;
[0190] Testing the second code in the updated code using a second test case in a second preset test environment, where the second preset test environment corresponds to the second test case;
[0191] Release the updated code based on the second code in the updated code after the test passes.
[0192] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0193] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0194] Since the computer program stored in the storage medium can execute the steps of any code publishing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any code publishing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0195] The above is a detailed introduction to a code publishing method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, based on the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A code publishing method, characterized in that: include: Obtaining a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, where the first code is used to update the second code, and the first function has a new function compared to the second function; Determining, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship; Performing mirroring processing on the first code to obtain a mirror code of the first code; Determine the upload status of the mirror code into the first preset test environment; If the upload status is that the mirror code is successfully uploaded, running the mirror code in the first preset test environment to obtain a first status of the mirror code running in the first preset test environment; If the upload status is that the mirror code was not successfully uploaded, performing problem detection processing on the first code to obtain a position to be corrected in the first code, re-mirroring the first code according to the position to be corrected to obtain a new mirror code, determining a new upload status of the new mirror code uploaded to the first preset test environment, and if the new upload status is that the new mirror code was successfully uploaded, running the new mirror code in the first preset test environment to obtain a first status of the new mirror code running in the first preset test environment; Testing the first code using the first test case in a first preset test environment according to the first state, where the first preset test environment corresponds to the first test case; According to the first code that passes the test, the second code is updated using the first code to obtain an updated code; Testing the second code in the updated code using the second test case in a second preset test environment, where the second preset test environment corresponds to the second test case; The updated code is released according to the second code in the updated code after the test passes.
2. The code publishing method according to claim 1, wherein: If the upload status indicates that the mirror code has not been uploaded successfully, performing problem detection processing on the first code to obtain a position to be corrected in the first code includes: If the upload status is that the mirror code has not been uploaded successfully, performing problem detection on the first code to obtain a position of the first code to be corrected; The step of re-mirroring the first code according to the position to be corrected to obtain a new mirrored code includes: When the position to be corrected does not exist, re-mirroring the first code to obtain a new mirrored code; When the position to be corrected exists, the position to be corrected is sent to the developer of the first code.
3. The code publishing method according to claim 1, wherein: Testing the first code using the first test case in a first preset test environment according to the first state includes: When the first state is normal, testing the first code using the first test case; When the first state is abnormal, performing problem detection processing on the first code to obtain a position to be corrected in the first code; When the position to be corrected exists, sending the position to be corrected to the developer of the first code; When the position to be corrected does not exist, re-running the first code in the first preset test environment to obtain a new first state; When the new first state is normal, the first code is retested using the first test case.
4. The code publishing method according to claim 1, wherein: The testing the second code in the updated code using the second test case in the second preset test environment includes: Running the update code in a second preset test environment to obtain a second state of the update code running in the second preset test environment; According to the second state, the second code in the updated code is tested using the second test case in the second preset test environment.
5. The code publishing method according to claim 4, wherein: Testing the second code in the updated code using the second test case in the second preset test environment according to the second state includes: When the second state is normal, testing the second code in the updated code using the second test case in the second preset test environment; When the second state is abnormal, performing problem detection processing on the first code in the updated code to obtain a position to be corrected in the first code; When the position to be corrected exists, sending the position to be corrected to the developer of the first code; When the position to be corrected does not exist, re-running the update code in the second preset test environment to obtain a new second state; When the new second state is normal, the second code in the updated code is tested using the second test case in the second preset test environment.
6. A code issuing device, characterized in that: include: an acquisition unit, configured to acquire a first code, a second code, a first function corresponding to the first code, a second function corresponding to the second code, and a mapping relationship between preset code functions and test cases, wherein the first code is used to update the second code, and the first function has a new function compared to the second function; a use case determining unit, configured to determine, from the test cases, a first test case corresponding to the first function and a second test case corresponding to the second function according to the mapping relationship; a first testing unit, configured to mirror the first code to obtain a mirror code of the first code, determine an upload status of the mirror code when uploaded to a first preset test environment, and if the upload status indicates successful upload of the mirror code, run the mirror code in the first preset test environment to obtain a first status of the mirror code when running in the first preset test environment; if the upload status indicates unsuccessful upload of the mirror code, perform problem detection on the first code to obtain a position to be corrected in the first code, re-mirror the first code based on the position to be corrected to obtain a new mirror code, determine a new upload status of the new mirror code when uploaded to the first preset test environment, and if the new upload status indicates successful upload of the new mirror code, run the new mirror code in the first preset test environment to obtain a first status of the new mirror code when running in the first preset test environment; and test the first code in the first preset test environment using the first test case based on the first status, wherein the first preset test environment corresponds to the first test case; a code updating unit, configured to update the second code with the first code after the test passes, to obtain an updated code; a second testing unit, configured to test the second code in the updated code using the second test case in a second preset test environment, where the second preset test environment corresponds to the second test case; A code publishing unit is used to publish the updated code according to the second code in the updated code after passing the test.
7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the code publishing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, which are suitable for loading by a processor to execute the steps in the code publishing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Test case generating method and device, computer equipment and storage medium
CN107992409A
Code testing method, apparatus and device
CN110928798A