[go: up one dir, main page]

CN113495831B - Method, system, equipment and medium for generating test case based on keywords - Google Patents

Method, system, equipment and medium for generating test case based on keywords Download PDF

Info

Publication number
CN113495831B
CN113495831B CN202010260011.9A CN202010260011A CN113495831B CN 113495831 B CN113495831 B CN 113495831B CN 202010260011 A CN202010260011 A CN 202010260011A CN 113495831 B CN113495831 B CN 113495831B
Authority
CN
China
Prior art keywords
interface
test
groups
data
tested
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.)
Active
Application number
CN202010260011.9A
Other languages
Chinese (zh)
Other versions
CN113495831A (en
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.)
Winning Health Technology Group Co Ltd
Original Assignee
Winning Health Technology Group 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 Winning Health Technology Group Co Ltd filed Critical Winning Health Technology Group Co Ltd
Priority to CN202010260011.9A priority Critical patent/CN113495831B/en
Publication of CN113495831A publication Critical patent/CN113495831A/en
Application granted granted Critical
Publication of CN113495831B publication Critical patent/CN113495831B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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 discloses a method, a system, equipment and a medium for generating test cases based on keywords. The method comprises the following steps: presetting a plurality of groups of keyword data; presetting a plurality of groups of test data; acquiring interface information of an interface to be tested; screening the multiple groups of key word data according to the interface information to obtain multiple groups of target key word data; screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data; and generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data. The invention adopts the keyword-driven automatic test framework to preset a plurality of groups of keyword data and test data, so that a plurality of groups of keyword data and test data for generating a plurality of test cases in a combined way can be obtained by screening according to the interface information of the interface to be tested, thereby reducing the labor cost and the time cost required by generating the test cases, and further improving the API automatic test efficiency and test quality.

Description

