Method and device for adaptively adjusting test case
By monitoring code changes and dynamically updating test cases, the problem of inaccurate and real-time test cases in the existing technology is solved, and the test cases are generated in a timely manner after the software changes are achieved, testing efficiency and accuracy are improved, and the occurrence of software is reduced after the software is released. Possibility of the problem.
Patent Information
- Application Number
- CN202411091305.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-15
AI Technical Summary
The existing technology has errors when generating test cases, and cannot respond to software changes in time, resulting in inaccurate test cases, low efficiency, poor accuracy and poor real-time performance.
By monitoring code changes, segmenting code change blocks, analyzing and parameterizing test case information, and dynamically updating test cases, ensuring the timeliness and effectiveness of test cases.
It realizes timely generation and execution of test cases after software changes, improves the timeliness and effectiveness of tests, reduces the risk of missed tests, improves the efficiency, accuracy and real-timeness of adaptive adjustment of test cases, and can cover more changes. In part, reduce the possibility of problems after the software is released.
Smart Images

Figure CN118964198A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer software and related technical fields, and in particular, to a method and apparatus for adaptively adjusting test cases. Background Art
[0002] A test case is a description of a test task for a specific software product, reflecting the test plan, method, technology and strategy. Its content includes test objectives, test environment, input data, test steps, expected results, test scripts, etc., and finally forms a document. A test case is a set of test inputs, execution conditions and expected results compiled for a specific goal, used to verify whether a specific software requirement is met.
[0003] The existing technology is not mature enough in dealing with software changes. The current technology may have errors, resulting in the generated test cases not being accurate enough or not covering all the changed parts. In addition, the existing technology may face real-time challenges and fail to respond to software changes in a timely manner, resulting in delayed or untimely test case generation. Low efficiency, poor accuracy and poor real-time performance are the problems existing in the current existing technology. Summary of the invention
[0004] The embodiments described in this article provide a method and device for adaptively adjusting test cases to solve the problems existing in the prior art.
[0005] According to a first aspect of the present disclosure, a method for adaptively adjusting a test case is provided, comprising: Monitor whether the code has changed; When a change in the code is detected, the module to which the changed code belongs is divided into a plurality of code change blocks, the code change blocks are parsed to obtain information of test cases corresponding to the code change blocks, and the information of the test cases is parameterized to obtain new parameters of the test cases; Obtaining new parameters of the test case and original parameters of the test case, and updating the test case corresponding to the code change block according to parameter changes; Execute the updated test case.
[0006] In some embodiments of the present disclosure, the code includes a front-end code and a back-end interface code.
[0007] In some embodiments of the present disclosure, the information of the test case includes object location information and / or interface path information, the new parameters of the test case include new parameters of the object location information and / or new parameters of the interface path information, and the original parameters of the test case include original parameters of the object location information and / or original parameters of the interface path information.
[0008] In some embodiments of the present disclosure, the step of parsing the code change block to obtain information of a test case corresponding to the code change block, and parameterizing the information of the test case to obtain new parameters of the test case includes: Parsing the code change block, and judging whether the code change block is a front-end module or a back-end interface module according to the module to which the code change block belongs; If the code change block is the front-end module, obtaining the object positioning information corresponding to the code change block, parameterizing the object positioning information to obtain new object positioning information parameters, and saving the new object positioning information parameters; If the code change block is the backend interface module, the interface path information corresponding to the code change block is obtained, and the interface path information is parameterized to obtain new interface path information parameters, and the new interface path information parameters are saved.
[0009] In some embodiments of the present disclosure, the step of obtaining the new parameters of the test case and the original parameters of the test case, and updating the test case corresponding to the code change block according to the parameter changes includes: If the code change block is the front-end module, then obtaining the new object positioning information parameters and the original object positioning information parameters, and comparing the new object positioning information parameters with the original object positioning information parameters, and if the two are different, updating the test case of the front-end module according to the new object positioning information parameters; If the code change block is the back-end interface module, the new parameters of the interface path information and the original parameters of the interface path information are obtained, and the new parameters of the interface path information are compared with the original parameters of the interface path information. If the two are different, the test case of the back-end interface module is updated according to the new parameters of the interface path information.
[0010] In some embodiments of the present disclosure, before the step of monitoring whether the code has changed, the method further includes: The test cases are generated for the codes of all modules using a code coverage method, specifically including: parsing the code of each module to obtain the information of the test case corresponding to the module code, parameterizing the test case information to obtain test case parameters, and keeping the test case parameters as the original parameters of the test case.
[0011] In some embodiments of the present disclosure, after the step of executing the updated test case, the method further includes: If successful, the new test case parameters will overwrite the original test case parameters.
[0012] According to a second aspect of the present disclosure, a device for adaptively adjusting a test case is provided, comprising: Change monitoring module, used to monitor whether the code has changed; A change analysis module is used to divide the module to which the changed code belongs into multiple code change blocks when the code change is detected, parse the code change blocks, obtain information of the test cases corresponding to the code change blocks, and parameterize the information of the test cases to obtain new parameters of the test cases; An adaptive adjustment module, used to obtain new parameters of the test case and original parameters of the test case, and update the test case corresponding to the code change block according to the parameter changes; An execution module is used to execute the updated test case.
[0013] According to a third aspect of the present disclosure, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the method in any one of the above embodiments are implemented.
[0014] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in any one of the above embodiments are implemented.
[0015] A method for adaptively adjusting test cases provided by an embodiment of the present disclosure comprises the following steps: first, monitoring whether the code has changed; then, when the code has changed, dividing the module to which the changed code belongs into a plurality of code change blocks, parsing the code change blocks, obtaining information of the test cases corresponding to the code change blocks, and parameterizing the information of the test cases to obtain new test case parameters; then, obtaining the new test case parameters and the original test case parameters, and updating the test cases corresponding to the code change blocks according to the parameter changes; finally, executing the updated test cases. The embodiment of the present application can generate and execute corresponding test cases in a timely manner after the software changes, ensure the timeliness and effectiveness of the test, reduce the risk of missed tests, and improve the efficiency, accuracy and real-time performance of adaptively adjusting test cases. By dynamically adjusting and updating the test cases according to the changes, the test efficiency is improved, and human resources and time costs are saved. The scope of influence of software changes can be accurately identified, and targeted test cases can be generated to improve test coverage and accuracy, and reduce invalid test cases. The method has adaptive capabilities, and can select appropriate test case generation strategies according to the characteristics and importance of software changes to adapt to different changes and requirements. It can cover more changing parts and comprehensively test the functions and performance of the software, improve the testing quality, and reduce the possibility of problems after the software is released.
[0016] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly described below. It should be noted that the drawings described below only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure, wherein: Figure 1 It is a flowchart of a method for adaptively adjusting test cases provided by an embodiment of the present disclosure; Figure 2 It is a structural schematic diagram of a device for adaptively adjusting test cases provided by an embodiment of the present disclosure; Figure 3 It is a flowchart of an embodiment of an adaptive adjustment test case provided by an embodiment of the present disclosure; Figure 4 It is a structural diagram of a computer device provided in an embodiment of the present disclosure.
[0018] In the drawings, reference numerals with the same last two digits correspond to the same elements. It should be noted that the elements in the drawings are schematic and not drawn to scale. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work also fall within the scope of protection of the present disclosure.
[0020] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase "embodiments" in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0021] The term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists, A and B exist at the same time, and B exists. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0022] Furthermore, in all embodiments of the present disclosure, terms such as “first” and “second” are used only to distinguish one component (or a part of a component) from another component (or another part of a component).
[0023] In the description of the present application, unless otherwise specified, "plurality" means more than two (including two), and similarly, "multiple groups" means more than two groups (including two).
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0025] In today's increasingly complex software development environment, code changes are very common. Every code modification may trigger a chain reaction, affecting the overall functionality and performance of the software. Therefore, how to effectively monitor code changes and adaptively adjust test cases accordingly to ensure software quality has become an indispensable part of the software development process.
[0026] Embodiment 1 Based on the problems existing in the existing technology, Figure 1 is a flow chart of a method for adaptively adjusting test cases provided by an embodiment of the present disclosure, such as Figure 1 As shown, the specific process of the method for adaptively adjusting test cases includes: Step S110, monitoring whether the code has changed; At every stage of the software development process, whether it is design, coding, testing or maintenance, the code may change. These changes may be caused by a variety of reasons such as new functional requirements, performance optimization, bug fixes, etc. In order to ensure the quality and stability of the software, it is necessary to monitor the changes in the code. This can be achieved through a version control system or a dedicated code monitoring tool. Once the code changes are detected, timely actions need to be taken to adapt to these changes.
[0027] In some embodiments, CI tools (such as Jenkins, CircleCI, etc.) are used to configure corresponding listeners and triggers to ensure that code changes can be detected immediately.
[0028] In some embodiments, a version control system (e.g., Python's Git library, SVN) or a scheduled task or code analysis tool (e.g., a static code analyzer) is used, or a Git hook or scheduled task provided by the version control system is used to detect the code repository in real time, and when new code is submitted or merged, the corresponding process is triggered. Python can be used to write scripts to implement monitoring, parsing, and adaptive adjustment functions. The GitPython library is used to interact with Git. Version control systems such as Git, SVN, etc. provide us with powerful code management functions. Through the version control system, every addition, deletion, modification, and other changes of the code can be tracked in real time, and the changes in the code can be quickly understood, providing a basis for subsequent test case adjustments. By comparing the differences between different versions, it is possible to accurately identify which parts have changed, thereby triggering the subsequent test case adjustment process.
[0029] In some embodiments, the information of the test case includes object location information and / or interface path information; The object location information in the test case is used to uniquely identify and locate specific objects or elements in the software under test during the software testing process. It is one of the key elements to ensure the accuracy and efficiency of the test. For example, object location information includes the following types: ID location, Name location, Class location, Xpath location, and CSS location.
[0030] In software testing, interface path information describes how to access and call a specific interface in the software system during a test case. Interface path information is the specific path from a starting point to a specific interface in the software system. This path includes network protocols, domain names, port numbers, interface names, and possible parameters.
[0031] In some embodiments, the code includes front-end code and back-end interface code.
[0032] In the process of front-end and back-end interaction, the front-end code is mainly responsible for sending requests to the back-end interface, interacting with the back-end interface by sending HTTP requests, allowing front-end developers to send GET, POST and other requests, and process the response data returned by the back-end. The back-end interface code is mainly responsible for receiving requests sent by the front-end, processing these requests, and returning the corresponding data. In some embodiments, before step S110, the method further includes: Step S100, using code coverage to generate test cases for the codes of all modules, specifically including: parsing the code of each module, obtaining the information of the test case corresponding to the module code, parameterizing the test case information to obtain the test case parameters of the module, keeping the test case parameters as the original test case parameters, and saving the test case parameters.
[0033] Specifically, the code of each module is parsed to obtain object location information and / or interface path information corresponding to the module code, and the object location information is parameterized to obtain the object location information parameters of the module, and the interface path information is parameterized to obtain the interface path information parameters of the module, and the object location information parameters are maintained as original object location information parameters, and the interface path information parameters are maintained as original interface path information parameters, and the original object location information parameters and the original interface path information parameters are saved.
[0034] Code coverage-based methods are often used in traditional software development projects, especially for large, complex systems or projects with high stability requirements. Code coverage testing can determine which parts of the code are covered by the test, help find uncovered parts, and increase code coverage by adding test cases. This method is suitable for scenarios that require quantifying test coverage and ensuring code quality and stability. Perform test coverage analysis to determine which parts of the code are affected by the change and identify the parts affected by the change.
[0035] In some embodiments, parameterization refers to separating key information such as object location information and path interface information from the test script and storing them in a configuration file, a database, or an environment variable. These parameters can be managed in a separate file or database and called by the automated test script. In this way, when this information changes, only the configuration file or database needs to be updated, without modifying and redeploying the entire test script.
[0036] In some embodiments, configuration information is stored in a format such as JSON or YAML, or the Page Object mode is used to manage test case parameters, including object location information parameters and path interface information parameters.
[0037] Step S120: when a change in the code is detected, the module to which the changed code belongs is divided into a plurality of code change blocks, the code change blocks are parsed to obtain information of test cases corresponding to the code change blocks, and the information of the test cases is parameterized to obtain new parameters of the test cases; Specifically, when code changes are detected, the scope and importance of the software changes need to be analyzed in order to find out the specific content and scope of the changes. This process involves in-depth analysis of the code, and by comparing code differences, etc., to determine which parts need to regenerate test cases, and which changes have the most significant impact on the system's functions and performance. Only through in-depth analysis can the test cases that need to be adjusted and regenerated be accurately determined.
[0038] Code changes may include adding new features, deleting features, modifying features, or optimizing performance. Different types of changes have different impacts on test cases, and it is necessary to develop corresponding test case generation strategies based on the type of changes.
[0039] The change may only involve a certain module, a certain function or a certain variable, etc. The specific scope of the change needs to be determined in order to accurately locate the test cases that need to be adjusted.
[0040] In some embodiments, code parsing and comparison techniques (such as static code analysis, code diff, etc.) are used to determine the specific content and location of code changes. These changes are analyzed to see whether they will affect existing test cases, especially those directly related to the changed code.
[0041] During the specific implementation process, the changes in the front-end code and the back-end interface code are analyzed. For example, a syntax analyzer is used to parse the grammatical structure of the code for the HTML language, or regular expressions or parsers are used to parse the changes in the code. The difflib text processing library in Python is used to perform various comparison and text processing tasks to identify the parts that affect the test cases.
[0042] Parsing the code change block, and judging whether the code change block is a front-end module or a back-end interface module according to the module to which the code change block belongs; If the code change block is the front-end module, obtaining the object positioning information corresponding to the code change block, parameterizing the object positioning information to obtain new object positioning information parameters, and saving the new object positioning information parameters; If the code change block is the backend interface module, the interface path information corresponding to the code change block is obtained, and the interface path information is parameterized to obtain new interface path information parameters, and the new interface path information parameters are saved.
[0043] In some embodiments, a configuration file or a centralized management system is used to define and store all object location information parameters and interface path parameters. These parameters can be managed in a separate file or database and called by an automated test script.
[0044] In some embodiments, the configuration information is stored in a format such as JSON or YAML, or the object location information is managed using the Page Object mode.
[0045] Step S130, obtaining the new parameters of the test case and the original parameters of the test case, and updating the test case corresponding to the code change block according to the parameter changes; Specifically, the new parameters of the test case and the original parameters of the test case are obtained, and the new parameters of the test case are compared with the original parameters of the test case. If the two are different, it is determined that the test case parameters have changed, and the test case corresponding to the code change block is updated according to the new test case parameters. The test case is adjusted according to the parameter changes to ensure that the updated test case can cover the latest changes in the code. The test case is the basis of software testing, which describes the test scenario, input, expected output and other information.
[0046] In some embodiments, if a function or class is modified, new test cases may need to be added to cover the new functionality or fix the problem.
[0047] In some embodiments, if a deprecated feature is removed, the test cases associated with it may need to be removed or updated.
[0048] After the adjustment, updating the generated test cases is an essential step. The updated test cases need to reflect the latest changes in the code and requirements to ensure the comprehensiveness and effectiveness of the test.
[0049] Automatically adjust related test cases according to changes, including object location information and interface path information of test cases. When the code changes, the related object location information and interface path information in the test cases need to be automatically updated. This can be achieved by parameterizing this information and dynamically loading it when the test is running.
[0050] The object location information and the interface path information are parameterized to obtain object location information parameters and interface path information parameters. When a parameter change is detected, an update operation is automatically triggered to automatically update the corresponding object location information parameters and interface path information parameters, that is, the result after code comparison is passed in.
[0051] In some embodiments, if the code change block is the front-end module, the new object positioning information parameters and the original object positioning information parameters are obtained, and the new object positioning information parameters are compared with the original object positioning information parameters. If the two are different, it is determined that the object positioning information parameters have changed, and the test case of the front-end module is updated according to the new object positioning information parameters; The new object positioning information parameters are obtained by parameterizing the object positioning information in step S120, and the original object positioning information parameters are obtained in step S100.
[0052] In some embodiments, if the code change block is the back-end interface module, the new parameters of the interface path information and the original parameters of the interface path information are obtained, and the new parameters of the interface path information are compared with the original parameters of the interface path information. If the two are different, it is determined that the interface path information parameters have changed, and the test case of the back-end interface module is updated according to the new parameters of the interface path information.
[0053] The new parameters of the interface path information are obtained by parameterizing the interface path information in step S120, and the original parameters of the interface path information are obtained in step S100.
[0054] The results of the code comparison (such as the location, type, and details of code changes) can be passed as input to the test case update and generation process. This information helps identify which test cases need to be updated or regenerated, and what specific changes should be considered when updating and generating test cases.
[0055] Through the above scheme, the object location information parameters and interface path information parameters can be automatically updated, thereby realizing the automatic update of test cases. This will ensure that the automated test is always tested against the latest code and interface, and improve the accuracy and reliability of the automated test.
[0056] Step S150: Execute the updated test case.
[0057] As a specific implementation method, in the Git version control system, you can set a hook script, such as a post-commit hook, to automatically trigger a specified operation after each commit, such as running automated tests. This method is directly tied to the code submission process to ensure that testing can be performed after each commit.
[0058] By executing the newly generated test cases, you can verify whether the latest changes in the code and requirements are properly covered and verified. This step is the final verification of software quality and stability, and the final test of the previous work. Only by executing the updated test cases can we ensure that the quality and stability of the software after the code and requirements have changed can be effectively verified and guaranteed.
[0059] In some embodiments, if it fails, step S220 is repeated. If it succeeds, the new test case parameters overwrite the original test case parameters stored in the configuration file, database or environment variables. Specifically, the new object location information parameters overwrite the original object location information parameters, and the new interface path information parameters overwrite.
[0060] The method for adaptively adjusting test cases provided by the embodiment of the present disclosure first monitors whether the code has changed; then, when the code is detected to have changed, the module to which the changed code belongs is divided into multiple code change blocks, the code change blocks are parsed, the information of the test cases corresponding to the code change blocks is obtained, and the information of the test cases is parameterized to obtain new test case parameters; then, the new test case parameters and the original test case parameters are obtained, and the test cases corresponding to the code change blocks are updated according to the parameter changes; finally, the updated test cases are executed. The whole process forms a closed-loop automated system for adaptively adjusting test cases, which can ensure that the test cases can be updated in time when the code changes, thereby maintaining the effectiveness and accuracy of the test, and realizing the improvement of the efficiency, accuracy and real-time performance of the adaptive test case adjustment system. The system can generate and execute corresponding test cases in time after the software changes, ensure the timeliness and effectiveness of the test, and reduce the risk of missed tests. By automatically generating test cases and dynamically adjusting the test strategy according to the changes, the test efficiency is improved, and human resources and time costs are saved. The scope of influence of software changes can be accurately identified, and targeted test cases can be generated to improve test coverage and accuracy, and reduce invalid test cases. It has the ability to adapt to different changes and requirements by selecting appropriate test case generation strategies based on the characteristics and importance of software changes. It can cover more changes and comprehensively test the functions and performance of the software, improve the quality of testing, and reduce the possibility of problems after software release.
[0061] Embodiment 2 Based on the above embodiments, the present disclosure also provides a device for adaptively adjusting test cases, such as Figure 2 As shown, the device for adaptively adjusting the test case includes: A change monitoring module 210 is used to monitor whether the code has changed; The change analysis module 220 is used to divide the module to which the changed code belongs into multiple code change blocks when the code change is detected, parse the code change blocks, obtain the information of the test case corresponding to the code change blocks, and parameterize the information of the test case to obtain new parameters of the test case; The adaptive adjustment module 230 is used to obtain the new parameters of the test case and the original parameters of the test case, and update the test case corresponding to the code change block according to the parameter changes; The execution module 240 is used to execute the updated test case.
[0062] In some embodiments, the code includes front-end code and back-end interface code.
[0063] In some embodiments, the information of the test case includes object location information and / or interface path information, the new parameters of the test case include new parameters of the object location information and / or new parameters of the interface path information, and the original parameters of the test case include original parameters of the object location information and / or original parameters of the interface path information.
[0064] In some embodiments, the change analysis module 220 is specifically used to parse the code change block and determine whether the code change block is a front-end module or a back-end interface module according to the module to which the code change block belongs; If the code change block is the front-end module, obtaining the object positioning information corresponding to the code change block, parameterizing the object positioning information to obtain new object positioning information parameters, and saving the new object positioning information parameters; If the code change block is the backend interface module, the interface path information corresponding to the code change block is obtained, and the interface path information is parameterized to obtain new interface path information parameters, and the new interface path information parameters are saved.
[0065] In some embodiments, if the code change block is the front-end module, the adaptive adjustment module 230 is specifically used to obtain the new object positioning information parameters and the original object positioning information parameters, compare the new object positioning information parameters with the original object positioning information parameters, and if the two are different, determine that the object positioning information parameters have changed, and update the test case of the front-end module according to the new object positioning information parameters; In some embodiments, if the code change block is the back-end interface module, the adaptive adjustment module 230 is specifically used to obtain the new parameters of the interface path information and the original parameters of the interface path information, and compare the new parameters of the interface path information with the original parameters of the interface path information. If the two are different, it is determined that the interface path information parameters have changed, and the test case of the back-end interface module is updated according to the new parameters of the interface path information.
[0066] In some embodiments, it also includes: The generation module 200 is used to generate test cases for the codes of all modules using a code coverage method, specifically including: parsing the code of each module, obtaining the information of the test case corresponding to the module code, parameterizing the test case information to obtain test case parameters, and maintaining the test case parameters as the original test case parameters.
[0067] In some embodiments, after the execution module 240 executes the updated test case, the step further includes: If successful, the generation module 200 will overwrite the original parameters of the test case with the new parameters of the test case.
[0068] The disclosed embodiment provides a device for adaptively adjusting test cases, which improves the efficiency, accuracy and real-time performance of the adaptive test case system. It can generate and execute corresponding test cases in time after the software changes, ensure the timeliness and effectiveness of the test, and reduce the risk of missed tests. By automatically generating test cases and dynamically adjusting the test strategy according to the changes, the test efficiency is improved, and human resources and time costs are saved. The scope of influence of software changes can be accurately identified, and targeted test cases can be generated to improve test coverage and accuracy, and reduce invalid test cases. It has adaptive capabilities and can select appropriate test case generation strategies according to the characteristics and importance of software changes to adapt to different changes and needs. It can cover more changes and comprehensively test the functions and performance of the software, improve the test quality, and reduce the possibility of problems after the software is released.
[0069] Embodiment 3 The following is a specific example for explanation. Figure 3 As shown, Step 1, the change detection module monitors whether the code has changed; Step 2: If a code change is detected, the change analysis module divides the module to which the changed code belongs into multiple code change blocks, uses a code scanning tool to parse the code change block, and determines whether the code change block is a front-end module or a back-end interface module according to the module to which the code change block belongs; if the code change block is the front-end module, execute steps 21 and 31; if the code change block is the back-end interface module, execute steps 22 and 32; Step 21, obtaining the object positioning information corresponding to the code change block, parameterizing the object positioning information to obtain new object positioning information parameters, and saving the new object positioning information parameters; Step 31, the adaptive adjustment module obtains the new parameters of the object positioning information and the original parameters of the object positioning information, and compares the new parameters of the object positioning information with the original parameters of the object positioning information. If the two are different, it is determined that the object positioning information parameters have changed, and the test case of the front-end module is updated according to the new parameters of the object positioning information.
[0070] Step 22, obtaining the interface path information corresponding to the code change block, parameterizing the interface path information to obtain new interface path information parameters, and saving the new interface path information parameters; Step 32, the adaptive adjustment module obtains the new parameters of the interface path information and the original parameters of the interface path information, and compares the new parameters of the interface path information with the original parameters of the interface path information. If the two are different, it is determined that the interface path information parameters have changed, and the test case of the back-end interface module is updated according to the new parameters of the interface path information.
[0071] Step 4: The execution module executes the updated test case.
[0072] If successful, the new test case parameters will overwrite the original test case parameters.
[0073] The present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0074] The computer device includes a memory 410 and a processor 420 that are connected to each other through a system bus. It should be noted that the figure only shows a computer device with components 410-420, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0075] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.
[0076] The memory 410 includes at least one type of readable storage medium, and the readable storage medium includes a non-volatile memory or a volatile memory, for example, a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc., and the RAM may include a static RAM or a dynamic RAM. In some embodiments, the memory 410 may be an internal storage unit of a computer device, for example, a hard disk or a memory of the computer device. In other embodiments, the memory 410 may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card or a flash card (FlashCard) equipped on the computer device. Of course, the memory 410 may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the memory 410 is generally used to store the operating system and various application software installed on the computer device, such as the program code of the above method. In addition, the memory 410 may also be used to temporarily store various data that have been output or are to be output.
[0077] The processor 420 is generally used to perform the overall operation of the computer device. In this embodiment, the memory 410 is used to store program codes or instructions, the program code includes computer operation instructions, and the processor 420 is used to execute the program codes or instructions stored in the memory 410 or process data, such as running the program code of the above method.
[0078] In this article, the bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus system can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0079] Another embodiment of the present application also provides a computer-readable medium, which may be a computer-readable signal medium or a computer-readable medium. A processor in a computer reads a computer-readable program code stored in the computer-readable medium, so that the processor can execute the functional actions specified in each step or a combination of steps in the above method; and generate a device for implementing the functional actions specified in each block or a combination of blocks in the block diagram.
[0080] Computer-readable media include but are not limited to electronic, magnetic, optical, electromagnetic, infrared memory or semiconductor systems, devices or apparatuses, or any appropriate combination of the foregoing, the memory is used to store program codes or instructions, the program codes include computer operating instructions, and the processor is used to execute the program codes or instructions of the above methods stored in the memory.
[0081] For the definitions of memory and processor, please refer to the description of the aforementioned computer device embodiment and will not be repeated here.
[0082] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0083] Each functional unit or module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0084] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0085] Unless the context clearly indicates otherwise, the singular form of the words used herein and in the appended claims includes the plural and vice versa. Thus, when referring to the singular, the plural form of the corresponding term is generally included. Similarly, the words "comprise" and "include" are to be interpreted as inclusive rather than exclusive. Likewise, the terms "include" and "or" should be interpreted as inclusive unless such interpretation is expressly prohibited herein. Where the term "example" is used herein, particularly when it is located after a group of terms, the "example" is merely exemplary and illustrative and should not be considered exclusive or comprehensive.
[0086] Further aspects and scopes of adaptability become apparent from the description provided herein. It should be understood that various aspects of the present application can be implemented individually or in combination with one or more other aspects. It should also be understood that the description and specific embodiments herein are intended for purposes of illustration only and are not intended to limit the scope of the present application.
[0087] Several embodiments of the present disclosure are described in detail above, but it is obvious that those skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the present disclosure. The protection scope of the present disclosure is defined by the attached claims.
Claims
1. A method for adaptively adjusting test cases, characterized in that: include: Monitor whether the code has changed; When a change in the code is detected, the module to which the changed code belongs is divided into a plurality of code change blocks, the code change blocks are parsed to obtain information of test cases corresponding to the code change blocks, and the information of the test cases is parameterized to obtain new parameters of the test cases; Obtaining new parameters of the test case and original parameters of the test case, and updating the test case corresponding to the code change block according to parameter changes; Execute the updated test case.
2. The method according to claim 1, characterized in that The code includes front-end code and back-end interface code.
3. The method according to claim 2, characterized in that The information of the test case includes object location information and / or interface path information, the new parameters of the test case include new parameters of the object location information and / or new parameters of the interface path information, and the original parameters of the test case include original parameters of the object location information and / or original parameters of the interface path information.
4. The method according to claim 3, characterized in that The step of parsing the code change block to obtain information of the test case corresponding to the code change block, and parameterizing the information of the test case to obtain new parameters of the test case includes: Parsing the code change block, and judging whether the code change block is a front-end module or a back-end interface module according to the module to which the code change block belongs; If the code change block is the front-end module, obtaining the object positioning information corresponding to the code change block, parameterizing the object positioning information to obtain new object positioning information parameters, and saving the new object positioning information parameters; If the code change block is the backend interface module, the interface path information corresponding to the code change block is obtained, and the interface path information is parameterized to obtain new interface path information parameters, and the new interface path information parameters are saved.
5. The method according to claim 4, characterized in that The step of obtaining the new parameters of the test case and the original parameters of the test case, and updating the test case corresponding to the code change block according to the parameter changes, includes: If the code change block is the front-end module, then obtaining the new object positioning information parameters and the original object positioning information parameters, and comparing the new object positioning information parameters with the original object positioning information parameters, and if the two are different, updating the test case of the front-end module according to the new object positioning information parameters; If the code change block is the back-end interface module, the new parameters of the interface path information and the original parameters of the interface path information are obtained, and the new parameters of the interface path information are compared with the original parameters of the interface path information. If the two are different, the test case of the back-end interface module is updated according to the new parameters of the interface path information.
6. The method according to claim 1, characterized in that Before the step of monitoring whether the code has changed, the method further includes: The test cases are generated for the codes of all modules using a code coverage method, specifically including: parsing the code of each module to obtain the information of the test case corresponding to the module code, parameterizing the information of the test case to obtain test case parameters, and keeping the test case parameters as the original parameters of the test case.
7. The method according to claim 6, characterized in that After the step of executing the updated test case, the method further includes: If successful, the new test case parameters will overwrite the original test case parameters.
8. A device for adaptively adjusting test cases, characterized in that: include: Change monitoring module, used to monitor whether the code has changed; A change analysis module is used to divide the module to which the changed code belongs into multiple code change blocks when the code change is detected, parse the code change blocks, obtain information of the test cases corresponding to the code change blocks, and parameterize the information of the test cases to obtain new parameters of the test cases; An adaptive adjustment module, used to obtain new parameters of the test case and original parameters of the test case, and update the test case corresponding to the code change block according to parameter changes; An execution module is used to execute the updated test case.
9. A computer device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Test case self-adaptive generation method and device based on dynamic scene perception
CN120179569A
Test case adaptive generation method and device based on dynamic scene perception
CN120179569B
Test case adaptive evolution method, electronic equipment and storage medium
CN120705073A
