CN117312148A - Automatic interface testing method and device, computer equipment and storage medium - Google Patents

Automatic interface testing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN117312148A
CN117312148A CN202311257652.9A CN202311257652A CN117312148A CN 117312148 A CN117312148 A CN 117312148A CN 202311257652 A CN202311257652 A CN 202311257652A CN 117312148 A CN117312148 A CN 117312148A
Authority
CN
China
Prior art keywords
test
keywords
action
case
natural language
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311257652.9A
Other languages
Chinese (zh)
Inventor
李青
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinan Inspur Data Technology Co Ltd
Original Assignee
Jinan Inspur Data Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinan Inspur Data Technology Co Ltd filed Critical Jinan Inspur Data Technology Co Ltd
Priority to CN202311257652.9A priority Critical patent/CN117312148A/en
Publication of CN117312148A publication Critical patent/CN117312148A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of cloud computing, and discloses an interface automatic testing method, an interface automatic testing device, computer equipment and a storage medium, wherein the method is applied to a testing system and comprises the following steps: acquiring a natural language test case; identifying action keywords and object keywords in the natural language test case, wherein the action keywords represent executed test actions, and the object keywords represent test objects applying the test actions; generating an interface automation test code according to the action keywords and the object keywords; and the running interface automatically tests the code. The invention solves the problems of lower writing efficiency and difficult modification of the automatic test code.

Description