Method, system, equipment and medium for generating test case based on keywords
Technical Field
The invention relates to the technical field of automatic testing, in particular to a method, a system, equipment and a medium for generating test cases based on keywords.
Background
Currently, API (Application Programming Interface ) automated testing generally includes: the method comprises five stages of demand analysis, case design, test case maintenance, test case execution and result analysis, wherein the demand analysis and the case design are generally completed manually and cannot be automatically realized based on an automatic test tool, the test case maintenance, the test case execution and the result analysis are generally realized based on the automatic test tool so as to save the time of test execution, but the test case maintenance is still completed manually. Therefore, in the current implementation of API automation test, the design and maintenance of the test cases are manually completed, so that higher manpower cost and time cost are required.
Disclosure of Invention
The invention aims to overcome the defect that test cases of API automatic test cannot be automatically generated in the prior art, and provides a method, a system, equipment and a medium for generating test cases based on keywords.
The invention solves the technical problems by the following technical scheme:
A method for generating test cases based on keywords, comprising:
Presetting a plurality of groups of key word data, wherein each group of key word data comprises a key word name, an interface application range and interface service logic, and the interface application range comprises an interface function type and an entry attribute;
presetting a plurality of groups of test data, wherein each group of test data comprises a parameter entry attribute and a parameter entry value;
acquiring interface information of an interface to be tested, wherein the interface information comprises an interface function type and an entry attribute;
screening the multiple groups of key word data according to the interface information to obtain multiple groups of target key word data;
screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data;
And generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data.
Preferably, after the step of generating a plurality of test cases according to the plurality of sets of target keyword data and the plurality of sets of target test data, the method further comprises:
judging whether the interface information of the interface to be tested needs to be changed or not;
If yes, firstly changing the interface information of the interface to be tested, and then executing the step of obtaining the interface information of the interface to be tested to obtain the interface information after the interface to be tested is changed;
and/or the number of the groups of groups,
Judging whether a newly added interface to be tested is needed;
If yes, the interface to be tested is newly added, and then the step of obtaining the interface information of the interface to be tested is executed to obtain the interface information of the newly added interface to be tested.
Preferably, after the step of generating a plurality of test cases according to the plurality of sets of target keyword data and the plurality of sets of target test data, the method further comprises:
And testing the interface to be tested according to the test cases.
Preferably, the step of presetting a plurality of sets of keyword data includes:
presetting a plurality of groups of keyword data according to an interface test case design method;
and/or the number of the groups of groups,
The step of generating a plurality of test cases according to the plurality of sets of target keyword data and the plurality of sets of target test data comprises the following steps:
representing the interface information by using a custom parameter;
generating a variable file according to the interface information expressed by the parameters and the target test data of the groups;
and generating a plurality of test cases according to the target keyword data and the variable file.
A system for generating test cases based on keywords, comprising:
The first presetting module is used for presetting a plurality of groups of keyword data, wherein each group of keyword data comprises a keyword name, an interface application range and interface service logic, and the interface application range comprises an interface function type and an entry attribute;
The second preset module is used for presetting a plurality of groups of test data, wherein each group of test data comprises a parameter attribute and a parameter value;
the acquisition module is used for acquiring interface information of the interface to be detected, wherein the interface information comprises an interface function type and a parameter entering attribute;
the first screening module is used for screening the multiple groups of keyword data according to the interface information to obtain multiple groups of target keyword data;
the second screening module is used for screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data;
and the generating module is used for generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data.
Preferably, the system further comprises:
the first judging module is used for judging whether the interface information of the interface to be tested needs to be changed or not;
If yes, firstly calling a changing module, wherein the changing module is used for changing the interface information of the interface to be tested, and then calling the obtaining module to obtain the interface information after the interface to be tested is changed;
and/or the number of the groups of groups,
The second judging module is used for judging whether a new interface to be tested needs to be added;
if yes, a new adding module is called, the new adding module is used for adding the interface to be tested, and then the obtaining module is called to obtain the interface information of the newly added interface to be tested.
Preferably, the system further comprises:
And the test module is used for testing the interface to be tested according to the test cases.
Preferably, the first preset module is specifically configured to preset a plurality of groups of keyword data according to an interface test case design method;
and/or the number of the groups of groups,
The generation module comprises:
the custom parameter unit is used for representing the interface information by using custom parameters;
The first generation unit is used for generating a variable file according to the interface information expressed by the parameters and the plurality of groups of target test data;
And the second generating unit is used for generating a plurality of test cases according to the plurality of groups of target keyword data and the variable file.
An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing any one of the above methods of generating test cases based on keywords when executing the computer program.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs any of the steps of the method of generating test cases based on keywords described above.
The invention has the positive progress effects that: the invention adopts the keyword-driven automatic test framework to preset a plurality of groups of keyword data and test data, so that a plurality of groups of keyword data and test data for generating a plurality of test cases in a combined way can be obtained by screening according to the interface information of the interface to be tested, thereby reducing the labor cost and the time cost required by generating the test cases, and further improving the API automatic test efficiency and test quality.
Drawings
FIG. 1 is a flowchart of a method for generating test cases based on keywords according to embodiment 1 of the present invention.
Fig. 2 is a schematic block diagram of a system for generating test cases based on keywords according to embodiment 2 of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to embodiment 3 of the present invention.
Detailed Description
The invention is further illustrated by means of the following examples, which are not intended to limit the scope of the invention.
Example 1
The embodiment provides a method for generating a test case based on keywords, and referring to fig. 1, the method of the embodiment includes:
S1, presetting a plurality of groups of keyword data.
In this embodiment, multiple sets of keyword data may be preset according to an interface test case design method by means of an automatic test platform, where each set of keyword data corresponds to an interface test scene, and the interface test case design method may include, for example: equivalence class classification, boundary value analysis, scene analysis, causal graph, orthogonal table, etc.
In this embodiment, each set of keyword data may include a keyword name, an interface application range, and interface business logic. The interface application scope is used for limiting an interface which corresponds to the keyword name and meets specific requirements, the interface which is suitable for the keyword name can be limited through interface function types, parameter entering attributes and the like, and the interface business logic can be used for describing functions corresponding to the keyword name.
In this embodiment, taking the interface to be tested as an API as an example, the interface to be tested is divided according to the interface function type of the interface to be tested, and the API may include, but is not limited to, get interface, delete interface, disable interface, query interface, search interface, and the like. In this embodiment, the parameter attribute may include a parameter entry number, where the parameter entry number may be used to define that the interface to be tested has a parameter entry or has no parameter entry, for example, the parameter entry number may be 0 and may indicate that the interface to be tested has no parameter entry, and the parameter entry number may be other than 0. Further, in this embodiment, when the interface to be tested has the parameter entry, the parameter entry attribute may further include whether the parameter entry includes a filling item, and so on. In addition, in this embodiment, when the interface to be tested has an entry, the entry attribute may further include an entry value type, and the entry value type may specifically include a data type (for example, integer type, character type, etc.) of the entry value.
In this embodiment, the plurality of sets of keyword data may be reused a plurality of times after being preset, and specifically, a list formed by the plurality of sets of keyword data may be referred to in table 1.
Table 1: keyword data list
S2, presetting a plurality of groups of test data.
In this embodiment, multiple sets of test data may be preset depending on the automated test platform, where each set of test data may include a parameter entry attribute and a parameter entry value, and the parameter entry attribute may specifically include a parameter entry type, a parameter entry value range, and the like, and each set of test data may further include a parameter entry value description.
In this embodiment, on the basis that the entry parameter type may include a data type of the entry parameter, the entry parameter type may be further divided according to whether the entry parameter is a fixed value or a value taken from the database, where the entry parameter type may include a valid type (indicating that the data type of the entry parameter is correct and does not exceed the entry parameter range), an invalid type (indicating that the data type of the entry parameter is correct but exceeds the entry parameter range), and an error type (indicating that the data type of the entry parameter is incorrect), and the entry parameter type is a valid type when the entry parameter is taken from the database.
In this embodiment, the multiple sets of test data may be reused multiple times after being preset, and specifically, when the data type of the input parameter is an integer, the list formed by the multiple sets of test data may be referred to in table 2.
Table 2: test data list
S3, obtaining interface information of the interface to be tested.
In this embodiment, the interface information may include an interface function type and an entry attribute. In this embodiment, let url of the interface to be tested be: the service function corresponding to the interface to be tested is to take out a corresponding code value list according to a concept, wherein the concept has a fixed corresponding relation with the code value list on the service, based on the fact, the interface function type of the interface to be tested is a query interface, and the entry at least comprises a filling-in field conceptid, namely, the interface to be tested has the entry and the entry comprises the filling-in item. Specifically, the entry of the interface to be tested may include conceptid and the encoding status of the next stage as conceptid, and the entry attribute of the exemplary interface to be tested may be referred to in table 3.
Table 3: parameter entry attribute of interface to be tested
Parameter entry type Whether or not to fill Description of entering into the Ginseng
integer Whether or not Coding state
integer Is that Conceptid, the upper level of coding
And S4, screening the plurality of groups of key word data according to the interface information to obtain a plurality of groups of target key word data.
In this embodiment, the automatic test platform may be relied on to screen the multiple sets of keyword data preset in step S1. For example, as shown in table 1, url of the interface to be tested is: when the interface to be tested accords with the interface application range of/api/v 1/base/codevalue/query/by_ conceptid, the interface application range includes: the interface with the entry, the interface with the entry value type being an integer, the interface with the entry of the necessary entry and the interface with the action type being query and search, so that a plurality of groups of target keyword data obtained by screening table 1 can be determined to comprise: the correct parameter entering communication is successful, the parameter entering value type is wrong, the parameter entering is null, the parameter entering lacks the necessary filling item, and the record number returned by the interface is verified.
And S5, screening multiple groups of test data according to the interface information to obtain multiple groups of target test data.
In this embodiment, the automatic test platform may be relied on to screen the multiple sets of test data preset in step S2. For example, url of the interface to be tested is: when in the process of/api/v 1/base/codevalue/query/by_ conceptid, the target test data hypothesis obtained by screening the test data list (table 2) according to the parameter entry attribute (table 3) of the parameter entry coding state of the interface to be tested is shown in table 4, and the target test data hypothesis obtained by screening the test data list (table 2) according to the parameter entry attribute (table 3) of the parameter entry conceptid of the interface to be tested is shown in table 5.
Table 4: target test data corresponding to coding state
Parameter entry type Parameter input value Description of the entry parameter
Fixed value, effective 0 The value of the input parameter is fixed and effective
Fixed value, invalid 999 The value of the entry is out-of-range invalid
Fixed value, error type “abc” The value of this entry is the error type
Table 5: conceptid corresponding target test data
S6, generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data.
In this embodiment, the plurality of sets of target keyword data obtained in the step S4 and the plurality of sets of target test data obtained in the step S5 may be combined by means of an automated test platform to generate a test case, where one set of target keyword data and one set of target test data may be combined to generate one test case, and the plurality of test cases generated in this embodiment form a test case file.
Further, in this embodiment, in order to facilitate decoupling of the test case file from the test data, that is, to facilitate the test case file to be used in different test environments after adjustment of the test data, the interface information may be designed by using parameterization. Specifically, the request address, the request header, and the request data (i.e., the parameter entry data) of the interface to be tested may be set by using parameterization, for example, a parameter url characterizing the request address, a parameter header characterizing the request header, a parameter codeStatus characterizing the encoding state, and a parameter conceptId characterizing conceptid may be customized to generate variable files, and these variable files may be used to generate test cases, so that decoupling of the test case files from the test data may be achieved.
In this embodiment, step S6 may specifically include: the method comprises the steps of representing interface information by using self-defined parameters, generating variable files according to the interface information represented by the parameters and a plurality of groups of target test data, and generating a plurality of test cases according to a plurality of groups of target keyword data and the variable files.
Further, in the testing process of the interface to be tested, the same reference needs to be tested by using different reference values, in this embodiment, different numerical numbers may be added after the reference name to represent different values of the same reference, so that the formed parameterized target test data may refer to table 6:
table 6: parameterized target test data
In this embodiment, when a robot frame is selected as an automation test frame in the automation test platform, the generated variable file variable.
1.***Variables***
The variable $ { url }/api/v1/base/codevalue/query/by_ conceptid # is the url of the interface
3.&{header}Content-Type=application/json
The = $ codeStatus # 1 interface goes into the parameter, codeStatus correct value (taking the preset valid value)
The = $ codeStatus2# 2 interface with = $ codeStatus # -codeStatus _ wrong1} -codeStatus =, codeStatus out of range values are invalid
The = $ codeStatus3# 3 interface goes into the parameter = { codeStatus _ wrong2} codeStatus = $ codeStatus value type error
The & { conceptId _right } conceptId = $ conceptId3# interface involves conceptId correct value (taking preset valid value randomly from data)
& { ConceptId _ wrong } conceptId = $ conceptId4# 4 interface entry, conceptId value type error
When a robot frame work is selected as an automation test frame in an automation test platform, a test case file testcase generated using a variable file variable.
1.***Test Cases***
2.${url}Create Dictionary/api/v1/base/codevalue/query/by_conceptid
The value of $ conceptId exec sql $ conceptId #3 preset variable conceptId3 from the database requires linking the database values
4. Correct call-in communication success $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId1} # call-in value is taken from a preset variable
5. Correct call-in communication success $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId3} # call-in value is taken from a preset variable
6. The entry is null error reporting $ { url } $ { header } { } # the entry is null
7. Parameter-in type error report error $ { url $ { header } { "codeStatus": $ codeStatus3, "conceptId": $ conceptId3} # parameter-in value is taken from a preset variable, $ codeStatus3 is an error value
8. Parameter-in type error report error $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId4} # parameter-in value is taken from a preset variable, $ conceptId4 is the error type value
9. The parameter entering lack of necessary-filling item reporting error $ { url $ { header } { "codeStatus": $ codeStatus1} # the parameter entering value is taken from a preset variable, $ conceptId is the necessary-filling item
10. The record number ${url}${header}{"codeStatus":$codeStatus1,"conceptId":$conceptId1}select count(*)from codevalue where conceptId=$conceptId1 and"codestatus"=${codeStatus1}# returned by the verification interface is taken from the preset variable, and $ conceptId is the necessary entry
In the test case file, each row where the keyword is located represents one test case, and for example, lines 4 to 10 of the test case file represent 7 test cases in total.
S7, testing the interface to be tested according to a plurality of test cases.
In this embodiment, the automatically generated test cases may run directly in the corresponding automated test framework. For example, when a robot frame work is selected as the automation test framework, the generated test case code is a robot frame work code, and may be directly run on the robot frame work framework. The same is true for keywords included in the test cases and test data used in the test cases.
In addition, in this embodiment, the parameter output of the interface to be tested may be used to verify the test result. For example, url of the interface to be tested is: when the interface to be tested is/api/v 1/base/codevalue/query/by_ conceptid, the parameters of the interface to be tested may include boolean type parameter success and integer type parameter count (which may be used to represent the total number of compliance).
In this embodiment, the method may further include a step of determining whether to change interface information of the interface to be tested, if so, changing the interface information of the interface to be tested first, then executing step S3 to obtain the interface information after the interface to be tested is changed, then executing step S4 and step S5 to obtain a plurality of sets of target keyword data and a plurality of sets of target test data by screening respectively according to the changed interface information, and finally, executing step S6 to regenerate a plurality of test cases according to the plurality of sets of target keyword data and the target test data obtained by re-screening, so as to realize automatic change of the test cases, and further realize maintenance of the test cases.
In this embodiment, the method may further include a step of determining whether a new interface to be tested is needed, if so, the new interface to be tested is added first, then step S3 is performed to obtain interface information of the new interface to be tested, then step S4 and step S5 are performed to obtain a plurality of sets of target keyword data and a plurality of sets of target test data by screening according to the interface information of the new interface to be tested, and finally step S6 is performed to regenerate a plurality of test cases according to the plurality of sets of target keyword data and the target test data obtained by screening, so as to realize automatic new addition of the test cases, and further realize maintenance of the test cases.
According to the embodiment, the keyword-driven automatic test framework is adopted, multiple groups of keyword data and test data are preset, and then multiple groups of keyword data and test data for generating multiple test cases in a combined mode can be obtained through screening according to interface information of an interface to be tested, so that labor cost and time cost required by design and maintenance of the test cases can be reduced, and API automatic test efficiency and test quality can be improved.
Example 2
The present embodiment provides a system for generating a test case based on a keyword, referring to fig. 2, the system of the present embodiment includes:
The first preset module 1 is used for presetting a plurality of groups of keyword data.
In this embodiment, multiple sets of keyword data may be preset according to an interface test case design method by means of an automatic test platform, where each set of keyword data corresponds to an interface test scene, and the interface test case design method may include, for example: equivalence class classification, boundary value analysis, scene analysis, causal graph, orthogonal table, etc.
In this embodiment, each set of keyword data may include a keyword name, an interface application range, and interface business logic. The interface application scope is used for limiting an interface which corresponds to the keyword name and meets specific requirements, the interface which is suitable for the keyword name can be limited through interface function types, parameter entering attributes and the like, and the interface business logic can be used for describing functions corresponding to the keyword name.
In this embodiment, taking the interface to be tested as an API as an example, the interface to be tested is divided according to the interface function type of the interface to be tested, and the API may include, but is not limited to, get interface, delete interface, disable interface, query interface, search interface, and the like. In this embodiment, the parameter attribute may include a parameter entry number, where the parameter entry number may be used to define that the interface to be tested has a parameter entry or has no parameter entry, for example, the parameter entry number may be 0 and may indicate that the interface to be tested has no parameter entry, and the parameter entry number may be other than 0. Further, in this embodiment, when the interface to be tested has the parameter entry, the parameter entry attribute may further include whether the parameter entry includes a filling item, and so on. In addition, in this embodiment, when the interface to be tested has an entry, the entry attribute may further include an entry value type, and the entry value type may specifically include a data type (for example, integer type, character type, etc.) of the entry value.
In this embodiment, the plurality of sets of keyword data may be reused a plurality of times after being preset, and specifically, a list formed by the plurality of sets of keyword data may be referred to in table 1.
Table 1: keyword data list
The second preset module 2 is used for presetting a plurality of groups of test data.
In this embodiment, multiple sets of test data may be preset depending on the automated test platform, where each set of test data may include a parameter entry attribute and a parameter entry value, and the parameter entry attribute may specifically include a parameter entry type, a parameter entry value range, and the like, and each set of test data may further include a parameter entry value description.
In this embodiment, on the basis that the entry parameter type may include a data type of the entry parameter, the entry parameter type may be further divided according to whether the entry parameter is a fixed value or a value taken from the database, where the entry parameter type may include a valid type (indicating that the data type of the entry parameter is correct and does not exceed the entry parameter range), an invalid type (indicating that the data type of the entry parameter is correct but exceeds the entry parameter range), and an error type (indicating that the data type of the entry parameter is incorrect), and the entry parameter type is a valid type when the entry parameter is taken from the database.
In this embodiment, the multiple sets of test data may be reused multiple times after being preset, and specifically, when the data type of the input parameter is an integer, the list formed by the multiple sets of test data may be referred to in table 2.
Table 2: test data list
And the acquisition module 3 is used for acquiring interface information of the interface to be tested.
In this embodiment, the interface information may include an interface function type and an entry attribute. In this embodiment, let url of the interface to be tested be: the service function corresponding to the interface to be tested is to take out a corresponding code value list according to a concept, wherein the concept has a fixed corresponding relation with the code value list on the service, based on the fact, the interface function type of the interface to be tested is a query interface, and the entry at least comprises a filling-in field conceptid, namely, the interface to be tested has the entry and the entry comprises the filling-in item. Specifically, the entry of the interface to be tested may include conceptid and the encoding status of the next stage as conceptid, and the entry attribute of the exemplary interface to be tested may be referred to in table 3.
Table 3: parameter entry attribute of interface to be tested
Parameter entry type Whether or not to fill Description of entering into the Ginseng
integer Whether or not Coding state
integer Is that Conceptid, the upper level of coding
The first screening module 4 is configured to screen the multiple sets of keyword data according to the interface information to obtain multiple sets of target keyword data.
In this embodiment, the automatic test platform may be relied on to screen the plurality of sets of keyword data preset by the first preset module 1. For example, as shown in table 1, url of the interface to be tested is: when the interface to be tested accords with the interface application range of/api/v 1/base/codevalue/query/by_ conceptid, the interface application range includes: the interface with the entry, the interface with the entry value type being an integer, the interface with the entry of the necessary entry and the interface with the action type being query and search, so that a plurality of groups of target keyword data obtained by screening table 1 can be determined to comprise: the correct parameter entering communication is successful, the parameter entering value type is wrong, the parameter entering is null, the parameter entering lacks the necessary filling item, and the record number returned by the interface is verified.
And the second screening module 5 is used for screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data.
In this embodiment, the automatic test platform may be relied on to screen multiple sets of test data preset by the second preset module 2. For example, url of the interface to be tested is: when in the process of/api/v 1/base/codevalue/query/by_ conceptid, the target test data hypothesis obtained by screening the test data list (table 2) according to the parameter entry attribute (table 3) of the parameter entry coding state of the interface to be tested is shown in table 4, and the target test data hypothesis obtained by screening the test data list (table 2) according to the parameter entry attribute (table 3) of the parameter entry conceptid of the interface to be tested is shown in table 5.
Table 4: target test data corresponding to coding state
Parameter entry type Parameter input value Description of the entry parameter
Fixed value, effective 0 The value of the input parameter is fixed and effective
Fixed value, invalid 999 The value of the entry is out-of-range invalid
Fixed value, error type “abc” The value of this entry is the error type
Table 5: conceptid corresponding target test data
And the generating module 6 is used for generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data.
In this embodiment, the plurality of sets of target keyword data obtained by the first screening module 4 and the plurality of sets of target test data obtained by the second screening module 5 may be combined by means of an automated test platform to generate a test case, where one set of target keyword data and one set of target test data may be combined to generate one test case, and the plurality of test cases generated in this embodiment form a test case file.
Further, in this embodiment, in order to facilitate decoupling of the test case file from the test data, that is, to facilitate the test case file to be used in different test environments after adjustment of the test data, the interface information may be designed by using parameterization. Specifically, the request address, the request header, and the request data (i.e., the parameter entry data) of the interface to be tested may be set by using parameterization, for example, a parameter url characterizing the request address, a parameter header characterizing the request header, a parameter codeStatus characterizing the encoding state, and a parameter conceptId characterizing conceptid may be customized to generate variable files, and these variable files may be used to generate test cases, so that decoupling of the test case files from the test data may be achieved.
Referring to fig. 2, the generating module 6 may specifically include a custom parameter unit 61, a first generating unit 62, and a second generating unit 63, where the custom parameter unit 61 is configured to use the custom parameter to represent interface information, the first generating unit 62 is configured to generate a variable file according to the interface information represented by the custom parameter and a plurality of sets of target test data, and the second generating unit 63 is configured to generate a plurality of test cases according to a plurality of sets of target keyword data and the variable file.
Further, in the testing process of the interface to be tested, the same reference needs to be tested by using different reference values, in this embodiment, different numerical numbers may be added after the reference name to represent different values of the same reference, so that the formed parameterized target test data may refer to table 6:
table 6: parameterized target test data
In this embodiment, when a robot frame is selected as an automation test frame in the automation test platform, the generated variable file variable.
1.***Variables***
The variable $ { url }/api/v1/base/codevalue/query/by_ conceptid # is the url of the interface
3.&{header}Content-Type=application/json
The = $ codeStatus # 1 interface goes into the parameter, codeStatus correct value (taking the preset valid value)
The = $ codeStatus2# 2 interface with = $ codeStatus # -codeStatus _ wrong1} -codeStatus =, codeStatus out of range values are invalid
The = $ codeStatus3# 3 interface goes into the parameter = { codeStatus _ wrong2} codeStatus = $ codeStatus value type error
The & { conceptId _right } conceptId = $ conceptId3# interface involves conceptId correct value (taking preset valid value randomly from data)
& { ConceptId _ wrong } conceptId = $ conceptId4# 4 interface entry, conceptId value type error
When a robot frame work is selected as an automation test frame in an automation test platform, a test case file testcase generated using a variable file variable.
1.***Test Cases***
2.${url}Create Dictionary/api/v1/base/codevalue/query/by_conceptid
The value of $ conceptId exec sql $ conceptId #3 preset variable conceptId3 from the database requires linking the database values
4. Correct call-in communication success $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId1} # call-in value is taken from a preset variable
5. Correct call-in communication success $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId3} # call-in value is taken from a preset variable
6. The entry is null error reporting $ { url } $ { header } { } # the entry is null
7. Parameter-in type error report error $ { url $ { header } { "codeStatus": $ codeStatus3, "conceptId": $ conceptId3} # parameter-in value is taken from a preset variable, $ codeStatus3 is an error value
8. Parameter-in type error report error $ { url $ { header } { "codeStatus": $ codeStatus1, ", conceptId": $ conceptId4} # parameter-in value is taken from a preset variable, $ conceptId4 is the error type value
9. The parameter entering lack of necessary-filling item reporting error $ { url $ { header } { "codeStatus": $ codeStatus1} # the parameter entering value is taken from a preset variable, $ conceptId is the necessary-filling item
10. The record number ${url}${header}{"codeStatus":$codeStatus1,"conceptId":$conceptId1}select count(*)from codevalue where conceptId=$conceptId1 and"codestatus"=${codeStatus1}# returned by the verification interface is taken from the preset variable, and $ conceptId is the necessary entry
In the test case file, each row where the keyword is located represents one test case, and for example, lines 4 to 10 of the test case file represent 7 test cases in total.
And the test module 7 is used for testing the interface to be tested according to a plurality of test cases.
In this embodiment, the automatically generated test cases may run directly in the corresponding automated test framework. For example, when a robot frame work is selected as the automation test framework, the generated test case code is a robot frame work code, and may be directly run on the robot frame work framework. The same is true for keywords included in the test cases and test data used in the test cases.
In addition, in this embodiment, the parameter output of the interface to be tested may be used to verify the test result. For example, url of the interface to be tested is: when the interface to be tested is/api/v 1/base/codevalue/query/by_ conceptid, the parameters of the interface to be tested may include boolean type parameter success and integer type parameter count (which may be used to represent the total number of compliance).
In this embodiment, the method may further include a first determining module for determining whether to change interface information of the interface to be tested, if so, calling a changing module for changing the interface information of the interface to be tested, then calling the obtaining module 3 to obtain the interface information after the interface to be tested is changed, then calling the first screening module 4 and the second screening module 5 to respectively screen and obtain a plurality of groups of target keyword data and a plurality of groups of target test data according to the changed interface information, and finally, calling the generating module 6 to regenerate a plurality of test cases according to the plurality of groups of target keyword data and the target test data obtained by re-screening, so as to realize automatic change of the test cases, and further realize maintenance of the test cases.
In this embodiment, the method may further include a second determining module for determining whether a new interface to be tested is needed, if so, calling a new module for adding the new interface to be tested, then calling the obtaining module 3 to obtain interface information of the new interface to be tested, then calling the first screening module 4 and the second screening module 5 to respectively screen and obtain a plurality of groups of target keyword data and a plurality of groups of target test data according to the interface information of the new interface to be tested, and finally, calling the generating module 6 to regenerate a plurality of test cases according to the plurality of groups of target keyword data and the target test data obtained by screening, so as to realize automatic new addition of the test cases, and further realize maintenance of the test cases.
According to the embodiment, the keyword-driven automatic test framework is adopted, multiple groups of keyword data and test data are preset, and then multiple groups of keyword data and test data for generating multiple test cases in a combined mode can be obtained through screening according to interface information of an interface to be tested, so that labor cost and time cost required by design and maintenance of the test cases can be reduced, and API automatic test efficiency and test quality can be improved.
Example 3
The present embodiment provides an electronic device, which may be expressed in the form of a computing device (for example, may be a server device), including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the method for generating a test case based on a keyword provided in embodiment 1 may be implemented when the processor executes the computer program.
Fig. 3 shows a schematic diagram of the hardware structure of the present embodiment, and as shown in fig. 3, the electronic device 9 specifically includes:
At least one processor 91, at least one memory 92, and a bus 93 for connecting the different system components (including the processor 91 and the memory 92), wherein:
the bus 93 includes a data bus, an address bus, and a control bus.
The memory 92 includes volatile memory such as Random Access Memory (RAM) 921 and/or cache memory 922, and may further include Read Only Memory (ROM) 923.
Memory 92 also includes a program/utility 925 having a set (at least one) of program modules 924, such program modules 924 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The processor 91 executes various functional applications and data processing, such as the method for generating test cases based on keywords provided in embodiment 1 of the present invention, by running a computer program stored in the memory 92.
The electronic device 9 may further communicate with one or more external devices 94 (e.g., keyboard, pointing device, etc.). Such communication may occur through an input/output (I/O) interface 95. Also, the electronic device 9 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through a network adapter 96. The network adapter 96 communicates with other modules of the electronic device 9 via the bus 93. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in connection with the electronic device 9, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, data backup storage systems, and the like.
It should be noted that although several units/modules or sub-units/modules of an electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present application. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
Example 4
The present embodiment provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method for generating test cases based on keywords provided in embodiment 1.
More specifically, among others, readable storage media may be employed including, but not limited to: portable disk, hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible embodiment, the invention may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps of implementing the method for generating test cases based on keywords as described in embodiment 1, when said program product is run on the terminal device.
Wherein the program code for carrying out the invention may be written in any combination of one or more programming languages, which program code may execute entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device and partly on the remote device or entirely on the remote device.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the principles and spirit of the invention, but such changes and modifications fall within the scope of the invention.

Claims (8)

1. A method for generating test cases based on keywords, comprising:
Presetting a plurality of groups of key word data, wherein each group of key word data comprises a key word name, an interface application range and interface service logic, and the interface application range comprises an interface function type and an entry attribute; the step of presetting a plurality of groups of keyword data comprises the following steps:
Presetting a plurality of groups of keyword data according to an interface test case design method; each group of keyword data corresponds to an interface test scene;
presetting a plurality of groups of test data, wherein each group of test data comprises a parameter entry attribute and a parameter entry value; the step of presetting a plurality of groups of test data comprises the following steps: presetting a plurality of groups of test data by means of an automatic test platform;
acquiring interface information of an interface to be tested, wherein the interface information comprises an interface function type and an entry attribute;
screening the multiple groups of key word data according to the interface information to obtain multiple groups of target key word data;
screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data;
generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data;
The step of generating a plurality of test cases according to the plurality of sets of target keyword data and the plurality of sets of target test data comprises the following steps:
representing the interface information by using a custom parameter;
generating a variable file according to the interface information expressed by the parameters and the target test data of the groups;
and generating a plurality of test cases according to the target keyword data and the variable file.
2. The method for generating test cases based on keywords of claim 1, further comprising, after the step of generating test cases based on the sets of target keyword data and the sets of target test data:
judging whether the interface information of the interface to be tested needs to be changed or not;
If yes, firstly changing the interface information of the interface to be tested, and then executing the step of obtaining the interface information of the interface to be tested to obtain the interface information after the interface to be tested is changed;
and/or the number of the groups of groups,
Judging whether a newly added interface to be tested is needed;
If yes, the interface to be tested is newly added, and then the step of obtaining the interface information of the interface to be tested is executed to obtain the interface information of the newly added interface to be tested.
3. The method for generating test cases based on keywords of claim 1, further comprising, after the step of generating test cases based on the sets of target keyword data and the sets of target test data:
And testing the interface to be tested according to the test cases.
4. A system for generating test cases based on keywords, comprising:
the first presetting module is used for presetting a plurality of groups of keyword data, wherein each group of keyword data comprises a keyword name, an interface application range and interface service logic, and the interface application range comprises an interface function type and an entry attribute; the first preset module is specifically used for presetting a plurality of groups of keyword data according to an interface test case design method; each group of keyword data corresponds to an interface test scene;
The second preset module is used for presetting a plurality of groups of test data, wherein each group of test data comprises a parameter attribute and a parameter value; the second preset module is specifically used for presetting the plurality of groups of test data by relying on an automatic test platform;
the acquisition module is used for acquiring interface information of the interface to be detected, wherein the interface information comprises an interface function type and a parameter entering attribute;
the first screening module is used for screening the multiple groups of keyword data according to the interface information to obtain multiple groups of target keyword data;
the second screening module is used for screening the multiple groups of test data according to the interface information to obtain multiple groups of target test data;
the generating module is used for generating a plurality of test cases according to the plurality of groups of target keyword data and the plurality of groups of target test data;
the generation module comprises:
the custom parameter unit is used for representing the interface information by using custom parameters;
The first generation unit is used for generating a variable file according to the interface information expressed by the parameters and the plurality of groups of target test data;
And the second generating unit is used for generating a plurality of test cases according to the plurality of groups of target keyword data and the variable file.
5. The system for generating test cases based on keywords of claim 4, wherein the system for generating test cases based on keywords further comprises:
the first judging module is used for judging whether the interface information of the interface to be tested needs to be changed or not;
If yes, firstly calling a changing module, wherein the changing module is used for changing the interface information of the interface to be tested, and then calling the obtaining module to obtain the interface information after the interface to be tested is changed;
and/or the number of the groups of groups,
The second judging module is used for judging whether a new interface to be tested needs to be added;
if yes, a new adding module is called, the new adding module is used for adding the interface to be tested, and then the obtaining module is called to obtain the interface information of the newly added interface to be tested.
6. The system for generating test cases based on keywords of claim 4, wherein the system for generating test cases based on keywords further comprises:
And the test module is used for testing the interface to be tested according to the test cases.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of generating test cases based on keywords as claimed in any one of claims 1 to3 when the computer program is executed by the processor.
8. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the steps of the method of generating test cases based on keywords as claimed in any one of claims 1 to 3.
CN202010260011.9A 2020-04-03 2020-04-03 Method, system, equipment and medium for generating test case based on keywords Active CN113495831B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010260011.9A CN113495831B (en) 2020-04-03 2020-04-03 Method, system, equipment and medium for generating test case based on keywords

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010260011.9A CN113495831B (en) 2020-04-03 2020-04-03 Method, system, equipment and medium for generating test case based on keywords

Publications (2)

Publication Number Publication Date
CN113495831A CN113495831A (en) 2021-10-12
CN113495831B true CN113495831B (en) 2024-05-31

Family

ID=77995430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010260011.9A Active CN113495831B (en) 2020-04-03 2020-04-03 Method, system, equipment and medium for generating test case based on keywords

Country Status (1)

Country Link
CN (1) CN113495831B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090457A (en) * 2021-11-30 2022-02-25 卫宁健康科技集团股份有限公司 Method, device, processing equipment and medium for testing database storage process
CN114385493A (en) * 2021-12-30 2022-04-22 连连银通电子支付有限公司 Performance test method and device, electronic equipment and storage medium
CN115269386A (en) * 2022-07-13 2022-11-01 杭州安恒信息技术股份有限公司 A kind of interface automatic testing method, system, device and readable storage medium
CN117033249B (en) * 2023-10-08 2024-07-02 卓望数码技术(深圳)有限公司 Test case generation method and device, computer equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268073A (en) * 2014-09-05 2015-01-07 北京广利核系统工程有限公司 Method for generating test cases in batch mode
CN105373478A (en) * 2015-12-14 2016-03-02 广州华多网络科技有限公司 Automatic test method and system
CN107957957A (en) * 2017-12-28 2018-04-24 网易(杭州)网络有限公司 The acquisition methods and device of test case
CN108897687A (en) * 2018-06-29 2018-11-27 泰华智慧产业集团股份有限公司 A kind of API automated testing method and system based on data-driven
CN109189692A (en) * 2018-10-18 2019-01-11 阳光人寿保险股份有限公司 A kind of webservice interface test method and device
CN109582588A (en) * 2018-12-25 2019-04-05 迈普通信技术股份有限公司 Method for generating test case, device and electronic equipment
CN110134584A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 A kind of generation method, device, storage medium and the server of interface testing use-case
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN110781082A (en) * 2019-10-14 2020-02-11 腾讯科技(深圳)有限公司 Method, device, medium and equipment for generating test case of interface
CN110888818A (en) * 2019-12-22 2020-03-17 普信恒业科技发展(北京)有限公司 Test case configuration system and method, automatic test system and method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8838607B2 (en) * 2012-10-17 2014-09-16 International Business Machines Corporation Software system test case creation
US9396098B2 (en) * 2014-03-26 2016-07-19 Mckesson Financial Holdings Apparatuses, methods, and computer program products for conducting automated tests

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268073A (en) * 2014-09-05 2015-01-07 北京广利核系统工程有限公司 Method for generating test cases in batch mode
CN105373478A (en) * 2015-12-14 2016-03-02 广州华多网络科技有限公司 Automatic test method and system
CN107957957A (en) * 2017-12-28 2018-04-24 网易(杭州)网络有限公司 The acquisition methods and device of test case
CN108897687A (en) * 2018-06-29 2018-11-27 泰华智慧产业集团股份有限公司 A kind of API automated testing method and system based on data-driven
CN109189692A (en) * 2018-10-18 2019-01-11 阳光人寿保险股份有限公司 A kind of webservice interface test method and device
CN109582588A (en) * 2018-12-25 2019-04-05 迈普通信技术股份有限公司 Method for generating test case, device and electronic equipment
CN110134584A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 A kind of generation method, device, storage medium and the server of interface testing use-case
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN110781082A (en) * 2019-10-14 2020-02-11 腾讯科技(深圳)有限公司 Method, device, medium and equipment for generating test case of interface
CN110888818A (en) * 2019-12-22 2020-03-17 普信恒业科技发展(北京)有限公司 Test case configuration system and method, automatic test system and method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
API接口自动化测试系统设计及实现;何舒;《中国优秀硕士学位论文全文数据库 信息科技辑》;20190305(第3期);I138-506 *
Automatic generation of system test cases from use case specifications;Chunhui Wang deng;<ISSTA 2015: Proceedings of the 2015 International Symposium on Software Testing and Analysis>;20150731;385–396 *
基于UML时序图的测试用例自动生成系统的设计与实现;孙大成;《中国优秀硕士学位论文全文数据库 信息科技辑》;20180715(第7期);I138-799 *

Also Published As

Publication number Publication date
CN113495831A (en) 2021-10-12

Similar Documents

Publication Publication Date Title
CN113495831B (en) Method, system, equipment and medium for generating test case based on keywords
CN107819627B (en) System fault processing method and server
CN112052172B (en) Rapid test method and device for third-party channel and electronic equipment
CN111367754B (en) Data monitoring method, device, computer equipment and storage medium
CN102236672A (en) Method and device for importing data
CN113472555B (en) Fault detection method, system, device, server and storage medium
CN111428095B (en) Graph data quality verification method and graph data quality verification device
CN116090808A (en) RPA breakpoint reconstruction method and device, electronic equipment and medium
CN109254912A (en) A kind of method and device of automatic test
EP2862101A1 (en) Method and a consistency checker for finding data inconsistencies in a data repository
CN109241163B (en) Electronic certificate generation method and terminal equipment
CN118885405A (en) Database testing method and device
CN112561388A (en) Information processing method, device and equipment based on Internet of things
CN111026631B (en) Automatic interface detection method, device and server
CN114116470B (en) An automated static model checking method and device
CN116483707A (en) Test method, test device, test apparatus, test program, and test program
EP4105813A1 (en) Method for analyzing data consisting of a large number of individual messages, computer program product and computer system
WO2023014282A1 (en) Device and method for automated generation of parameter testing requests
CN114185548A (en) Code review method and device based on artificial intelligence, storage medium and server
CN113672497A (en) Method, device and equipment for generating non-buried point event and storage medium
CN112559331A (en) Test method and device
CN117076546B (en) Data processing method, terminal device and computer readable storage medium
CN114185943B (en) Data verification system, method and electronic device
CN109144804A (en) The processing method and relevant apparatus of automated production testing service device
CN119691651A (en) Industry model effective management method and system based on artificial intelligence

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
GR01 Patent grant
GR01 Patent grant