Automatic testing method and device, storage medium and computer equipment
By extracting and analyzing the test requirements documents and user stories, determining the test functions and generating parameterized test cases, the problem of insufficient coverage of automated tests in the existing technology is solved, and the comprehensiveness and effectiveness of the test are improved.
Patent Information
- Application Number
- CN202411563192.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-18
AI Technical Summary
The existing automated test script generation methods cannot meet the test coverage requirements for key business scenarios, resulting in low effectiveness of software automation testing.
By extracting text information from the test requirements documents and user stories of the test application, identifying core and supplementary test functions, generating parameterized test cases, and executing these use cases to monitor test results.
It improves the coverage of test functions, ensures automatic generation of test cases, and enhances the comprehensiveness and effectiveness of automated testing.
Smart Images

Figure CN119473892A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to an automated testing method and device, a storage medium, and a computer device. Background Art
[0002] Currently, most software provides UI (User Interface) functions, which requires testing the software's UI functions to ensure that the software can be put into use. In order to improve the testing efficiency of software UI functions and reduce testing costs, testing software UI functions based on automated testing has become a new testing method.
[0003] The current automated test script development method usually finds the corresponding UI controls and all upper-level controls of the UI controls based on the test steps in the test case, encodes the UI controls and all upper-level controls one by one, and finally obtains the test script. However, when faced with application software containing complex user interactions and asynchronous operations, such as financial leasing in the financial field and Internet hospitals in the medical field, the test scripts generated by the current method cannot meet the test coverage requirements for key business scenarios, greatly reducing the effectiveness of software automated testing. Summary of the invention
[0004] In view of this, the present invention provides an automated testing method and apparatus, a storage medium, and a computer device, the main purpose of which is to solve the problem that the test scripts generated by the existing script generation method cannot meet the test coverage requirements for key business scenarios, resulting in low effectiveness of software automated testing.
[0005] According to one aspect of the present invention, there is provided an automated testing method, comprising:
[0006] Extracting text information from the test requirement document and user story of the application to be tested to obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension;
[0007] Determine core test functions according to the test requirement key information, and determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested;
[0008] For each test function, identify a target test case template matching the test function from a test case library, and generate at least one parameterized test case for the test function according to the functional attributes of the test function and the target test case template;
[0009] Execute the parameterized test cases of each of the test functions, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
[0010] Furthermore, in the case where the application to be tested is an online product, the parameterized test case for executing each of the test functions includes:
[0011] Performing user behavior analysis based on the user operation behavior data of the application to be tested to obtain user operation tendency data of different test functions, and using the test error ratio in the historical test results of the different test functions as a correction coefficient to correct the user operation tendency data to obtain corrected user operation tendency data;
[0012] For each of the test functions, identifying an attention level that matches the corrected user operation tendency data from a test attention level mapping relationship list;
[0013] Retrieving test execution information matching the modified attention level to obtain test execution information of each of the test functions, wherein the test execution information includes at least one of a test case execution priority, a test case execution frequency, and a test case execution time;
[0014] The parameterized test cases of each of the test functions are executed according to the test execution information.
[0015] Furthermore, before executing the parameterized test cases of each test function, the method further includes:
[0016] Detecting an environment type of an expected execution environment of the parameterized test case, wherein the environment type is divided based on at least one dimension of a browser dimension, an operating system dimension, and a device dimension;
[0017] Retrieving test case difference information matching the environment type from a test case library;
[0018] The test case difference information is updated into the parameterized test case to obtain a parameterized test case matching the expected execution environment.
[0019] Furthermore, the method further comprises:
[0020] In response to source code update of the application to be tested, comparing updated objects of the application to be tested;
[0021] Retrieving at least one candidate execution strategy matching the update object, wherein the candidate execution strategy includes a pre-built element location strategy, an interface matching strategy, and a parameter adjustment strategy;
[0022] Verify the validity of the candidate execution strategy, and update any of the candidate execution strategies that pass the verification into the test case template corresponding to the update object.
[0023] Further, determining the core test function according to the test requirement key information, and determining the supplementary test function according to the core test function and the user story key information to obtain the global test function of the application to be tested includes:
[0024] Match the key information of the test requirements with the preset test function items to determine the core test functions;
[0025] The user-dimensional test function is extracted from the key information of the user story through the big model to obtain supplementary test functions;
[0026] An integration process is performed based on the core test function and the supplementary test function to obtain a global test function of the application to be tested.
[0027] Furthermore, the functional attributes include multi-role attributes and multi-parameter attributes, and the step of generating at least one parameterized test case of the test function according to the functional attributes of the test function and the target test case template includes:
[0028] In the case where the functional attribute of the test function is a multi-role attribute, corresponding parameterized test cases are generated for different role categories, so as to obtain parameterized test cases in which the test function matches each role category;
[0029] In the case where the functional attribute of the test function is a multi-parameter attribute, multiple parameter combinations are determined according to a preset combination relationship, and corresponding parameterized test cases are generated for each parameter combination.
[0030] Furthermore, after monitoring the execution process of the parameterized test case and obtaining the test result of the application to be tested, the method further includes:
[0031] In the case where the test result includes an abnormal test item, determining the test abnormal item according to the document object model state and the test case execution log in the test result;
[0032] Retrieve the associated repair suggestions and / or code optimization strategies that match the test exception items, and generate a test report for the application to be tested based on the document object model status and test case execution log in the test results, as well as the associated repair suggestions and / or the code optimization strategies.
[0033] According to another aspect of the present invention, there is provided an automated testing device, comprising:
[0034] An extraction module is used to extract text information from the test requirement document and user story of the application to be tested, and obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension;
[0035] A determination module, configured to determine core test functions according to the test requirement key information, and to determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested;
[0036] A generating module, configured to identify, for each test function, a target test case template matching the test function from a test case library, and generate at least one parameterized test case for the test function according to a functional attribute of the test function and the target test case template;
[0037] The execution module is used to execute the parameterized test cases of each test function, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
[0038] Furthermore, in the case where the application to be tested is an online product, the execution module includes:
[0039] An analysis unit, configured to perform user behavior analysis based on the user operation behavior data of the application to be tested, obtain user operation tendency data of different test functions, and use the test error ratio in the historical test results of the different test functions as a correction coefficient to correct the user operation tendency data to obtain corrected user operation tendency data;
[0040] A correction unit, configured to identify, for each of the test functions, an attention level that matches the corrected user operation tendency data from a test attention level mapping relationship list;
[0041] A retrieving unit, configured to retrieve test execution information matching the modified attention level, and obtain test execution information of each of the test functions, wherein the test execution information includes at least one of a test case execution priority, a test case execution frequency, and a test case execution time;
[0042] An execution unit is used to execute the parameterized test cases of each test function according to the test execution information.
[0043] Furthermore, the device also includes:
[0044] A detection module, used to detect the environment type of the expected execution environment of the parameterized test case, wherein the environment type is divided based on at least one dimension of a browser dimension, an operating system dimension, and a device dimension;
[0045] A first retrieving module, used to retrieve test case difference information matching the environment type from a test case library;
[0046] An updating module is used to update the test case difference information into the parameterized test case to obtain a parameterized test case that matches the expected execution environment.
[0047] Furthermore, the device also includes:
[0048] A comparison module, configured to compare and identify an update object of the application to be tested in response to a source code update of the application to be tested;
[0049] A second calling module, used to call at least one alternative execution strategy matching the update object, wherein the alternative execution strategy includes a pre-built element location strategy, an interface matching strategy, and a parameter adjustment strategy;
[0050] The verification module is used to verify the validity of the alternative execution strategy and update any of the alternative execution strategies that pass the verification into the test case template corresponding to the update object.
[0051] Furthermore, the determination module includes:
[0052] A matching unit is used to match the key information of the test requirements with the preset test function items to determine the core test functions;
[0053] An extraction unit, used to extract test functions of the user dimension from the key information of the user story through a large model to obtain supplementary test functions;
[0054] The comparison unit is used to compare and remove duplications based on the core test function and the supplementary test function to obtain the global test function of the application to be tested.
[0055] Furthermore, the generation module includes:
[0056] A generating unit, for generating corresponding parameterized test cases for different role categories respectively, when the functional attribute of the test function is a multi-role attribute, to obtain parameterized test cases for which the test function matches each role category;
[0057] The determination unit is used to determine multiple parameter combinations according to a preset combination relationship when the functional attribute of the test function is a multi-parameter attribute, and generate corresponding parameterized test cases for each parameter combination.
[0058] Furthermore, the determination module is further used to determine the test abnormality item according to the document object model state and the test case execution log in the test result when the test result includes the abnormal test item;
[0059] The generation module is also used to retrieve the associated repair suggestions and / or code optimization strategies that match the test exception items, and generate a test report for the application to be tested based on the document object model status and test case execution log in the test results, as well as the associated repair suggestions and / or the code optimization strategies.
[0060] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the above-mentioned automated testing method.
[0061] According to another aspect of the present invention, there is provided a computer device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0062] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the above-mentioned automatic testing method.
[0063] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0064] The present invention provides an automated testing method and device, a storage medium, and a computer device. Compared with the prior art, the embodiments of the present invention extract text information from the test requirement document and user story of the application to be tested to obtain key information of the test requirement and key information of the user story; determine the core test function according to the key information of the test requirement, and determine the supplementary test function according to the core test function and the key information of the user story to obtain the global test function of the application to be tested; for each test function, identify the target test case template matching the test function from the test case library, and generate at least one parameterized test case of the test function according to the functional attributes of the test function and the target test case template; execute the parameterized test cases of each test function, and monitor the execution process of the parameterized test cases to obtain the test results of the application to be tested. By determining the test function according to the key information of the test requirement and the key information of the user story, and generating multiple parameterized test cases according to the functional attributes, the coverage of the test function is greatly improved, and at the same time, the automatic generation of the test case is ensured, thereby greatly improving the comprehensiveness and effectiveness of the automated test.
[0065] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0067] Figure 1 A flow chart of an automated testing method provided by an embodiment of the present invention is shown;
[0068] Figure 2 Another flow chart of an automated testing method provided by an embodiment of the present invention is shown;
[0069] Figure 3 A block diagram of an automated testing device provided by an embodiment of the present invention is shown;
[0070] Figure 4 A schematic structural diagram of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0071] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0072] The test scripts generated by the existing script generation method cannot meet the test coverage requirements of key business scenarios, resulting in the problem of low effectiveness of software automated testing. Figure 1 As shown, the method includes:
[0073] 101. Extract text information from the test requirement documents and user stories of the application to be tested to obtain key information of the test requirements and key information of the user stories.
[0074] In an embodiment of the present invention, the application to be tested can be an application in the development stage or a product that has been launched. The user story includes description information of each function in the application to be tested from the user dimension. The description information of the user story may include: the role that uses this function (user, administrator, etc.), the purpose that the user needs to achieve by using this function (complete a task, obtain certain information, etc.), and why this function is important (improve efficiency, reduce errors). For example, "As a user, I want to be able to log in to my account so that I can access my personal information" and "As an administrator, I want to be able to view the activity records of all users in order to monitor the use of the system". The test requirements document is a document that describes the test requirements from the software development dimension. The test requirements document and user stories can be uploaded by developers or test requirement proposers through the test system platform.
[0075] In order to determine the test functions, the key information in the test requirement documents and user stories is extracted based on machine learning and natural language processing technology to obtain the test requirement key information corresponding to the test requirement documents and the user story key information corresponding to the user stories. Specifically, the named entity recognition method can be used to extract the key information in the test requirement documents and user stories, such as functions, user roles, test objectives, etc. Then, the relationship between the key information is extracted, such as the relationship between user permissions and the corresponding executable functions.
[0076] 102. Determine core test functions according to the test requirement key information, and determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested.
[0077] In an embodiment of the present invention, a user story is a description of the application software to be tested based on the user's perspective, and can extract the permission control of users of different roles, such as the permission control of administrators and ordinary users. User stories contain content that expresses emotions and needs. By analyzing these contents, the usage tendencies and demand tendencies of users of different roles for different functions in the application can be extracted, thereby supplementing and refining the test functions. The test requirement document contains multi-level business logic, especially the test requirement document for large-scale enterprise-level applications, such as e-commerce platforms, financial technology applications, software as a service platforms, mobile applications, Internet of Things systems, medical systems, and other application products. The logical hierarchy of the test requirement document is more complex. The key information provided by the user story from the user's perspective also has a certain supplementary effect on the hierarchical understanding of the business logic. Thereby ensuring that the functions to be tested of the application to be tested are fully extracted.
[0078] 103. For each test function, identify a target test case template matching the test function from a test case library, and generate at least one parameterized test case of the test function according to a functional attribute of the test function and the target test case template.
[0079] In an embodiment of the present invention, the test case library includes test case templates corresponding to different functions that are constructed based on historical test cases and predefined test templates. For example, a login function test template in user operation mode, a form submission login function test template, and a page view login function test template. After determining the global test function, the functional description of each test function is matched with the test case template in the test case library, and the test case template matching the functional description is determined as the target test case template. After the description information of the test function is parameterized, the corresponding parameters in the target test case template are updated to automatically generate parameterized test cases. Among them, the parameterized test case of a test function is not limited to one, and multiple test cases need to be generated for test functions based on certain functional attributes. For example, multiple login test cases are generated for different combinations of user names and passwords. For another example, for different user roles, such as administrators and ordinary users' authority control, test cases related to different permissions can be automatically generated.
[0080] 104. Execute the parameterized test cases of the test functions, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
[0081] In an embodiment of the present invention, after a parameterized test case is automatically generated, the parameterized test case is automatically run, and the test process of the parameterized test case on the test function is recorded to obtain the test result. The test result includes the test pass rate, and the specific error details in the test process, such as the incorrect user name input without correct prompt, and a DOM snapshot and a detailed log are attached. Since the parameterized test case is extracted based on the user story and the test requirement document, and more test cases are generated according to the characteristics of different functional attributes, it is possible to achieve comprehensive extraction and comprehensive testing of the test function, and on the basis of automated testing, greatly improve the test coverage of the application to be tested, thereby improving the comprehensiveness and effectiveness of automated testing.
[0082] In an embodiment of the present invention, for further explanation and limitation, as Figure 2 As shown, in the step, when the application to be tested is an online product, the parameterized test case of executing each test function includes:
[0083] 201. Perform user behavior analysis based on the user operation behavior data of the application to be tested to obtain user operation tendency data of different test functions, and use the proportion of test errors in the historical test results of the different test functions as a correction coefficient to correct the user operation tendency data to obtain corrected user operation tendency data.
[0084] 202. For each of the test functions, identify an attention level that matches the corrected user operation tendency data from a test attention level mapping relationship list.
[0085] 203. Retrieve test execution information matching the corrected attention level to obtain test execution information of each of the test functions.
[0086] 204. Execute the parameterized test cases of each of the test functions according to the test execution information.
[0087] In an embodiment of the present invention, the test execution information is used to guide the order and frequency of test execution of different test functions, including at least one of the test case execution priority, the test case execution frequency and the test case execution time. Different test functions are tested according to the corresponding test execution information. In the scenario where the application to be tested is an online product, the test coverage may not be full range, but the coverage of the function is adaptively adjusted according to the usage of each function in the application and user feedback. In order to achieve adaptive adjustment, the user operation behavior data after the application is launched or the user operation behavior data within a historical period of time can be obtained. And the user operation behavior data is analyzed to determine the user operation tendency data. The user operation tendency data includes the frequency of use of different test functions, the number of user feedback received, the number of boundary errors in user operations, etc.
[0088] After determining the user operation tendency data, it is also necessary to correct the user operation tendency data based on the test error ratio in the historical test results as a correction coefficient. The quotient of the user operation tendency data and the test error ratio is used as the corrected attention level. Among them, the test error ratio is a number less than 1. The higher the error ratio, the more the user operation tendency data is improved. Then, the attention level matching the corrected user operation tendency data is identified from the test attention level mapping relationship list, wherein the test attention level mapping relationship list includes the mapping relationship between different corrected user operation tendency numerical ranges and their corresponding attention levels. The larger the user operation tendency numerical range, the higher the attention represented by its corresponding attention level. For example, the system detects that the shopping cart function is used less frequently, and no new problems have been found in the recent tests; while the order generation function is used more frequently, and boundary errors often occur after the update, then the attention level corresponding to the shopping cart function is lower than the attention level of the order generation function. Different attention levels correspond to different test execution information. The higher the attention level, the higher the test priority in the corresponding test execution information and the greater the test execution frequency. This allows the test coverage to be adjusted based on the user's operating behavior and historical test data.
[0089] In one embodiment of the present invention, for further explanation and limitation, before executing the parameterized test cases of each test function, the method further includes:
[0090] Detecting an environment type of an expected execution environment of the parameterized test case;
[0091] Retrieving test case difference information matching the environment type from a test case library;
[0092] The test case difference information is updated into the parameterized test case to obtain a parameterized test case matching the expected execution environment.
[0093] In the embodiment of the present invention, the environment type is the type of the operating environment of the application to be tested, that is, the expected execution environment of the parameterized test case. It is divided based on at least one of the browser dimension, the operating system dimension, and the device dimension. There are many common contents in different browsers, operating systems, and terminal devices, and of course there are certain specific differences. Test case difference information for different environment types is pre-constructed in the test case library to solve the specificity problem of different test environments. Among them, the test case difference information includes the difference information of the user interface and interaction, the difference information of the system architecture and function, the difference information of the security mechanism, the difference information of the resolution and the screen size, etc. For example, the display ratio of the tablet computer and the mobile phone is different, and the corresponding display data can be calculated based on the preset function according to the display ratio of different devices to realize the display across devices. For another example, the call protocol of the URL Schema needs to be tested in the iOS system, but this test is not required in the Android system, then the test case difference information of the iOS system includes the call protocol test item of the URLSchema. By pre-constructing the test case difference information, the adaptive adjustment of the test case can be realized, thereby realizing the cross-environment test.
[0094] In an embodiment of the present invention, for further explanation and limitation, the method further includes:
[0095] In response to source code update of the application to be tested, comparing updated objects of the application to be tested;
[0096] Retrieving at least one alternative execution strategy matching the update object;
[0097] Verify the validity of the candidate execution strategy, and update any of the candidate execution strategies that pass the verification into the test case template corresponding to the update object.
[0098] In an embodiment of the present invention, in a scenario where an application to be tested is updated, in order to adapt to the update of the code, different elements, different interfaces and different parameters are pre-constructed to provide alternative execution strategies. That is, the alternative execution strategy includes a pre-constructed element positioning strategy, an interface matching strategy and a parameter adjustment strategy. For example, the element positioning strategy may include text content positioning, class name positioning, page structure positioning, etc. When an object is updated, the same function as before the update can be achieved according to the alternative execution strategy corresponding to the updated object. Specifically, the alternative execution strategy of the updated object can be tested to determine the validity of the alternative execution strategy. If the verification is passed, the alternative execution strategy is updated to the test case template corresponding to the updated object to replace the original execution strategy. For example, in an update of a front-end interface, the ID of the login button changes from #loginBtn to #submitLogin. The system detects that the updated object is the login button by comparing the DOM (Document Object Model) structure of the page. It then calls strategies such as positioning the button's text content and positioning the button's class name to match the login button to locate the login button. If positioning the button's text content is correct and the click operation can be performed, it is confirmed that the text content positioning method is valid. The content of locating the login button based on the ID in the corresponding test case template is updated to locating the login button based on the text content, so that this positioning strategy can be applied for positioning in subsequent test cases.
[0099] In one embodiment of the present invention, for further explanation and limitation, determining the core test function based on the test requirement key information, and determining the supplementary test function based on the core test function and the user story key information to obtain the global test function of the application to be tested includes:
[0100] Match the key information of the test requirements with the preset test function items to determine the core test functions;
[0101] The user-dimensional test function is extracted from the key information of the user story through the big model to obtain supplementary test functions;
[0102] An integration process is performed based on the core test function and the supplementary test function to obtain a global test function of the application to be tested.
[0103] In an embodiment of the present invention, core test functions and supplementary test functions are functions that may overlap. When functions overlap, the description information of the test functions is compared, and the two description information is integrated to obtain more comprehensive description information, so as to provide more parameterized information in the process of parameterizing the description information, thereby improving the comprehensiveness of the test points and test objectives in the test functions. The functions after the integration of the overlapping functions are integrated with the remaining non-overlapping functions to obtain a complete global test function. The preset test function items are constructed based on historical testing experience and have certain subjective limitations. The user-dimensional test function extraction of the key information of the user story based on the big model can expand and refine the test function in combination with big data and user perspectives, improve the comprehensive coverage of the test function, and thus improve the effectiveness of the test.
[0104] In one embodiment of the present invention, for further explanation and limitation, generating at least one parameterized test case of the test function according to the functional attribute of the test function and the target test case template includes:
[0105] In the case where the functional attribute of the test function is a multi-role attribute, corresponding parameterized test cases are generated for different role categories, so as to obtain parameterized test cases in which the test function matches each role category;
[0106] In the case where the functional attribute of the test function is a multi-parameter attribute, multiple parameter combinations are determined according to a preset combination relationship, and corresponding parameterized test cases are generated for each parameter combination.
[0107] In an embodiment of the present invention, the functional attributes include multi-role attributes and multi-parameter attributes. Multi-role attributes, that is, the test function provides different control permissions for different user roles. For example, a test case is generated for administrator permissions, and another test case is generated for ordinary users. Multi-parameter attributes, that is, the test function also includes the matching relationship of multiple parameters. For example, the order generation function also includes multiple parameters such as order status, payment method, inventory status, etc., then it is necessary to combine different order statuses, different payment methods and different inventory statuses to obtain multiple parameter combinations, and generate corresponding parameterized test cases for each parameter combination. For another example, under the user login function, multiple parameter combinations are generated for different user name and password combinations, and corresponding parameterized test cases are generated for different parameter combinations.
[0108] In one embodiment of the present invention, for further explanation and limitation, after monitoring the execution process of the parameterized test case and obtaining the test result of the application to be tested, the method further includes:
[0109] In the case where the test result includes an abnormal test item, determining the test abnormal item according to the document object model state and the test case execution log in the test result;
[0110] Retrieve the associated repair suggestions and / or code optimization strategies that match the test exception items, and generate a test report for the application to be tested based on the document object model status and test case execution log in the test results, as well as the associated repair suggestions and / or the code optimization strategies.
[0111] In an embodiment of the present invention, in order to provide timely feedback to the tester after the test case is executed, the execution process of each parameterized test case is monitored and the test results are collected. In the case where the test result does not include abnormal test items, a test report of the test passing is directly generated. In the case where the test result includes abnormal test items, the test abnormal items are determined according to the document object model state (DOM snapshot) and the test case execution log. And at least one of the associated repair suggestions and code optimization strategies corresponding to the test abnormal items is matched from the pre-built associated repair suggestions and code optimization strategies to provide developers with repair suggestions in the test report, thereby improving the efficiency of modifying test problems.
[0112] The present invention provides an automated testing method. Compared with the prior art, the embodiment of the present invention extracts text information from the test requirement document and user story of the application to be tested to obtain key information of the test requirement and key information of the user story; determines the core test function according to the key information of the test requirement, and determines the supplementary test function according to the core test function and the key information of the user story, so as to obtain the global test function of the application to be tested; for each test function, identifies the target test case template matching the test function from the test case library, and generates at least one parameterized test case of the test function according to the functional attributes of the test function and the target test case template; executes the parameterized test case of each test function, and monitors the execution process of the parameterized test case to obtain the test result of the application to be tested. By determining the test function according to the key information of the test requirement and the key information of the user story, and generating multiple parameterized test cases according to the functional attributes, the coverage rate of the test function is greatly improved, and at the same time, the automatic generation of the test case is ensured, thereby greatly improving the comprehensiveness and effectiveness of the automated test.
[0113] Furthermore, as a response to the above Figure 1 To implement the method shown in the figure, the embodiment of the present invention provides an automated testing device, such as Figure 3 As shown, the device comprises:
[0114] An extraction module 31 is used to extract text information from the test requirement document and user story of the application to be tested, and obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension;
[0115] A determination module 32, configured to determine a core test function according to the test requirement key information, and to determine a supplementary test function according to the core test function and the user story key information, so as to obtain a global test function of the application to be tested;
[0116] A generating module 33, for identifying, for each test function, a target test case template matching the test function from a test case library, and generating at least one parameterized test case for the test function according to the functional attributes of the test function and the target test case template;
[0117] The execution module 34 is used to execute the parameterized test cases of each of the test functions, and monitor the execution process of the parameterized test cases to obtain the test results of the application to be tested.
[0118] Furthermore, in the case where the application to be tested is an online product, the execution module 34 includes:
[0119] An analysis unit, configured to perform user behavior analysis based on the user operation behavior data of the application to be tested, obtain user operation tendency data of different test functions, and use the test error ratio in the historical test results of the different test functions as a correction coefficient to correct the user operation tendency data to obtain corrected user operation tendency data;
[0120] A correction unit, configured to identify, for each of the test functions, an attention level that matches the corrected user operation tendency data from a test attention level mapping relationship list;
[0121] A retrieving unit, configured to retrieve test execution information matching the modified attention level, and obtain test execution information of each of the test functions, wherein the test execution information includes at least one of a test case execution priority, a test case execution frequency, and a test case execution time;
[0122] An execution unit is used to execute the parameterized test cases of each test function according to the test execution information.
[0123] Furthermore, the device also includes:
[0124] A detection module, used to detect the environment type of the expected execution environment of the parameterized test case, wherein the environment type is divided based on at least one dimension of a browser dimension, an operating system dimension, and a device dimension;
[0125] A first retrieving module, used to retrieve test case difference information matching the environment type from a test case library;
[0126] An updating module is used to update the test case difference information into the parameterized test case to obtain a parameterized test case that matches the expected execution environment.
[0127] Furthermore, the device also includes:
[0128] A comparison module, configured to compare and identify an update object of the application to be tested in response to a source code update of the application to be tested;
[0129] A second calling module, used to call at least one alternative execution strategy matching the update object, wherein the alternative execution strategy includes a pre-built element location strategy, an interface matching strategy, and a parameter adjustment strategy;
[0130] The verification module is used to verify the validity of the alternative execution strategy and update any of the alternative execution strategies that pass the verification into the test case template corresponding to the update object.
[0131] Furthermore, the determination module 32 includes:
[0132] A matching unit is used to match the key information of the test requirements with the preset test function items to determine the core test functions;
[0133] An extraction unit, used for extracting test functions of the user dimension from the key information of the user story through a large model to obtain supplementary test functions;
[0134] The comparison unit is used to compare and remove duplications based on the core test function and the supplementary test function to obtain the global test function of the application to be tested.
[0135] Furthermore, the generating module 33 comprises:
[0136] A generating unit, for generating corresponding parameterized test cases for different role categories respectively, when the functional attribute of the test function is a multi-role attribute, to obtain parameterized test cases for which the test function matches each role category;
[0137] The determination unit is used to determine multiple parameter combinations according to a preset combination relationship when the functional attribute of the test function is a multi-parameter attribute, and generate corresponding parameterized test cases for each parameter combination.
[0138] Furthermore, the determination module 32 is further configured to determine the test abnormality item according to the document object model state and the test case execution log in the test result when the test result includes the abnormal test item;
[0139] The generation module 33 is also used to retrieve the associated repair suggestions and / or code optimization strategies that match the test exception items, and generate a test report for the application to be tested based on the document object model status and test case execution log in the test results, as well as the associated repair suggestions and / or the code optimization strategies.
[0140] The present invention provides an automated testing device. Compared with the prior art, the embodiment of the present invention extracts text information from the test requirement document and user story of the application to be tested, obtains key information of the test requirement and key information of the user story; determines the core test function according to the key information of the test requirement, and determines the supplementary test function according to the core test function and the key information of the user story, so as to obtain the global test function of the application to be tested; for each test function, identifies the target test case template matching the test function from the test case library, and generates at least one parameterized test case of the test function according to the functional attributes of the test function and the target test case template; executes the parameterized test case of each test function, and monitors the execution process of the parameterized test case to obtain the test result of the application to be tested. By determining the test function according to the key information of the test requirement and the key information of the user story, and generating multiple parameterized test cases according to the functional attributes, the coverage rate of the test function is greatly improved, and at the same time, the automatic generation of the test case is ensured, thereby greatly improving the comprehensiveness and effectiveness of the automated test.
[0141] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the automated testing method in any of the above method embodiments.
[0142] Figure 4 A schematic diagram of the structure of a computer device provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the computer device.
[0143] like Figure 4As shown, the computer device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0144] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0145] The communication interface 404 is used to communicate with other devices such as clients or other servers.
[0146] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above-mentioned embodiment of the automated testing method.
[0147] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0148] The processor 402 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The computer device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0149] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0150] The program 410 may be specifically configured to enable the processor 402 to perform the following operations:
[0151] Extracting text information from the test requirement document and user story of the application to be tested to obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension;
[0152] Determine core test functions according to the test requirement key information, and determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested;
[0153] For each test function, identify a target test case template matching the test function from a test case library, and generate at least one parameterized test case for the test function according to the functional attributes of the test function and the target test case template;
[0154] Execute the parameterized test cases of each of the test functions, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
[0155] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0156] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An automated testing method, characterized in that: include: Extracting text information from the test requirement document and user story of the application to be tested to obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension; Determine core test functions according to the test requirement key information, and determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested; For each test function, identify a target test case template matching the test function from a test case library, and generate at least one parameterized test case for the test function according to the functional attributes of the test function and the target test case template; Execute the parameterized test cases of each of the test functions, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
2. The method according to claim 1, characterized in that In the case where the application to be tested is an online product, the parameterized test cases for executing each of the test functions include: Performing user behavior analysis based on the user operation behavior data of the application to be tested to obtain user operation tendency data of different test functions, and using the test error ratio in the historical test results of the different test functions as a correction coefficient to correct the user operation tendency data to obtain corrected user operation tendency data; For each of the test functions, identifying an attention level that matches the corrected user operation tendency data from a test attention level mapping relationship list; Retrieving test execution information matching the modified attention level to obtain test execution information of each of the test functions, wherein the test execution information includes at least one of a test case execution priority, a test case execution frequency, and a test case execution time; The parameterized test cases of each of the test functions are executed according to the test execution information.
3. The method according to claim 2, characterized in that Before executing the parameterized test cases of each of the test functions, the method further includes: Detecting an environment type of an expected execution environment of the parameterized test case, wherein the environment type is divided based on at least one dimension of a browser dimension, an operating system dimension, and a device dimension; Retrieving test case difference information matching the environment type from a test case library; The test case difference information is updated into the parameterized test case to obtain a parameterized test case matching the expected execution environment.
4. The method according to claim 1, characterized in that: The method further comprises: In response to source code update of the application to be tested, comparing updated objects of the application to be tested; Retrieving at least one candidate execution strategy matching the update object, wherein the candidate execution strategy includes a pre-built element location strategy, an interface matching strategy, and a parameter adjustment strategy; Verify the validity of the candidate execution strategy, and update any of the candidate execution strategies that pass the verification into the test case template corresponding to the update object.
5. The method according to claim 1, characterized in that Determining the core test function according to the test requirement key information, and determining the supplementary test function according to the core test function and the user story key information to obtain the global test function of the application to be tested, includes: Match the key information of the test requirements with the preset test function items to determine the core test functions; The user-dimensional test function is extracted from the key information of the user story through the big model to obtain supplementary test functions; An integration process is performed based on the core test function and the supplementary test function to obtain a global test function of the application to be tested.
6. The method according to claim 1, characterized in that The functional attributes include multi-role attributes and multi-parameter attributes, and generating at least one parameterized test case of the test function according to the functional attributes of the test function and the target test case template includes: In the case where the functional attribute of the test function is a multi-role attribute, corresponding parameterized test cases are generated for different role categories, so as to obtain parameterized test cases in which the test function matches each role category; In the case where the functional attribute of the test function is a multi-parameter attribute, multiple parameter combinations are determined according to a preset combination relationship, and corresponding parameterized test cases are generated for each parameter combination.
7. The method according to claim 1, characterized in that After monitoring the execution process of the parameterized test case and obtaining the test result of the application to be tested, the method further includes: In the case where the test result includes an abnormal test item, determining the test abnormal item according to the document object model state and the test case execution log in the test result; Retrieve the associated repair suggestions and / or code optimization strategies that match the test exception items, and generate a test report for the application to be tested based on the document object model status and test case execution log in the test results, as well as the associated repair suggestions and / or the code optimization strategies.
8. An automated testing device, characterized in that: include: An extraction module is used to extract text information from the test requirement document and user story of the application to be tested, and obtain key information of the test requirement and key information of the user story, wherein the user story includes description information of the application to be tested from the user dimension; A determination module, configured to determine core test functions according to the test requirement key information, and to determine supplementary test functions according to the core test functions and the user story key information, so as to obtain global test functions of the application to be tested; A generating module, configured to identify, for each test function, a target test case template matching the test function from a test case library, and generate at least one parameterized test case for the test function according to a functional attribute of the test function and the target test case template; The execution module is used to execute the parameterized test cases of each test function, monitor the execution process of the parameterized test cases, and obtain the test results of the application to be tested.
9. A storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute an operation corresponding to the automated testing method according to any one of claims 1 to 7.
10. A computer device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the automated testing method according to any one of claims 1 to 7.