Automatic interface testing method and device, computer equipment and storage medium
Technical Field
The invention relates to the technical field of cloud computing, in particular to an interface automatic testing method, an interface automatic testing device, computer equipment and a storage medium.
Background
Cloud computing is widely applied to provide reliable basic software and hardware, abundant network resources and low-cost construction and management capability, and continuous heating of cloud computing products also promotes rapid iteration of the products, continuously promotes more diverse functions and meets various demands of customers. As the functions of cloud computing products become increasingly complex, it has become increasingly difficult for related products to cover all functional branches through manual testing, and simply manually completing the testing has become an increasingly significant challenge to testers, which is detrimental to verifying the robustness and security of the products. The interface test is a test of interfaces among components of the test system, and the interface test system can directly issue test parameters to the interfaces without passing through a UI interface. However, the code writing and comparison of the automatic test of the interface depends on the coding level of coding personnel, various tools are good and uneven, the learning cost is high, and the automatic test code is difficult to output quickly and high-quality. And with the enrichment of product functions and the increase of test cases, it becomes difficult to maintain automation codes and test cases, and temporary addition or modification of cases cannot be completed efficiently, so that a more flexible test method is required.
Disclosure of Invention
In view of the above, the present invention provides an interface automation test method, device, computer device and storage medium, so as to solve the problems of low efficiency and difficult modification of automatic test code writing.
In a first aspect, the present invention provides an automated interface testing method, applied to a testing system, the method comprising: acquiring a natural language test case; identifying action keywords and object keywords in the natural language test case, wherein the action keywords represent executed test actions, and the object keywords represent test objects applying the test actions; generating an interface automation test code according to the action keywords and the object keywords; and the running interface automatically tests the code.
According to the technical means, the embodiment of the invention maintains the test case in natural language, a user inputs the desired test logic in natural language to obtain the natural language test case, the test system identifies the natural language test case, extracts action keywords and object keywords from the natural language test case, then continues to analyze the extracted action keywords and object keywords, and converts the description actions of the natural language words into interface automation test codes, thereby carrying out automation test according to the generated interface automation codes. On the one hand, the user does not need to write code instructions, but only needs to input test logic according to natural language, so that the writing difficulty of the test case is obviously reduced. In addition, the modification and maintenance of the test cases are easy, and the user only needs to modify the description of the natural language test cases, and does not need to write at the code level. The method solves the problems of low writing efficiency and difficult modification of the automatic test codes, and remarkably improves the flexibility of the automatic test of the interface.
In an alternative embodiment, the acquiring the natural language test case includes: acquiring the natural language test case from a case management module, wherein the case management module is used for storing the natural language test case; the step of adding the natural language test case through the case management module comprises the following steps: receiving an input natural language test case; receiving an input use case keyword; receiving a marking instruction; adding an action tag or an object tag to the use case keyword in response to the marking instruction; receiving an input test method code; receiving an input parameter symbol; packaging the test method codes to obtain a basic test method; matching the basic test method with the use case keywords added with the action labels according to the actions executed by the basic test method, and determining target keywords; establishing an association relation between a basic test method with consistent action matching and a target keyword; and establishing a one-to-one association relation between the parameter symbol and each use case keyword added with the object label.
According to the technical means, the embodiment of the invention receives various natural language test cases input by a user through the case management module, so that the test cases can be directly acquired and operated when the test is needed. In addition, in the test system, various case keywords input by a user are maintained through a case analysis module, corresponding specific meanings of the case keywords are analyzed aiming at the case keywords for pre-configuration, and whether each case keyword represents a test action or an object representing a test parameter is determined, so that an action label or an object label is added for the case keywords. Meanwhile, the user also configures testing method codes without input parameters in the testing system in advance, the testing method codes are managed through the interface code module, and different testing method codes correspond to different testing actions, so that the testing method codes are matched with action labels according to actual testing actions, and are further correlated with use case keywords input in advance by the user, and in addition, each testing method code is packaged and convenient to call. Through the processing, the maintained natural language test cases can accurately correspond to the executed basic test methods after the keywords are extracted, the interface automatic test codes are rapidly generated by using the determined basic test methods, and the accuracy and the generation efficiency of the interface automatic test codes can be remarkably improved.
In an alternative embodiment, identifying action keywords and object keywords in a natural language test case includes: traversing and extracting the text of the natural language test case according to different word segmentation lengths; sequentially comparing the extracted text with the stored use case keywords; determining candidate keywords consistent with the use case keyword comparison from the extracted text; and dividing the candidate keywords into action keywords and object keywords according to the action tags or the object tags marked by the candidate keywords.
According to the technical means, a large number of case keywords are stored in the test system in advance, and action labels or object labels are assigned to each case keyword. When the intention of the natural language test case is identified, whether the stored case keywords exist or not is directly and accurately searched in sentences of the natural language test case, the searched candidate keywords are directly extracted, and then the candidate keywords are divided into action keywords and object keywords according to marked action tags or object tags, so that the difficulty of intention identification can be reduced, the generation speed of the test case is remarkably improved, and the test efficiency is improved.
In an alternative embodiment, generating interface automation test code from action keywords and object keywords includes: matching the extracted action keywords with the object keywords to obtain one or more test combinations; aiming at the current test combination, calling a current basic test method corresponding to the current action keyword according to the stored association relation; determining a target parameter symbol serving as an input parameter according to the object keywords in the current test combination; importing the target parameter symbol into a current basic test method to generate a current test code segment; the next test combination is used as a current test combination, and the current basic test method corresponding to the current action keyword is called according to the stored association relation aiming at the current test combination; and when the generation of the test code segments corresponding to each test combination is finished, splicing each test code segment to obtain an interface automatic test code.
According to the technical means, when the acquired natural language test case comprises a plurality of action keywords and a plurality of object keywords, the embodiment pairs and matches the action keywords and the object keywords according to the description logic of the natural language, so that the action keywords and the object keywords belonging to the same test logic are classified into the same test combination, and the object keywords are further used as input parameters to perfect the basic test method associated with each action keyword. Finally, each perfect basic test method is spliced into a complete test code, so that an automatic interface test code is obtained, and a simple, efficient and accurate automatic interface test code generation method is realized.
In an alternative embodiment, matching the extracted action keywords with the object keywords to obtain one or more test combinations includes: identifying sentence breaking of the natural language test case; and dividing the target action keywords and the object keywords belonging to the same broken sentence into the same test combination from the extracted action keywords and the object keywords.
In an alternative embodiment, stitching each test code segment includes: checking whether the basic test method in each test code segment can process the corresponding input parameters; deleting the test code segment of which the checking result is that the corresponding input parameter cannot be processed; arranging the splicing sequence of each test code segment according to the execution action in each test code segment; and splicing the test code fragments according to the splicing sequence.
In an alternative embodiment, before running the interface automation test code for testing, the method further comprises: displaying interface automation test codes in an editable program window; receiving an input modification instruction; the interface automation test code is adjusted in response to the modification instruction.
In a second aspect, the present invention provides an automated interface testing apparatus, for use in a testing system, the apparatus comprising: the test case acquisition module is used for acquiring a natural language test case; the keyword extraction module is used for identifying action keywords and object keywords in the natural language test cases, wherein the action keywords represent executed test actions, and the object keywords represent test objects applying the test actions; the code generation module is used for generating interface automation test codes according to the action keywords and the object keywords; and the test module is used for running the interface automation test code to test.
In a third aspect, the present invention provides a computer device comprising: the memory and the processor are in communication connection, the memory stores computer instructions, and the processor executes the computer instructions to perform the method of the first aspect or any implementation manner corresponding to the first aspect.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of the first aspect or any of its corresponding embodiments.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an automated interface test method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a test system according to an embodiment of the invention;
FIG. 3 is another flow diagram of an interface automated test method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an automated interface test equipment according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a hardware structure of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In accordance with an embodiment of the present invention, an interface automated test method embodiment is provided, it being noted that the steps shown in the flowchart of the figures may be performed in a computer system, such as a set of computer executable instructions, and, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order other than that shown or described herein.
In this embodiment, an automatic interface testing method is provided, which may be used in the above-mentioned computer device, and fig. 1 is a flowchart of an automatic interface testing method according to an embodiment of the present invention, where the flowchart includes the following steps:
step S101: and acquiring a natural language test case.
In particular, considering that the programming of the interface automation code is dependent on the coding level of coding personnel, various tools are good and bad, the learning cost is high, and the automation code is difficult to output rapidly and high-quality. And with the richness of product functions and the increase of test cases, it becomes difficult to maintain automation codes and test cases, and temporary increase or modification of cases cannot be completed efficiently. The invention provides an automatic interface test method, which is characterized in that after analyzing test cases written in natural language, an automatic interface code is automatically generated, a tester can directly use the code or adjust the code to carry out interface test in a small scale, and after modifying the automatic cases, the code can be synchronously modified, and the modification contents of the cases and the code are synchronized.
Firstly, the embodiment of the invention maintains the test case by natural language, when a user needs to test, the user inputs the desired test logic to the test system by natural language so as to obtain the natural language test case, for example, the natural language test case can be' 1, a virtual machine is created, and the virtual machine has two magnetic discs; 2. and starting the virtual machine. The test system provided by the embodiment of the invention is a software system which is specially used for maintaining test cases, analyzing the test cases and executing tests, and can be deployed in computer equipment such as personal computers, servers and the like.
Step S102: and identifying action keywords and object keywords in the natural language test case, wherein the action keywords represent executed test actions, and the object keywords represent test objects to which the test actions are applied.
Specifically, when the testing system obtains a natural language testing case to be tested, the natural language testing case is first identified to extract action keywords and object keywords from the natural language testing case. Wherein, the action keyword represents the executed test action, the object keyword represents the test object to which the test action is applied, for example, the natural language test case is "1", a virtual machine is created, and the virtual machine has two disks; 2. and starting the virtual machine. The corresponding extracted action keywords comprise creation and starting; the object keywords include virtual machine, two disks. The process of extracting the keywords can be realized through a pre-trained natural language processing model, and the natural language processing model built by using a large amount of data training neural network is utilized, so that the intention of the natural language test case is identified, and the keywords in the natural language test case are accurately extracted. The pre-training process for the natural language processing model may refer to the prior art, and will not be described herein.
Step S103: and generating interface automation test codes according to the action keywords and the object keywords.
Step S104: and the running interface automatically tests the code.
Specifically, the technical scheme provided by the embodiment continues to analyze the extracted action keywords and object keywords, converts the description actions of the natural language words into interface automation test codes, for example, constructs a code generation model, trains the constructed code generation model to obtain a trained code generation model, then inputs the action keywords and the object keywords into the code generation model to generate interface automation codes, and finally utilizes the generated codes to perform automation test. On the one hand, the user does not need to write code instructions, but only needs to input test logic according to natural language, so that the writing difficulty of the test case is obviously reduced. In addition, the modification and maintenance of the test cases are easy, and the user only needs to modify the description of the natural language test cases, and does not need to write at the code level. The method solves the problems of low writing efficiency and difficult modification of the automatic test codes, and remarkably improves the flexibility of the automatic test of the interface.
Specifically, in some alternative embodiments, the step S101 includes: acquiring the natural language test case from a case management module, wherein the case management module is used for storing the natural language test case; the specific steps of adding the natural language test case through the case management module comprise:
step a1, receiving an input natural language test case;
step a2, receiving an input use case keyword;
step a3, receiving a marking instruction;
step a4, adding an action label or an object label to the use case keyword in response to the marking instruction;
step a5, receiving an input test method code;
step a6, receiving input parameter symbols;
step a7, packaging the test method codes to obtain a basic test method;
step a8, matching the basic test method with the use case keywords added with the action labels according to the action executed by the basic test method, and determining target keywords;
step a9, establishing an association relationship between a basic test method with consistent action matching and a target keyword;
and a step a10, establishing a one-to-one association relationship between the parameter symbol and each use case keyword added with the object label.
Specifically, in order to further improve the efficiency of the automated test of the interface, the maintenance of the test cases is facilitated. Before the interface automation test is performed, the embodiment also provides a pre-configuration function of the natural language test case, the case keyword and the test method code, and pre-configured contents are stored in the test system.
As shown in FIG. 2, the embodiment of the invention receives various natural language test cases input by a user through the case management module, so that the test cases can be directly obtained and operated from the stored natural language test cases when the test is required. In addition, the tester can also perform operations such as adding, deleting, modifying, checking and the like on the natural language test cases of the interface automatic test through the module. In the embodiment of the invention, the test system also receives the use case keywords input by the user, and maintains various use case keywords input by the user through the use case analysis module. The use case keywords are the description words of the test actions and objects in the natural language, such as the test actions have new, added, modified, deleted words, the test objects such as virtual machines, storage pools and the like, and the configuration of the objects such as virtual machine disks, memories, CPUs and the like.
It should be noted that, in this embodiment, the case keyword input by the user needs to be in the natural language test case, and the natural language test case input by the user also needs to be written according to the saved case keyword, so that the purpose of configuration is that the subsequent steps can quickly achieve extraction of the keyword and detection of the test intention, without collecting a large amount of training data, so that the step of training the natural language neural network model is omitted, and the complexity of the automatic test method is simplified.
In addition, the implementation receives a marking instruction input by a user, and determines whether each case keyword represents a test action or a test object according to the specific meaning corresponding to each preconfigured case keyword by the user, so that an action label or an object label is added for the case keyword in response to the marking instruction, and the marked keyword is stored in a test system. The use case parsing module also takes the work of adding, deleting, modifying and viewing the keyword library.
In addition, the embodiment manages the test method codes and parameter symbols input by the user through the interface code module. The test method code is smaller, basic and simple relative to the complete interface automation test code, and the test method with single test action is realized. The embodiment encapsulates the test method codes to obtain a basic test method, namely an interface of the function codes, so that the actual test can be conveniently invoked. Different basic test methods correspond to different test actions, so that the actual test actions are matched with action labels marked in the steps, and further the different basic test methods can be correlated with target keywords which are input in advance by a user and represent the actions. And establishing a mapping relation.
The parameter symbol refers to the input parameters of each basic test method, the use case keyword added with the object label is a natural language vocabulary, and the use case keyword needs to correspond to the actual parameter symbol to determine what the entry parameter of the function is when the basic test method is called. For example, the method name or parameter name of the corresponding package may be create, delete, modify, VM, storage, disk, memory, cpu or the like. Therefore, the embodiment also matches the parameter symbol preconfigured by the user with the use case keyword representing the object one by one, and establishes the association relation.
Based on the configuration flow, when the code test is carried out, the test system firstly extracts keywords from the natural language test case, then accurately finds out the corresponding method according to the keywords and calls the corresponding method, meanwhile, rapidly determines parameter symbols serving as input parameters according to the keywords, and imports the parameter symbols into the method and executes the method, so that the test is realized, and the accuracy and the generation efficiency of the interface automatic test code can be remarkably improved. The user can build corresponding relation with the keywords by newly adding, modifying and checking the encapsulation method through the interface code module; the module increases the user authority, only opens to the users with authority codes, and prevents common users from generating low-quality codes to interfere with the correctness of the test method.
Specifically, in some optional embodiments, the step S102 includes:
step b1, traversing and extracting the text of the natural language test case according to different word segmentation lengths;
step b2, comparing the extracted text with the saved use case keywords in sequence;
step b3, determining candidate keywords consistent with the comparison of the case keywords from the extracted text;
and b4, dividing the candidate keywords into action keywords and object keywords according to the action tags or the object tags marked by the candidate keywords.
Specifically, when the test is executed, the embodiment firstly extracts texts with different lengths from the natural language test case according to different word segmentation lengths. For example, the natural language test case is "create virtual machine, the virtual machine has two disks", the text extracted by traversing the natural language test case with the word segmentation length 1 includes "create", "subtract", "virtual" …, etc., the text extracted by traversing the word segmentation length 2 includes "create", "create virtual", "virtual" …, etc., and then extracting with the word segmentation length 3 until the word segmentation length 10 is extracted. And then, comparing all the extracted texts with all the case keywords stored in the test system, and judging which texts are completely consistent with the stored case keywords, for example, a large number of case keywords such as 'creation', 'virtual machine', 'disk', 'two', 'start-up', 'judgment' are stored in the embodiment, so that the texts are compared with the stored case keywords one by one, and candidate keywords which are completely consistent in matching in the current natural language test case are found to be 'creation', 'virtual machine', 'disk' and 'two', and as each case keyword is marked with an action label or an object label in advance during storage, the extracted keywords can be accurately divided into the action keywords and the object keywords according to the marked labels. When the test is executed subsequently, the 'one action keyword' + 'one object keyword' = 'one test method', which corresponds to the basic test method and the parameter symbol in the interface code module, ensures the accurate generation of the automatic test code of the interface.
Compared with the training neural network model, the keyword extraction method provided by the embodiment of the invention is simpler and more convenient, does not need to acquire a large amount of training data, avoids the problem of high difficulty in acquiring the training data, and saves training time. Because the basic test method and the saved case keywords provided by the embodiment are in one-to-one correspondence, the keywords are only required to be extracted from the natural language test case in a text complete matching mode, and then the basic test method and the parameter symbols corresponding to the keywords are called to generate test codes, so that the code generation efficiency and the code generation accuracy are remarkably improved. When the keywords of the natural language test cases input by the user are not consistent with the case keywords stored in the system, the user can maintain the keywords through the case analysis module, newly add and modify the case keywords, and the accuracy of the basic test method matching is ensured.
In some alternative embodiments, the step S103 includes:
step c1, matching the extracted action keywords with object keywords to obtain one or more test combinations;
step c2, aiming at the current test combination, calling a current basic test method corresponding to the current action keyword according to the stored association relation;
Step c3, determining a target parameter symbol serving as an input parameter according to the object keywords in the current test combination;
step c4, importing the target parameter symbol into a current basic test method to generate a current test code segment;
step c5, taking the next test combination as a current test combination, and returning to the step of calling a current basic test method corresponding to the current action keyword according to the stored association relation aiming at the current test combination;
and c6, splicing the test code fragments when the test code fragments corresponding to the test combinations are generated, and obtaining the interface automatic test codes.
Specifically, after determining the action keywords and the object keywords in the natural language test case, the embodiment of the invention matches the extracted action keywords and the object keywords according to 'an action keyword' + 'an object keyword' = 'a test method', so as to obtain one or more test combinations. And for each test combination, according to the association relation between the action keywords and the basic test methods stored in the system, calling the current basic test method corresponding to the current action keywords, determining target parameter symbols serving as input parameters by using the object keywords, and adding the corresponding target parameter symbols into the current basic test method, thereby generating the current test code segment corresponding to the current test combination.
After the processing is performed on each test combination, a plurality of test code segments are obtained, and the test code segment corresponding to each test combination is only a single test operation, and for a complete test, the obtained plurality of test code segments are required to be spliced together to generate a complete interface automation test code. According to the scheme provided by the embodiment of the invention, the interface automation test code for testing can be automatically generated only by utilizing the association relation between the keywords and the test method to complete simple matching work. On the one hand, compared with manually writing the use case code, the method provided by the embodiment obviously improves the writing efficiency of the code and reduces the probability of manual writing errors on the premise of ensuring the accuracy of the code. On the other hand, compared with the scheme of automatically generating codes by adopting the neural network model, the method does not need to collect a large amount of training data and perform a long-time complex model training process, is simpler and easier to realize, and ensures the generation efficiency and accuracy of the codes.
In some alternative embodiments, step c1 above includes:
step d1, identifying the sentence breaking of the natural language test case;
And d2, dividing the action keywords and the object keywords belonging to the same sentence breaking into the same test combination from the matching of the extracted action keywords and the object keywords.
Specifically, considering that when the natural language test case is long, a situation that the test combination is matched with an error may occur, for example, the natural language test case is "1", a virtual machine is created, and the created virtual machine includes two disks; 2. and starting the virtual machine. By way of example, all test combinations generated may include: "create virtual machine", "create two disks", "open virtual machine", "open two disks", it can be found that "open two disks" does not belong to an achievable method, a disk cannot be opened, and two disks only create input parameters of the virtual machine. In order to avoid the occurrence of such test combinations as much as possible, the embodiment improves the accuracy of test code generation. And (3) optimizing the natural language test case to a certain extent, and creating a corresponding test combination by taking the sentence breaking of the natural language test case as a standard. For example: the virtual machine is created to belong to one sentence breaking, the created virtual machine comprises two disks belonging to one sentence breaking, the virtual machine is started to belong to one sentence breaking, and for each sentence breaking, after keywords are extracted, action keywords and object keywords in the same test combination can only belong to the same sentence breaking, and keywords of different sentence breaking cannot be matched to the same test combination, for example, the two disks cannot be combined, so that the probability of occurrence of an error test combination is reduced, and the error probability of an interface automation test code is further reduced.
In some alternative embodiments, step c6 above includes:
step e1, checking whether the basic test method in each test code segment can process the corresponding input parameters.
And e2, deleting the test code segment which is detected as the test code segment incapable of processing the corresponding input parameters.
And e3, arranging the splicing sequence of each test code segment according to the input parameters in each test code segment.
And e4, splicing the test code fragments according to the splicing sequence.
Specifically, in order to further improve the accuracy of the generated interface automation test code, the present embodiment further deploys an automatic checking mechanism before testing to reduce the occurrence of erroneous test combinations. Such as "open two disks" in the previous embodiments. According to the embodiment, whether the basic test method in each test code segment can process the corresponding input parameters is checked, then the test code segment with the check result that the corresponding input parameters cannot be processed is deleted, so that the accuracy of the test code segment is improved, for example, two magnetic discs are used as input parameters to be input into the basic test method corresponding to the opening, the fact that the basic test method cannot identify the parameters such as the two magnetic discs can be found, the basic test method cannot operate can also occur, and for the situation, the current test combination is judged to be the wrong combination, and the current test code segment is correspondingly deleted, so that the accuracy of the interface automatic test code generated by subsequent splicing is improved.
In addition, in this embodiment, the splicing order of the test code segments is further arranged according to the execution action in each test code segment, for example, the "create" action is defined before "power on", and if the "power on" test code segment is spliced to the "create" test code segment during splicing, the generated interface automation test code will also be misplaced during runtime. Thereby further improving the accuracy of the interface automation test code through the scheme.
In some optional implementations, an automated interface testing method provided by an embodiment of the present invention further includes, before step S104:
and f1, displaying interface automation test codes in an editable program window.
And f2, receiving an input modification instruction.
And f3, adjusting the interface automation test code in response to the modification instruction.
In particular, considering that some tiny errors can exist in the interface automatic test code generated by the machine, the embodiment of the invention also displays the interface automatic test code in an editable program window when the interface automatic test code is generated, so that a user can conveniently check whether the error exists manually and manually fine-tune again, and the accuracy of the interface automatic test code is further improved. After the manual inspection is completed, the test task is executed, so that the reliability of the test result is further improved.
In addition, in some optional implementations, the test system provided by the embodiment of the invention further includes a test code module, the test code after the user checks is saved, and the saved test code and the natural language test case input by the user also establish an association relationship, so that the next test can be directly reused. When the stored test codes are manually modified by the user, the test code module synchronously updates the stored test codes, so that the flexibility of the test system is further improved.
In order to facilitate understanding of the present solution, as shown in fig. 3, a specific implementation procedure of the method for automatically testing an interface provided by the embodiment of the present invention is described below in a specific embodiment:
1. the testers design automation uses such as: "create a virtual machine, the virtual machine has two disks, start the virtual machine";
2. inputting a test system, wherein the test system stores the use case;
3. the system analyzes the use case, and identifies keywords, namely "create", "virtual machine", "two disks", "start", wherein the keywords "create", "start" correspond to operations, and "virtual machine", "two disks" correspond to objects. The generated test combination includes: "create virtual machine", "virtual machine power on" and create two disks ". The virtual machine is created and the virtual machine is started corresponding to the virtual machine operation, for example, the called basic test methods are createVM and powerOnVM, and the two disks correspond to the virtual machine configuration diskNum, and the parameter value is 2, so that the virtual machine operation can be used as the input parameter of createVM;
4. Calling the packaged test methods createVM (diskNum 2) and vmPowerOn according to the keywords, and generating an interface automation test code according to the steps;
5. the code is output, so that the test personnel can check the code conveniently, the manual change of the test personnel is supported, the code can be saved without errors, and the code is associated with the use case;
6. running codes and finishing the test;
7. if the automatic test case needs to be maintained, generating codes again after modifying the case;
in this embodiment, an automatic interface testing device is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and will not be described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The embodiment provides an automatic interface testing device, as shown in fig. 4, including:
the test case acquisition module 401 is configured to acquire a natural language test case. For details, refer to the related description of step S101 in the above method embodiment, and no further description is given here.
The keyword extraction module 402 is configured to identify an action keyword and an object keyword in a natural language test case, where the action keyword represents an executed test action, and the object keyword represents a test object to which the test action is applied. For details, refer to the related description of step S102 in the above method embodiment, and no further description is given here.
The code generating module 403 is configured to generate an interface automation test code according to the action keyword and the object keyword. For details, see the description of step S103 in the above method embodiment, and the details are not repeated here.
And the test module 404 is used for running the interface automation test code to test. For details, refer to the related description of step S104 in the above method embodiment, and no further description is given here.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The interface automation test device in this embodiment is in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit ) circuit, a processor and memory executing one or more software or fixed programs, and/or other devices that can provide the above functions.
The embodiment of the invention also provides computer equipment, which is provided with the interface automatic testing device shown in the figure 4.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, as shown in fig. 5, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 5.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform a method for implementing the embodiments described above.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.

