Test case generation method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202010979788.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-17
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2040-09-17
AI Technical Summary
相关技术中针对不同的操作系统平台分别编写测试用例,需要工作人员耗费大量时间,工作效率低
[0029] The test case generation method, apparatus, storage medium, and electronic device provided in this application, based on existing basic test cases, determine the first operating system platform to which the target test cases to be generated should be applied. Then, the original control attribute information in the search control operation interface of the basic test cases is replaced with the target control attribute information applicable to the first operating system platform, thus obtaining the target test cases. This method eliminates the need for staff to write test cases separately for different operating system platforms, accelerating test case generation, saving time in generating test cases for different operating system platforms, and improving work efficiency.
Smart Images

Figure CN114201382B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a test case generation method, apparatus, storage medium, and electronic device. Background Technology
[0002] With the rapid development of computer technology and the internet, the iteration speed of application products is becoming increasingly fast, and mobile terminal applications are updated even more frequently. To ensure that released application products can function properly, they are usually tested before release. The application testing process typically includes testing the UI (User Interface) interaction logic.
[0003] Because different mobile devices may run on different operating system platforms, applications for the same product are typically developed separately for each platform. For example, when developing a game application, separate applications are developed for iOS and Android. Therefore, when testing the UI / UX logic of an application, it is necessary to write corresponding test cases for each operating system platform to test the application for that platform.
[0004] Because applications typically contain a large amount of UI interaction logic, many test cases need to be written. Related technologies often involve writing test cases separately for different operating system platforms, which requires a significant amount of time from staff and results in low work efficiency. Summary of the Invention
[0005] This application provides a test case generation method, apparatus, storage medium, and electronic device, which can save time in generating test cases and improve work efficiency.
[0006] To achieve the above objectives, the technical solution of this application embodiment is implemented as follows:
[0007] In a first aspect, embodiments of this application provide a test case generation method for generating test cases for various operating system platforms. When implementing the same interface function, test cases applicable to various operating system platforms use the same operation interface; the method includes:
[0008] Obtain basic test cases;
[0009] Determine the first operating system platform on which the target test cases to be generated should be applied;
[0010] The original control attribute information in the setting type operation interface of the basic test case is replaced with the target control attribute information applicable to the first operating system platform to obtain the target test case.
[0011] Secondly, embodiments of this application also provide a test case generation apparatus for generating test cases for various operating system platforms. When implementing the same interface function, test cases applicable to various operating system platforms use the same operation interface; the apparatus includes:
[0012] The test case acquisition unit is used to acquire basic test cases;
[0013] The platform determination unit is used to determine the first operating system platform to which the target test cases to be generated should be applied.
[0014] The information replacement unit is used to replace the original control attribute information in the setting type operation interface of the basic test case with the target control attribute information applicable to the first operating system platform, so as to obtain the target test case.
[0015] In one optional embodiment, the information replacement unit is specifically used for:
[0016] Based on the established correspondence between the control attribute information of various operating system platforms, the original control attribute information in the specified type operation interface is replaced with the target control attribute information corresponding to the original control attribute information.
[0017] In an optional embodiment, the information replacement unit is further configured to:
[0018] These tools are applicable to finding control properties and their values that characterize various controls from applications on different operating system platforms.
[0019] For each control, combine the control's properties and their values to form a key-value pair corresponding to that control;
[0020] Based on the control identifiers and corresponding key-value pairs of each control, a correspondence is established between control attribute information used to represent the same control in various operating system platforms.
[0021] In one optional embodiment, the basic test cases are test cases applicable to a second operating system platform; the original control attribute information includes key-value pairs corresponding to controls in an application applicable to the second operating system platform;
[0022] The information replacement unit is further configured to:
[0023] Replace the key-value pairs in the search control operation interface of the basic test case that are applicable to the second operating system platform with the corresponding key-value pairs applicable to the first operating system platform.
[0024] In one optional embodiment, the basic test case is a test case template created for the application, and the original control attribute information includes control identifiers;
[0025] The information replacement unit is further configured to:
[0026] Replace the control identifier in the search control operation interface of the test case template with the corresponding key-value pair applicable to the first operating system platform.
[0027] Thirdly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the test case generation method of the first aspect.
[0028] Fourthly, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and when the computer program is executed by the processor, the processor enables the processor to implement the test case generation method of the first aspect.
[0029] The test case generation method, apparatus, storage medium, and electronic device provided in this application, based on existing basic test cases, determine the first operating system platform to which the target test cases to be generated should be applied. Then, the original control attribute information in the search control operation interface of the basic test cases is replaced with the target control attribute information applicable to the first operating system platform, thus obtaining the target test cases. This method eliminates the need for staff to write test cases separately for different operating system platforms, accelerating test case generation, saving time in generating test cases for different operating system platforms, and improving work efficiency. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This application provides an illustration of a test case generation method.
[0032] Figure 2A flowchart illustrating a test case generation method provided in an embodiment of this application;
[0033] Figure 3 A flowchart illustrating a specific implementation method provided in this application embodiment;
[0034] Figure 4 A schematic diagram of a login interface provided in an embodiment of this application;
[0035] Figure 5 A flowchart illustrating another specific implementation method provided in this application embodiment;
[0036] Figure 6 This is a schematic diagram of the structure of a test case generation device provided in an embodiment of this application;
[0037] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0039] It should be noted that the terms "comprising" and "having" and their variations used in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or device.
[0040] The following are explanations of some of the words that appear in the text:
[0041] (1) Key-value pairs: These represent the one-to-one correspondence between control properties and their values in a terminal device application page. A control is the external representation of a logical function in software, and it has a visual icon on the application's interface. When a user triggers the icon corresponding to a control, the control calls the corresponding logical function to perform an action, such as redirecting to a new page.
[0042] (2) Test case: A test case is a set of test case programs compiled to test a certain software functional module, including test inputs, execution conditions, and expected results. The test cases in the embodiments of this application are used to test the UI interaction logic of the application, and the test results are judged by verifying changes in the page and controls.
[0043] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0044] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0045] To better understand the technical solutions provided in the embodiments of this application, the background and applicable application scenarios of the technical solutions provided in the embodiments of this application are briefly introduced below. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided in the embodiments of this application can be flexibly applied according to actual needs.
[0046] With the rapid development of computer technology and the internet, the iteration speed of application products is becoming increasingly faster. To ensure that applications can function properly in the market, they are typically tested before release. To meet the increased testing demands brought about by agile development and rapid iteration of application products, automated testing of applications has become increasingly popular. Automated testing of applications includes automated testing of the application's UI interaction logic. Testing the application's UI interaction logic allows for the assessment of test results by verifying changes in the page and controls.
[0047] Because different mobile devices may run on different operating system platforms, applications for the same product are typically developed separately for each platform. In related technologies, when automating the UI interaction logic of applications for the same product on different operating system platforms, it is usually necessary to write separate test cases for each platform. For example, when automating the UI interaction logic of the same game application on iOS and Android operating system platforms, separate test cases need to be written for both platforms.
[0048] Taking the writing of test cases for the iOS operating system platform to automate the testing of UI interaction logic as an example, the following steps are taken: First, determine the control properties in each UI page of the application. Specifically, the location tool can be used to view the control properties in each page of the application. The control properties of each control can include: the control type, class name, attribute value, label, coordinates of the control, width and height parameters of the control, etc.
[0049] After obtaining the control's properties, you can locate the control's instance object through the UI interface. The UI interface used to find instance objects requires control properties as parameter characteristics to match the instance object of the control being searched for within the current UI page. For example, you can use the class name "Switch" and the tag "New Message Notification" as parameter characteristics to precisely locate the instance object of the toggle button corresponding to the new message notification in the UI page using the find interface function.
[0050] After locating the instance object of a control, you can manipulate it through the interface, similar to manual operations such as swiping, clicking, typing, and stretching. For example, after locating the instance object of the toggle button corresponding to a new message notification, you can click the toggle button using the click interface function, thus simulating human operation to turn the new message notification on or off. Through these steps, test cases can be generated, demonstrating the manipulation of each control. By connecting these controls in a certain order and logic, a complete UI operation flow can be formed, automating operations and replacing manual intervention.
[0051] Typically, software testing staff spend a significant amount of time writing test cases following the above process. Writing test cases for applications on different operating system platforms of the same product takes twice as long, resulting in very low efficiency. For example, automating the UI interaction logic of a game application on the iOS operating system platform requires writing 1,000 test cases, which would take staff two months. Similarly, automating the UI interaction logic of the same game application on the Android operating system platform also requires writing 1,000 test cases, again taking two months. Therefore, completing the test case writing for both iOS and Android operating system platforms would take a total of four months. Furthermore, after completing the test cases, maintenance is required, including finding and correcting errors, which also consumes a considerable amount of time.
[0052] To save time in generating test cases and improve work efficiency, this application provides a test case generation method. The test case generation method provided in this application can be executed by an electronic device used for application testing or for generating test cases. This electronic device can be a server, a computer, or other device with computing capabilities. For example, the electronic device may have an application installed to generate test cases. Users can write test cases through this application or generate test cases based on existing test cases. Specifically, users can specify existing test cases as base test cases and specify the first operating system platform to which the target test cases to be generated should be applied. The aforementioned base test cases can be test cases applicable to other operating system platforms or test case templates shared by various operating system platforms. The electronic device obtains the base test cases, determines the first operating system platform to which the target test cases to be generated should be applied, and replaces the original control attribute information in the setting type operation interface of the base test cases with the target control attribute information applicable to the first operating system platform to obtain the target test cases. This method can save time in writing test cases for different operating system platforms, improving the speed and efficiency of test case writing.
[0053] In some embodiments, the test case generation method provided in this application can also be applied to... Figure 1 In the application scenarios shown. See also Figure 1 As shown, this application scenario includes multiple terminal devices 11 and a server 12. Terminal devices 11 and server 12 can connect and transmit data via wired or wireless connections. For example, terminal devices 11 and server 12 can be connected via a data cable or a wired network; they can also be connected via an RF module, a WiFi module, or a wireless network.
[0054] The terminal device 11 can be a computer, laptop, PDA, tablet computer, etc. The server 12 can be a single server, a server cluster consisting of several servers, a cloud computing center, a virtualization platform, or a personal computer, large or medium-sized computer, or computer cluster. Depending on the implementation requirements, the application scenario in this application embodiment can have any number of terminal devices and servers. This application does not impose any special limitations on this. The test case generation method provided in this application embodiment can be executed by the server 12, or it can be executed collaboratively by the terminal device 11 and the server 12.
[0055] For example, an application development organization has a server 12 for testing the application and generating test cases. Each laboratory within the organization is equipped with a terminal device 11. Application testers can transmit their written test cases or test case templates to the server 12 via their own laboratory's terminal device 11. The server 12 can aggregate multiple test cases or test case templates written by different application testers, obtain basic test cases from the aggregated test cases or test case templates, and generate target test cases based on the basic test cases. To further illustrate the technical solutions provided in this application's embodiments, a detailed description is provided below in conjunction with the accompanying drawings and specific implementation methods. Although this application's embodiments provide method operation steps as shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on conventional or non-creative labor. In steps where there is no logically necessary causal relationship, the execution order of these steps is not limited to the execution order provided in this application's embodiments. In actual processing or device execution, this method may be executed sequentially or in parallel according to the method shown in the embodiments or drawings.
[0056] Figure 2 This document illustrates a flowchart of a test case generation method provided in an embodiment of this application. This method can be implemented by... Figure 1 The test case generation method can be executed by server 12, terminal device 11, or other electronic devices. Exemplarily, the following describes the specific implementation process of the test case generation method according to embodiments of this application, using a computer used for test cases as the execution entity. Figure 2 As shown, the test case generation method includes the following steps:
[0057] Step S201: Obtain basic test cases.
[0058] The obtained basic test cases can be test cases applicable to other operating system platforms besides the first operating system platform described below, such as the second operating system platform, or test case templates created for applications of the same product.
[0059] Step S202: Determine the first operating system platform to which the target test cases to be generated should be applied.
[0060] In some embodiments, the order of steps S202 and S201 can be reversed, that is, step S202 can also be performed before step S201.
[0061] Specifically, the computer has an application installed to generate test cases, and it stores existing test cases or test case templates. After launching the application, the user can select base test cases from the existing test cases or templates, and specify the first operating system platform on which the target test cases to be generated should be applied. The computer receives the first operating system platform on which the target test cases should be applied, and retrieves the base test cases selected by the user.
[0062] Step S203: Replace the original control attribute information in the setting type operation interface of the basic test case with the target control attribute information applicable to the first operating system platform to obtain the target test case.
[0063] In some embodiments, the original control attribute information in the set type operation interface can be replaced with the target control attribute information corresponding to the original control attribute information based on the established correspondence between the control attribute information of each operating system platform.
[0064] The correspondence between control attribute information across different operating system platforms is pre-established. To establish this correspondence, the control attributes and their values, representing each control, are first retrieved from applications applicable to each operating system platform. Then, for each control, the control attributes and their values are combined to form a key-value pair corresponding to that control. Finally, based on the control identifiers of each control and their corresponding key-value pairs, the correspondence between control attribute information representing the same control across different operating system platforms is established.
[0065] In one optional embodiment, the basic test case is a test case applicable to a second operating system platform. The original control attribute information in the setting type operation interface of the basic test case may include key-value pairs corresponding to controls in the application applicable to the second operating system platform. Based on the established correspondence between control attribute information of the first operating system platform and the correspondence between control attribute information of the second operating system platform, the key-value pairs applicable to the second operating system platform in the search control operation interface of the basic test case can be replaced with corresponding key-value pairs applicable to the first operating system platform.
[0066] In another optional embodiment, the basic test case is a test case template built for the application. The original control attribute information in the setting type operation interface of the basic test case should include the control identifier. According to the established correspondence between the control attribute information of the first operating system platform, the control identifier in the search control operation interface of the test case template can be replaced with the corresponding key-value pair applicable to the first operating system platform.
[0067] The test case generation method provided in this application, based on existing basic test cases, determines the first operating system platform to which the target test case to be generated should be applied. Then, it replaces the original control attribute information in the search control operation interface of the basic test cases with the target control attribute information applicable to the first operating system platform, thus obtaining the target test case. This method eliminates the need for staff to write test cases separately for different operating system platforms, accelerating test case generation, saving time, and improving work efficiency.
[0068] The following section uses two specific implementation methods to illustrate the differences and effects between the test case generation method provided in this application and related technologies.
[0069] The explanation will continue using the iOS and Android operating system platforms as examples. In related technologies, a test case is written for the login page of the same product on both the iOS and Android operating system platforms. This login page can be configured as follows: Figure 4 As shown, on both operating system platforms, the login page includes an account control, a password control, and a login control. The functions implemented are the same: to receive the user's entered account and password through the account control and password control respectively, and then to log in based on the user's click on the login control.
[0070] The process of writing test cases for the login page of the iOS operating system platform is as follows: The account control used by the iOS operating system platform is "name = account", where "name" is the control property of the account control and "account" is the control property value of the account control. The program code statement to find the account control is "account = findElementByName('account')". The input type interface used by the iOS operating system platform is inputElementUseIOS. Assuming that the account entered in the test case using this input type interface is 12345678901@qq.com, the program code statement to enter the account is inputElementUseIOS(account, "12345678901@qq.com"). The password control used by the iOS operating system platform is "name = password", where "name" is the control property of the password control and "password" is the control property value of the password control. The code statement to find the password control is "password = findElementByName('password')". Assuming the password entered in the test case using the above input type interface is "123456", the code statement to input the password is inputElementUseIOS(password, "123456"). The login control used by the iOS operating system platform is "AccessibilityID = login", where "AccessibilityID" is the control property of the login control, and "login" is the value of the login control property. The code statement to find the login control is "login = findElementByAccessibilityID('login')". The click interface used by the iOS operating system platform is clickElementUseIOS, so the code statement to perform the click login is clickElementUseIOS(login). Through the above steps, the test cases can be completed, resulting in the following test cases for the iOS operating system platform:
[0071] / / iOS
[0072] 1. Use name=account to find the account input control.
[0073] account = findElementByName('account name')
[0074] 2. Use the iOS API to enter the account 12345678901@qq.com
[0075] inputElementUseIOS(account, "12345678901@qq.com")
[0076] 3. Use name=password to find the password input control.
[0077] password = findElementByName('password')
[0078] 4. Enter the password "123456" using the iOS interface.
[0079] inputElementUseIOS(password, "123456")
[0080] 5. Use AccessibilityID=login to find the login button.
[0081] login=findElementByAccessbilityID('login')
[0082] 6. Use the iOS interface for click-to-login
[0083] clickElementUseIOS(login)
[0084] The process of writing test cases for the login page of the Android operating system platform is as follows: The account control used by the Android operating system platform is "ID = accountName", where "ID" is the control property of the account control and "accountName" is the value of the control property. The program code statement to find the account control is "account = findElementByID('accountName')". The input type interface used by the Android operating system platform is inputElementUseAndroid. Assuming that the account entered in the test case using this input type interface is 12345678901@qq.com, the program code statement to enter the account is inputElementUseAndroid(account, "12345678901@qq.com"). The password control used by the Android operating system platform is "ClassName = inputText", where "ClassName" is the control property of the password control and "inputText" is the value of the control property. The code statement to find the password control is "password = findElementByClassName('inputText')". Assuming the password entered using the above input type interface in the test case is "123456", the code statement to input the password is inputElementUseAndroid(password, "123456"). The login control used by the Android operating system platform is "ID = login", where "ID" is the control property of the login control, and "login" is the value of the login control property. The code statement to find the login control is "login = findElementByID('login')". The click interface used by the Android operating system platform is clickElementUseAndroid, so the code statement to perform the click login is clickElementUseAndroid(login). Through the above steps, the test cases can be completed, resulting in the following test cases for the Android operating system platform:
[0085] Android
[0086] 1. Use id=accountName to find the account input control.
[0087] account=findElementByID('accountName')
[0088] 2. Use the Android interface to enter the account 12345678901@qq.com
[0089] inputElementUseAndroid(account, "12345678901@qq.com")
[0090] 3. Use ClassName = inputText to locate the password input control.
[0091] password=findElementByClassName('inputText')
[0092] 4. Enter the password "123456" using the Android interface.
[0093] inputElementUseAndroid(password, "123456")
[0094] 5. Use ID=login to find the login button.
[0095] login=findElementByID('login')
[0096] 6. Use the Android interface for click-to-login
[0097] clickElementUseAndroid(login)
[0098] As described above, in related technologies, the same control has different control properties and control property values for iOS and Android operating system platforms, and the operation interfaces used to achieve the same function are also different. Therefore, it is necessary to write test cases separately for different operating system platforms.
[0099] In this embodiment, the control attributes and control attribute values of each control in the iOS operating system platform and the Android operating system platform can be combined to form the key-value pairs corresponding to the control. Based on the control identifier of each control and the corresponding key-value pairs, a correspondence between control attribute information used to represent the same control in the iOS operating system platform and the Android operating system platform can be established.
[0100] For example, for the account control mentioned above, the key-value pair corresponding to the account control is formed by combining the control property "name" and the control property value "account" in the iOS operating system platform: 'Name':'account'. Similarly, the key-value pair corresponding to the account control is formed by combining the control property "ID" and the control property value "accountName" in the Android operating system platform: 'ID':'accountName'. Based on the control identifier "account control" and the corresponding key-value pair, the correspondence between the control property information representing the account control in the iOS and Android operating system platforms can be obtained as follows:
[0101] "Account control" = {'Name':'Account Name', 'ID':'accountName'}.
[0102] Similarly, the correspondence between the control attribute information used to represent password controls and login controls in the iOS and Android operating system platforms can be obtained as follows:
[0103] "Password control" = {'Name':'Password', 'ClassName':'inputText'}
[0104] "Login control" = {'AccessibilityID':'login', 'ID':'login'}.
[0105] When establishing the correspondence between the above control property information, the first column of key-value pairs in the correspondence can be pre-set to be the key-value pairs corresponding to the iOS operating system platform, and the first column of key-value pairs can be the key-value pairs corresponding to the Android operating system platform.
[0106] In some embodiments, to facilitate finding key-value pairs corresponding to different operating system platforms, a corresponding platform identifier can be set before each key-value pair when establishing the correspondence between control attribute information. That is, based on the platform identifier of each operating system platform, the control identifier of each control, and the corresponding key-value pair, a correspondence is established between control attribute information representing the same control across different operating system platforms. An example is shown below:
[0107] "Account control" = {iOS: 'Name': 'Account', Android: 'ID': 'accountName'}
[0108] "Password control" = {iOS: 'Name': 'Password', Android: 'ClassName': 'inputText'}
[0109] "Login control" = {iOS: 'AccessibilityID': 'login', Android: 'ID': 'login'}
[0110] In this context, iOS: 'Name': 'Account' means that 'Name': 'Account' is a key-value pair corresponding to the iOS operating system platform, and Android: 'ID': 'accountName' means that 'ID': 'accountName' is a key-value pair corresponding to the Android operating system platform.
[0111] In related technologies, the operation interfaces used to implement the same interface functions are different for the iOS and Android operating system platforms. For example, the input type interface used to implement input functions is inputElementUseIOS on the iOS operating system platform, while inputElementUseAndroid is used on the Android operating system platform.
[0112] In this embodiment of the application, to facilitate the conversion of test cases between two operating system platforms, the operation interfaces of the iOS and Android operating system platforms are unified. That is, when implementing the same interface function, the same operation interface is used for both operating system platforms. For example, the search control operation interface is unified as findElement(string), the input type interface is unified as inputElement(element,content), and the click interface is unified as clickElement(element).
[0113] Based on the above settings, in a specific embodiment, the execution process of the test case generation method can be as follows: Figure 3 As shown, it includes the following steps:
[0114] Step S301: Obtain test cases suitable for the second operating system platform as base test cases.
[0115] As described above, the basic test cases can be user-inputted or obtained based on user selection. In this embodiment, the obtained basic test cases are test cases applicable to the second operating system platform.
[0116] Step S302: Determine the first operating system platform to which the target test cases to be generated should be applied.
[0117] The first operating system platform and the second operating system platform are different. For example, the first operating system platform can be the Android operating system platform, and the second operating system platform can be the iOS operating system platform; or, the first operating system platform can be the iOS operating system platform, and the second operating system platform can be the Android operating system platform.
[0118] Step S303: Replace the original control attribute information in the setting type operation interface of the test cases of the second operating system platform with the target control attribute information applicable to the first operating system platform to obtain the target test cases.
[0119] In some embodiments, when implementing the same interface functionality, test cases applicable to different operating system platforms use the same operation interface. Therefore, when converting test cases applicable to a second operating system platform into test cases applicable to a first operating system platform, it is not necessary to modify the operation interface. Only the original control attribute information in the setting type operation interface of the test cases for the second operating system platform needs to be replaced with the target control attribute information applicable to the first operating system platform to obtain the target test cases. The setting type operation interface can be a search control operation interface.
[0120] Specifically, the original control attribute information in the setting type operation interface of the basic test cases is the key-value pair corresponding to the control in the application applicable to the second operating system platform. Based on the established correspondence between the control attribute information of each operating system platform, the key-value pairs in the search control operation interface of the test cases applicable to the second operating system platform can be replaced with the corresponding key-value pairs applicable to the first operating system platform.
[0121] The following example uses Android as the first operating system platform and iOS as the second operating system platform. For instance, a user might write a test case for the iOS operating system platform as follows:
[0122] account = findElement('Name':'account')
[0123] inputElement(account, "12345678901@qq.com")
[0124] password = findElement('Name':'password')
[0125] inputElement(password, "123456")
[0126] login=findElement('AccessbilityID':'login')
[0127] clickElement(login).
[0128] The user designates this test case as the base test case and specifies that it be converted into a test case suitable for the Android operating system platform. Upon receiving the user's instruction, the computer first identifies the search control operation interfaces contained in the base test case, and then sequentially replaces the key-value pairs in each search control operation interface with the corresponding key-value pairs for the Android operating system platform.
[0129] In some embodiments, based on the key-value pair 'Name':'Account' in the first search control operation interface findElement('Name':'Account') in the basic test case, the key-value pair 'Name':'Account' can be found from the pre-established mapping relationship of control attribute information. The corresponding key-value pair for the Android operating system platform is 'ID':'accountName'. Alternatively, based on the object "account" corresponding to the first search control operation interface in the basic test case, the control identifier of the control corresponding to "account" can be determined to be "Account Control". From the pre-established mapping relationship of control attribute information, the key-value pair for the Android operating system platform corresponding to the control identifier "Account Control" can be found as 'ID':'accountName'. Thus, the key-value pair 'Name':'Account' in the first search control operation interface findElement('Name':'Account') in the basic test case is replaced with the key-value pair 'ID':'accountName' for the Android operating system platform.
[0130] Similarly, in the second search control operation interface findElement('Name':'Password') in the basic trial example, the key-value pair 'Name':'Password' can be replaced with the Android operating system platform key-value pair 'ClassName':'inputText'. Similarly, in the third search control operation interface findElement('AccessibilityID':'login') in the basic trial example, the key-value pair 'AccessibilityID':'login' can be replaced with the Android operating system platform key-value pair 'ID':'login'.
[0131] In other embodiments, after the computer determines that the target test cases to be generated should be applied to the Android operating system platform, it can obtain all key-value pairs corresponding to the Android operating system from the pre-established correspondence of control attribute information, such as "Account control" = {'ID':'accountName'}, "Password control" = {'ClassName':'inputText'}, and "Login control" = {'ID':'login'}. Then, based on the object "account" corresponding to the first search control operation interface in the basic test case, it can determine that the control identifier of the control corresponding to "account" is "Account control", and obtain the key-value pairs corresponding to the Android operating system. Within the data, the key-value pair for the Android operating system platform corresponding to the "Account Control" control can be found to be 'ID':'accountName'. Similarly, the control identifier for "password" can be determined to be "Password Control", and the control identifier for "login" can be determined to be "Login Control". From the obtained key-value pairs corresponding to the Android operating system, the key-value pair corresponding to the "Password Control" control can be found to be 'ClassName':'inputText', and the key-value pair corresponding to the "Login Control" control can be found to be 'ID':'login'. Therefore, the key-value pairs in each search control operation interface in the basic test cases can be replaced with the corresponding key-value pairs for the Android operating system platform.
[0132] By following the steps above, target test cases suitable for the Android operating system platform can be generated. The generated target test cases are as follows:
[0133] account=findElement('ID':'accountName')
[0134] inputElement(account, "12345678901@qq.com")
[0135] password=findElement('ClassName':'inputText')
[0136] inputElement(password, "123456")
[0137] login=findElement('ID':'login')
[0138] clickElement(login).
[0139] In some embodiments, users can first write test cases in batches for the iOS operating system platform, and then select multiple test cases as base test cases, specifying the target test cases as applicable to the Android operating system platform. The computer can then use this method to generate corresponding test cases applicable to the Android operating system platform for each of the multiple test cases selected by the user, eliminating the need for the user to write test cases specifically for the Android operating system platform.
[0140] Users can first write test cases in batches for the Android operating system platform, and then select multiple test cases as base test cases, specifying the target operating system platform as iOS. The computer can then use this method to generate corresponding test cases applicable to the iOS operating system platform for each of the user-selected test cases, eliminating the need for users to write separate test cases for iOS. Therefore, this speeds up test case generation, saves time in generating test cases for different operating system platforms, and improves work efficiency.
[0141] In another specific embodiment, the execution process of the test case generation method can be as follows: Figure 5 As shown, it includes the following steps:
[0142] Step S501: Obtain the test case template created for the application as the base test case.
[0143] In this embodiment, the basic test cases obtained are test case templates created for the application.
[0144] Step S502: Determine the first operating system platform to which the target test cases to be generated should be applied.
[0145] The primary operating system platform can be either the Android operating system platform or the iOS operating system platform.
[0146] Step S503: Replace the original control attribute information in the setting type operation interface of the test case template with the target control attribute information applicable to the first operating system platform to obtain the target test case.
[0147] In some embodiments, when implementing the same interface functionality, test cases applicable to various operating system platforms use the same operation interface. Therefore, when converting a test case template into a test case applicable to the first operating system platform, it is not necessary to modify the operation interface; simply replace the original control attribute information in the setting type operation interface of the test case template with the target control attribute information applicable to the first operating system platform to obtain the target test case. The setting type operation interface can be a search control operation interface.
[0148] Specifically, the original control attribute information in the setting type operation interface of the basic test case is the control identifier. Based on the established correspondence between the control attribute information of various operating system platforms, the control identifier in the search control operation interface of the test case template can be replaced with the corresponding key-value pair applicable to the first operating system platform.
[0149] The following explanation uses the Android operating system platform as an example. For instance, a user can create a test case template as follows:
[0150] account = findElement('Account Control')
[0151] inputElement(account, "12345678901@qq.com")
[0152] password = findElement('password control')
[0153] inputElement(password, "123456")
[0154] login = findElement('login control')
[0155] clickElement(login).
[0156] The user designates this test case template as the base test case and specifies that it should be converted into test cases suitable for the Android operating system platform. Upon receiving the user's instruction, the computer first identifies the search control operation interfaces contained in the base test cases, and then sequentially replaces the control identifiers in each search control operation interface with the corresponding key-value pairs for the Android operating system platform.
[0157] In some embodiments, based on the control identifier 'Account Control' in the first search control operation interface findElement('Account Control') in the basic test case, the corresponding Android operating system platform key-value pair 'ID':'accountName' can be found from the pre-established mapping relationship of control attribute information. Therefore, the control identifier in the first search control operation interface findElement('Account Control') in the basic test case is replaced with the Android operating system platform key-value pair 'ID':'accountName'.
[0158] Similarly, in the second search control operation interface findElement('Password Control') in the basic trial example, you can replace the control identifier 'Password Control' with the Android operating system platform key-value pair 'ClassName':'inputText'. Similarly, in the third search control operation interface findElement('Login Control') in the basic trial example, you can replace the control identifier 'Login Control' with the Android operating system platform key-value pair 'ID':'login'.
[0159] By following the steps above, target test cases suitable for the Android operating system platform can be generated. The generated target test cases are as follows:
[0160] account=findElement('ID':'accountName')
[0161] inputElement(account, "12345678901@qq.com")
[0162] password=findElement('ClassName':'inputText')
[0163] inputElement(password, "123456")
[0164] login=findElement('ID':'login')
[0165] clickElement(login)
[0166] In some embodiments, the first operating system platform can also be the iOS operating system platform. After writing a test case template, the user designates the test case template as the base test case and specifies that the base test case be converted into test cases suitable for the iOS operating system platform. After receiving the user's instruction, the computer first determines the search control operation interface contained in the base test case, and then replaces the control identifier in each search control operation interface with the corresponding key-value pair of the iOS operating system platform in turn, thereby generating the target test cases for the iOS system. The generated target test cases are as follows:
[0167] account = findElement('Name':'account')
[0168] inputElement(account, "12345678901@qq.com")
[0169] password = findElement('Name':'password')
[0170] inputElement(password, "123456")
[0171] login=findElement('AccessbilityID':'login')
[0172] clickElement(login).
[0173] In the above embodiments, the process of generating test cases using the method provided in this application is illustrated using two operating system platforms as examples. In other embodiments, the test case generation method provided in this application can also be used to convert test cases between multiple operating system platforms to generate the required test cases. For example, the operating system platforms may include multiple operating system platforms such as iOS, Android, Mac, and PC. For example, the operating system platforms may include three operating system platforms: iOS, Android, and PC. When establishing the correspondence between control attribute information, the correspondence between control attribute information representing the same control in the above three operating system platforms can be established. For example, the correspondence between the control attribute information of the account control can be represented as: "Account Control" = {iOS: 'Name': 'Account', Android: 'ID': 'accountName', PC: 'Name': 'Username'}. The test case generation process for each operating system platform can refer to the test case generation process for the iOS and Android systems described above, and will not be repeated here.
[0174] and Figure 2 The test case generation method shown is based on the same inventive concept. This application also provides a test case generation device. Since this device corresponds to the test case generation method of this application, and the principle by which this device solves the problem is similar to that of the method, the implementation of this device can refer to the implementation of the above method; repeated details will not be elaborated further.
[0175] Figure 6 This paper illustrates a schematic diagram of a test case generation device provided in an embodiment of this application. Figure 6 As shown, the test case generation device includes a test case acquisition unit 601, a platform determination unit 602, and an information replacement unit 603.
[0176] Among them, the test case acquisition unit 601 is used to acquire basic test cases;
[0177] Platform determination unit 602 is used to determine the first operating system platform to which the target test cases to be generated should be applied;
[0178] The information replacement unit 603 is used to replace the original control attribute information in the setting type operation interface of the basic test case with the target control attribute information applicable to the first operating system platform to obtain the target test case.
[0179] In an optional embodiment, the information replacement unit 603 is specifically used for:
[0180] Based on the established correspondence between control attribute information of various operating system platforms, the original control attribute information in the setting type operation interface is replaced with the target control attribute information corresponding to the original control attribute information.
[0181] In an optional embodiment, the information replacement unit 603 is further configured to:
[0182] These tools are applicable to finding control properties and their values that characterize various controls from applications on different operating system platforms.
[0183] For each control, combine the control's properties and their values to form a key-value pair corresponding to that control;
[0184] Based on the control identifiers and corresponding key-value pairs of each control, a correspondence is established between control attribute information used to represent the same control in various operating system platforms.
[0185] In an optional embodiment, the base test cases are test cases applicable to the second operating system platform; the original control attribute information includes key-value pairs corresponding to controls in the application applicable to the second operating system platform; the information replacement unit 603 is further used for:
[0186] Replace the key-value pairs in the search control operation interface of the basic test cases that are applicable to the second operating system platform with the corresponding key-value pairs applicable to the first operating system platform.
[0187] In an optional embodiment, the base test case is a test case template built for the application, and the original control attribute information includes the control identifier; the information replacement unit 603 is further used for:
[0188] Replace the control identifiers in the search control operation interface of the test case template with corresponding key-value pairs applicable to the first operating system platform.
[0189] In one alternative embodiment, when implementing the same interface functionality, test cases applicable to various operating system platforms use the same operation interface.
[0190] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. This electronic device can be used for test case generation. In one embodiment, the electronic device can be a server, a terminal device, or other electronic equipment. In this embodiment, the structure of the electronic device can be as follows: Figure 7 As shown, it includes a memory 101, a communication module 103, and one or more processors 102.
[0191] The memory 101 is used to store computer programs executed by the processor 102. The memory 101 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0192] Memory 101 may be volatile memory, such as random-access memory (RAM); memory 101 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 101 may be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 101 may be a combination of the above-described memories.
[0193] Processor 102 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 102 is used to implement the above-described test case generation method when calling computer programs stored in memory 101.
[0194] The communication module 103 is used to communicate with terminal devices and other electronic devices.
[0195] This application does not limit the specific connection medium between the memory 101, communication module 103, and processor 102 described above. This disclosure embodiment... Figure 7 The memory 101 and the processor 102 are connected via a bus 104, and the bus 104 is in Figure 7 The connections between other components are shown in thick lines only and are not intended to be limiting. Bus 104 can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0196] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the test case generation method described in the above embodiments. The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0197] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0198] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0199] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A test case generation method, characterized in that, The method is used to generate test cases for various operating system platforms. When implementing the same interface function, the test cases applicable to various operating system platforms use the same operation interface; the method includes: Obtain basic test cases; The first operating system platform to which the target test cases to be generated should be applied is determined; based on the established correspondence between the control attribute information of each operating system platform, the original control attribute information in the setting type operation interface of the basic test cases is replaced with the target control attribute information applicable to the first operating system platform that corresponds to the original control attribute information, thereby obtaining the target test cases; the basic test cases are test cases applicable to the second operating system platform, or the basic test cases are test case templates established for the application. The process of establishing the correspondence between control attribute information of each operating system platform includes: searching for control attributes and control attribute values used to represent each control from applications applicable to each operating system platform; for each control, forming a key-value pair corresponding to the control by combining the control attributes and control attribute values; and establishing the correspondence between control attribute information used to represent the same control in each operating system platform based on the control identifier of each control and the corresponding key-value pair.
2. The method according to claim 1, characterized in that, The basic test cases are test cases applicable to the second operating system platform; the original control attribute information includes key-value pairs corresponding to controls in the application applicable to the second operating system platform; Replacing the original control attribute information in the specified type operation interface with the target control attribute information corresponding to the original control attribute information includes: Replace the key-value pairs in the search control operation interface of the basic test case that are applicable to the second operating system platform with the corresponding key-value pairs applicable to the first operating system platform.
3. The method according to claim 1, characterized in that, The basic test cases are test case templates created for the application; the original control attribute information includes control identifiers; Replacing the original control attribute information in the specified type operation interface with the target control attribute information corresponding to the original control attribute information includes: Replace the control identifier in the search control operation interface of the test case template with the corresponding key-value pair applicable to the first operating system platform.
4. A test case generation device, characterized in that, The apparatus is used to generate test cases for various operating system platforms. When implementing the same interface function, test cases applicable to various operating system platforms use the same operation interface; the apparatus includes: The test case acquisition unit is used to acquire basic test cases; The platform determination unit is used to determine the first operating system platform to which the target test cases to be generated should be applied. The information replacement unit is used to replace the original control attribute information in the setting type operation interface of the basic test case with the target control attribute information applicable to the first operating system platform, according to the established correspondence between the control attribute information of each operating system platform, so as to obtain the target test case; the basic test case is a test case applicable to the second operating system platform, or the basic test case is a test case template established for the application. The process of establishing the correspondence between control attribute information of each operating system platform includes: searching for control attributes and control attribute values used to represent each control from applications applicable to each operating system platform; for each control, forming a key-value pair corresponding to the control by combining the control attributes and control attribute values; and establishing the correspondence between control attribute information used to represent the same control in each operating system platform based on the control identifier of each control and the corresponding key-value pair.
5. The apparatus according to claim 4, characterized in that, The information replacement unit is specifically used for: Based on the established correspondence between the control attribute information of various operating system platforms, the original control attribute information in the specified type operation interface is replaced with the target control attribute information corresponding to the original control attribute information.
6. The apparatus according to claim 5, characterized in that, The information replacement unit is further configured to: Find the control properties and control property values that represent each control from applications applicable to each operating system platform; For each control, combine the control's properties and their values to form a key-value pair corresponding to that control; Based on the control identifiers and corresponding key-value pairs of each control, a correspondence is established between control attribute information used to represent the same control in various operating system platforms.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 3.
8. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program that can run on the processor, and when the computer program is executed by the processor, it implements the method of any one of claims 1 to 3.
Citation Information
Patent Citations
Automation test method and apparatus
CN108614774A