Claims (10)

1. An automated interface testing method, for use in a testing system, the method comprising:
acquiring a natural language test case;
identifying action keywords and object keywords in the natural language test case, wherein the action keywords represent executed test actions, and the object keywords represent test objects applying the test actions;
generating interface automation test codes according to the action keywords and the object keywords;
and running the interface automation test code to test.
2. The method of claim 1, wherein the obtaining the natural language test case comprises: acquiring the natural language test case from a case management module, wherein the case management module is used for storing the natural language test case; the step of adding the natural language test case through the case management module comprises the following steps:
Receiving the input natural language test case;
receiving an input use case keyword;
receiving a marking instruction;
adding an action tag or an object tag to the use case keyword in response to the marking instruction;
receiving an input test method code;
receiving an input parameter symbol;
packaging the test method codes to obtain a basic test method;
matching the basic test method with the use case keywords added with the action labels according to the action executed by the basic test method, and determining target keywords;
establishing an association relation between the basic test method with consistent action matching and the target keyword;
and establishing a one-to-one association relation between the parameter symbol and each use case keyword added with the object label.
3. The method of claim 2, wherein the identifying action keywords and object keywords in the natural language test case comprises:
traversing and extracting the text of the natural language test case according to different word segmentation lengths;
sequentially comparing the extracted text with the stored use case keywords;
determining candidate keywords consistent with the use case keyword comparison from the extracted text;
And dividing the candidate keywords into the action keywords and the object keywords according to the action tags or the object tags marked by the candidate keywords.
4. The method of claim 2, wherein the generating interface automation test code from the action keywords and the object keywords comprises:
matching the extracted action keywords with the object keywords to obtain one or more test combinations;
aiming at the current test combination, calling a current basic test method corresponding to the current action keyword according to the stored association relation;
determining a target parameter symbol serving as an input parameter according to the object keyword in the current test combination;
importing the target parameter symbol into the current basic test method to generate a current test code segment;
returning the next test combination as the current test combination to the step of calling a current basic test method corresponding to the current action keyword according to the saved association relation aiming at the current test combination;
and when the generation of the test code segments corresponding to each test combination is finished, splicing each test code segment to obtain the interface automatic test code.
5. The method of claim 4, wherein said matching the extracted action keywords with the object keywords results in one or more test combinations comprising:
identifying the sentence breaking of the natural language test case;
and dividing the action keywords and the object keywords belonging to the same sentence breaking into the same test combination from the extracted action keywords and the object keywords for matching.
6. The method of claim 4, wherein the concatenating each test code segment comprises:
checking whether the basic test method in each test code segment can process the corresponding input parameters;
deleting the test code segment of which the checking result is that the corresponding input parameter cannot be processed;
arranging the splicing sequence of each test code segment according to the execution action in each test code segment;
and splicing all the test code fragments according to the splicing sequence.
7. The method of claim 1, wherein prior to said running the interface automation test code for testing, the method further comprises:
displaying the interface automation test code in an editable program window;
Receiving an input modification instruction;
and adjusting the interface automation test code in response to the modification instruction.
8. An automated interface testing apparatus for use with a testing system, the apparatus comprising:
the test case acquisition module is used for acquiring a natural language test case;
the keyword extraction module is used for identifying action keywords and object keywords in the natural language test case, wherein the action keywords represent executed test actions, and the object keywords represent test objects applying the test actions;
the code generation module is used for generating interface automation test codes according to the action keywords and the object keywords;
and the test module is used for running the interface automation test code to test.
9. A computer device, comprising:
a memory and a processor in communication with each other, the memory having stored therein computer instructions which, upon execution, cause the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of any one of claims 1 to 7.
CN202311257652.9A 2023-09-26 2023-09-26 Automatic interface testing method and device, computer equipment and storage medium Pending CN117312148A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311257652.9A CN117312148A (en) 2023-09-26 2023-09-26 Automatic interface testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311257652.9A CN117312148A (en) 2023-09-26 2023-09-26 Automatic interface testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117312148A true CN117312148A (en) 2023-12-29

Family

ID=89286108

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311257652.9A Pending CN117312148A (en) 2023-09-26 2023-09-26 Automatic interface testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117312148A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573567A (en) * 2024-01-17 2024-02-20 易方信息科技股份有限公司 Method and related device for automatically generating UI (user interface) automation test cases

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573567A (en) * 2024-01-17 2024-02-20 易方信息科技股份有限公司 Method and related device for automatically generating UI (user interface) automation test cases
CN117573567B (en) * 2024-01-17 2024-05-17 易方信息科技股份有限公司 Method and related device for automatically generating UI (user interface) automation test cases

Similar Documents

Publication Publication Date Title
US10642721B2 (en) Generation of automated testing scripts by converting manual test cases
KR20190026641A (en) Method of character recognition of claims document, apparatus, server and storage medium
US20160132421A1 (en) Adaptation of automated test scripts
CN111382070B (en) Compatibility testing method and device, storage medium and computer equipment
CN105335282A (en) Method and system for cross-platform test of applications
US11176019B2 (en) Automated breakpoint creation
US8745521B2 (en) System and method for annotating graphical user interface
CN117312148A (en) Automatic interface testing method and device, computer equipment and storage medium
WO2014115189A1 (en) Method and system for transforming specification scripts to program code
CN112764784A (en) Automatic software defect repairing method and device based on neural machine translation
CN113778898A (en) User interface automatic testing method and device, electronic equipment and storage medium
EP4364044A1 (en) Automated troubleshooter
CN114048129A (en) Automatic testing method, device, equipment and system for software function change
CN109614325B (en) Method and device for determining control attribute, electronic equipment and storage medium
CN117421217A (en) Automatic software function test method, system, terminal and medium
CN117113080A (en) Data processing and code processing method, device, all-in-one machine and storage medium
CN109684207B (en) Method and device for packaging operation sequence, electronic equipment and storage medium
CN107077365A (en) Selectively load the head and/or its part of precompile
CN115905016A (en) BIOS Setup search function test method and device, electronic equipment and storage medium
CN108984386A (en) Test method, device and the storage medium of application program search
CN112989256B (en) Method and device for identifying web fingerprint in response information
CN113918165A (en) Method and system for compiling text description type flow description into application automatic operation script
CN114064010A (en) Front-end code generation method, device, system and storage medium
CN112749079A (en) Defect classification method and device for software test and computing equipment
CN116991734A (en) Test environment deployment method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination