CN104965781A - Method and apparatus for generating test case - Google Patents

Method and apparatus for generating test case Download PDF

Info

Publication number
CN104965781A
CN104965781A CN201510305545.8A CN201510305545A CN104965781A CN 104965781 A CN104965781 A CN 104965781A CN 201510305545 A CN201510305545 A CN 201510305545A CN 104965781 A CN104965781 A CN 104965781A
Authority
CN
China
Prior art keywords
key word
test case
described
testing procedure
test
Prior art date
Application number
CN201510305545.8A
Other languages
Chinese (zh)
Inventor
赵慧
Original Assignee
浪潮电子信息产业股份有限公司
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 浪潮电子信息产业股份有限公司 filed Critical 浪潮电子信息产业股份有限公司
Priority to CN201510305545.8A priority Critical patent/CN104965781A/en
Publication of CN104965781A publication Critical patent/CN104965781A/en

Links

Abstract

The present invention provides a method and an apparatus for generating a test case. The method comprises: pre-defining at least one keyword, wherein each keyword comprises at least one test step; determining test steps in the test case according to a program to be tested; according to the determined test steps in the test case and the at least one test step in each keyword, determining test case keywords corresponding to the test steps in the test case; according to an order of the test steps in the test cases, determining an order of the test case keywords; and writing the test case keywords into the test case in the determined order of the test case keywords, to generate the test case. The method and the apparatus for generating a test case provided by the present invention can improve software testing efficiency.

Description

A kind of method of generating test use case and device

Technical field

The present invention relates to field of computer technology, particularly a kind of method of generating test use case and device.

Background technology

Software test is a kind of process being used for promoting the qualification correctness of software, integrality, security and quality.In other words, software test is that a kind of reality exports and the examination & verification of expection outlet chamber or comparison procedure.The classics definition of software test is: operate program under defined terms, with discovery procedure mistake, weighs software quality, and to its process assessed that whether can meet design requirement.Along with computer software develop rapidly, the software program of exploitation becomes increasingly complex, more and more higher to the requirement of test specification and test dynamics, also more and more higher to the requirement of testing efficiency.

In prior art, when carrying out software test, need to write test case, general test use-case is made up of testing procedure one by one, and a usual test case comprises tens steps; When needs are modified to test case, steps related to all in test case are all modified.

Visible by foregoing description, the process of generating test use case in prior art, workload is large, and testing efficiency is lower.

Summary of the invention

In view of this, the invention provides a kind of method and device of generating test use case, the efficiency of software test can be improved.

On the one hand, the invention provides a kind of method of generating test use case, comprising:

At least one key word pre-defined, each key word comprises: at least one testing procedure, and the method also comprises:

According to the testing procedure in program determination test case to be tested;

According to the testing procedure in the testing procedure in the test case determined and each key word, determine the test case key word that testing procedure in test case is corresponding;

According to the order of the testing procedure in test case, determine the order of described test case key word;

Described test case key word is sequentially written in test case according to the test case key word determined, generates described test case.

Further, in described key word, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;

Before the described test case of described generation, also comprise: in test case, write the data that the parameter of each test case key word is corresponding.

Further, also comprise: according to described program to be tested and the testing procedure in the test case determined, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.

Further, described at least one key word pre-defined, comprising: be encapsulated in same key word, as high-order key word by the testing procedure verified Output rusults that do not need be connected; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.

Further, also comprise:

Key function corresponding to each key word is generated according to described key word;

According to the test case determined and described key function, determine the test script of described test case.

On the other hand, the invention provides a kind of device of generating test use case, comprising:

Definition unit, for defining at least one key word, each key word comprises: at least one testing procedure;

Testing procedure determining unit, for according to the testing procedure in program determination test case to be tested;

Key word determining unit, for the testing procedure in the test case determined according to described testing procedure determining unit and the testing procedure in each key word, determines the test case key word that testing procedure in test case is corresponding;

Order determination unit, for the order according to the testing procedure in test case, determines the order of described test case key word;

Test cases technology unit, for being sequentially written in test case by described test case key word according to the test case key word determined, generates described test case.

Further, described definition unit, also for definition of keywords, make at least one key word in all key words, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;

Described Test cases technology unit, also for data that the parameter writing each test case key word in test case is corresponding.

Further, also comprise:

Redefine unit, for the testing procedure in the test case determined according to described program to be tested and described testing procedure determining unit, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.

Further, described definition unit, when performing described at least one key word pre-defined, specifically performs: be encapsulated in same key word, as high-order key word by the testing procedure verified Output rusults that do not need be connected; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.

Further, also comprise:

Function determining unit, for determining according to described key word the key function that each key word is corresponding;

Script determining unit, for according to the test case determined and described key function, determines the test script of described test case.

The method of a kind of generating test use case provided by the invention and device, in advance according to application definition key word to be tested, in the process of generating test use case, testing procedure in test case is described by key word, key word can be reused, without the need to describing test case to the testing procedure by repeating, saving the workload of generating test use case, improve the efficiency of software test.

Accompanying drawing explanation

In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.

Fig. 1 is the process flow diagram of the method for a kind of generating test use case that one embodiment of the invention provides;

Fig. 2 is the process flow diagram of the method for the another kind of generating test use case that one embodiment of the invention provides;

Fig. 3 is the device schematic diagram of a kind of generating test use case that one embodiment of the invention provides.

Embodiment

For making the object of the embodiment of the present invention, technical scheme and advantage clearly; below in conjunction with the accompanying drawing in the embodiment of the present invention; technical scheme in the embodiment of the present invention is clearly and completely described; obviously; described embodiment is the present invention's part embodiment, instead of whole embodiments, based on the embodiment in the present invention; the every other embodiment that those of ordinary skill in the art obtain under the prerequisite not making creative work, all belongs to the scope of protection of the invention.

As shown in Figure 1, embodiments provide a kind of method of generating test use case, the method can comprise the following steps:

Step 101: at least one key word pre-defined, each key word comprises: at least one testing procedure;

Step 102: according to the testing procedure in program determination test case to be tested;

Step 103: according to the testing procedure in the testing procedure in the test case determined and each key word, determines the test case key word that testing procedure in test case is corresponding;

Step 104: according to the order of the testing procedure in test case, determines the order of described test case key word;

Step 105: described test case key word is sequentially written in test case according to the test case key word determined, generates described test case.

Visible by foregoing description, the method of a kind of generating test use case that the embodiment of the present invention provides, pre-defined key word, in the process of generating test use case, described the testing procedure in test case by key word, key word can be reused, without the need to describing test case to the testing procedure by repeating, save the workload of generating test use case, improve the efficiency of software test.

In a kind of possible implementation, in described key word, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;

Before the described test case of described generation, also comprise: in test case, write the data that the parameter of each test case key word is corresponding.

In test case, some testing procedure needs input parameter, output parameter, is separated by the numerical value of testing procedure with input, output by this implementation, improves the reusability of key word.

In a kind of possible implementation, the method also comprises: according to described program to be tested and the testing procedure in the test case determined, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.

Due in the process of generating test use case, may needing to modify to test case, by this implementation, test case can be revised by redefining key word.For example, certain testing procedure in test case needs amendment, and can realize by redefining key word corresponding to this testing procedure, like this, test case just changes test process without the need to modifying, and substantially reduces the workload of modification process.

In a kind of possible implementation, described at least one key word pre-defined, comprising: be encapsulated in same key word, as high-order key word by the testing procedure verified Output rusults that do not need be connected; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.

In this implementation, when definition of keywords, key word is divided into high-order key word and low order key word, high-order should note its reusability.

High-order key word, mainly for operation flow, for user interface, in test case, can be hidden in the step of high-order key word some details operations of user interface.High-order key word easy understand, and be easy to safeguard.

Low order key word mainly operates for some details, for user interface, in test case, mainly for the operating interactive with user interface, and the testing procedure of more detailed description test.

In a kind of possible implementation, the method also comprises:

Key function corresponding to each key word is generated according to described key word;

According to the test case determined and described key function, determine the test script of described test case.

In this implementation, key word is realized by key function, according to the Test cases technology test script determined, in test script, key function can be called to perform the testing procedure in key word corresponding to this key function.

For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with drawings and the specific embodiments, the present invention is described in further detail.

In this embodiment, need to test the login feature of a web system, as shown in Figure 2, embodiments provide a kind of method of generating test use case, the method can comprise the following steps:

Step 201: in advance according to the login feature definition both keyword of web system to be tested, be login system key word, verification tip information keys respectively.

Wherein, login system key word comprises following 3 testing procedures and execution sequence thereof: step 1: open < browser >, input < network address >; Step 2: input < user name >, < password >; Step 3: click " login " button; Login system key word comprises following 4 parameters and comprises: browser, network address, user name, password;

Verification tip information keys comprises following 2 steps and execution sequence thereof: step 1: check whether information is < expected information > at prompt window; Step 2: close prompt window; Parameter in verification tip information keys is expected information.

In addition, the mark of entry keyword can be added in key word, for example, identification key is carried out by the title of key word, wherein, the title of key word is generally " verb "+" object ", the title of above both keyword respectively: " login system " and " verification tip information ".When generating test use case, by the title of key word write test case.

When definition of keywords, can define according to the requirement documents of program to be tested, the key word of definition can be put in key word library and preserve.

Testing procedure in same key word is connected, can perform successively according to respective sequence.

Step 202: be followed successively by according to the testing procedure in the login feature determination test case of web system to be tested: open < browser >, input < network address >; Input < user name >, < password >; Click " login " button; Check whether information is < expected information > at prompt window; Close prompt window.

Step 203: according to the testing procedure in the testing procedure in the test case determined and each key word, determines that the test case key word that testing procedure in test case is corresponding is login system key word, verification tip information keys.

In step 202., define the testing procedure needed in test case, step " opens < browser >, input < network address >; Input < user name >, < password >; Click " logins " button " correspondence key word be login system key word, at prompt window, step " checks whether information is < expected information >; Close prompt window " corresponding key word is verification tip information keys.

Step 204: according to the order of the testing procedure in test case, determines that the order of described test case key word is from login system key word to verification tip information keys.

In step 202., define the order of the testing procedure needed in test case, determine the order of key word according to this order.

Step 205: by login system key word and verification tip information keys, according to from login system key word being sequentially written in test case to verification tip information keys.

Step 206: the data of write parameters browser, network address, user name, password and expected information in test case, generating test use case.

For example, can arrange browser is IE10, and network address is www.abc.com, and user is called admin, and password is test, and expected information is " logining successfully ".The login feature can being tested web system to be tested by the data of these parameters normally can be logged at IE10 browser.

In addition, in order to test the login feature identifiable design Bad user name or password of web system to be tested, refusal logs in, the data of parameter can be set to: browser is IE10, network address is www.abc.com, and user is called admin1, and password is test, expected information for " user name does not exist, and please input correct user name! ".Expected information is that " code error please input proper password or the data of parameter can be set to: browser is IE10, and network address is www.abc.com, and user is called admin, password is test1! "

In general, a test event builds a key word library, stores the key word of definition in key word library.When writing test case, in key word library, look for suitable key word, logically relation is enumerated, then by needing the test data used to replenish below the parameter of key word, this completes writing of a test case.

See Fig. 3, the device of a kind of generating test use case that the present embodiment provides, comprising:

Definition unit 301, for defining at least one key word, each key word comprises: at least one testing procedure;

Testing procedure determining unit 302, for according to the testing procedure in program determination test case to be tested;

Key word determining unit 303, for the testing procedure in the test case determined according to described testing procedure determining unit 302 and the testing procedure in each key word, determines the test case key word that testing procedure in test case is corresponding;

Order determination unit 304, for the order according to the testing procedure in test case, determines the order of described test case key word;

Test cases technology unit 305, for being sequentially written in test case by described test case key word according to the test case key word determined, generates described test case.

In a kind of possible implementation, described definition unit 301, also for definition of keywords, make at least one key word in all key words, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;

Described Test cases technology unit 305, also for data that the parameter writing each test case key word in test case is corresponding.

In a kind of possible implementation, this device also comprises:

Redefine unit, for the testing procedure in the test case determined according to described program to be tested and described testing procedure determining unit, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.

In a kind of possible implementation, described definition unit 301, when performing described at least one key word pre-defined, specifically perform: the testing procedure verified Output rusults that do not need be connected is encapsulated in same key word, as high-order key word; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.

In a kind of possible implementation, this device also comprises:

Function determining unit, for determining according to described key word the key function that each key word is corresponding;

Script determining unit, for according to the test case determined and described key function, determines the test script of described test case.

The content such as information interaction, implementation between each unit in said apparatus, due to the inventive method embodiment based on same design, particular content can see in the inventive method embodiment describe, repeat no more herein.

The method of a kind of generating test use case that the embodiment of the present invention provides and device, have following beneficial effect:

1, a kind of method of generating test use case that provides of the embodiment of the present invention and device, in advance according to application definition key word to be tested, in the process of generating test use case, testing procedure in test case is described by key word, key word can be reused, without the need to describing test case to the testing procedure by repeating, saving the workload of generating test use case, improve the efficiency of software test.

2, a kind of method of generating test use case that provides of the embodiment of the present invention and device, pre-defined key word, the numerical value that testing procedure and test input export can be separated by key word, key word has very large reusability, test case more easily performs, and when program to be tested realizes changing, only needs to modify to key word, general needs revises test case, and this way is than traditional test use-case more easy care.

It should be noted that, in this article, the relational terms of such as first and second and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element " being comprised a 〃 〃 〃 〃 〃 〃 " limited by statement, and be not precluded within process, method, article or the equipment comprising described key element and also there is other same factor.

One of ordinary skill in the art will appreciate that: all or part of step realizing said method embodiment can have been come by the hardware that programmed instruction is relevant, aforesaid program can be stored in the storage medium of embodied on computer readable, this program, when performing, performs the step comprising said method embodiment; And aforesaid storage medium comprises: ROM, RAM, magnetic disc or CD etc. various can be program code stored medium in.

Finally it should be noted that: the foregoing is only preferred embodiment of the present invention, only for illustration of technical scheme of the present invention, be not intended to limit protection scope of the present invention.All any amendments done within the spirit and principles in the present invention, equivalent replacement, improvement etc., be all included in protection scope of the present invention.

Claims (10)

1. a method for generating test use case, is characterized in that, comprising:
At least one key word pre-defined, each key word comprises: at least one testing procedure, and the method also comprises:
According to the testing procedure in program determination test case to be tested;
According to the testing procedure in the testing procedure in the test case determined and each key word, determine the test case key word that testing procedure in test case is corresponding;
According to the order of the testing procedure in test case, determine the order of described test case key word;
Described test case key word is sequentially written in test case according to the test case key word determined, generates described test case.
2. method according to claim 1, it is characterized in that, in described key word, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;
Before the described test case of described generation, also comprise: in test case, write the data that the parameter of each test case key word is corresponding.
3. method according to claim 1, it is characterized in that, also comprise: according to described program to be tested and the testing procedure in the test case determined, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.
4. method according to claim 1, is characterized in that, described at least one key word pre-defined, comprising: be encapsulated in same key word, as high-order key word by the testing procedure verified Output rusults that do not need be connected; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.
5. method according to claim 1, is characterized in that, also comprises:
Key function corresponding to each key word is generated according to described key word;
According to the test case determined and described key function, determine the test script of described test case.
6. a device for generating test use case, is characterized in that, comprising:
Definition unit, for defining at least one key word, each key word comprises: at least one testing procedure;
Testing procedure determining unit, for according to the testing procedure in program determination test case to be tested;
Key word determining unit, for the testing procedure in the test case determined according to described testing procedure determining unit and the testing procedure in each key word, determines the test case key word that testing procedure in test case is corresponding;
Order determination unit, for the order according to the testing procedure in test case, determines the order of described test case key word;
Test cases technology unit, for being sequentially written in test case by described test case key word according to the test case key word determined, generates described test case.
7. device according to claim 6, is characterized in that,
Described definition unit, also for definition of keywords, make at least one key word in all key words, also comprise: at least one parameter, wherein, at least one parameter described comprises: the output parameter of at least one testing procedure described in the input parameter of at least one testing procedure described in described key word, described key word;
Described Test cases technology unit, also for data that the parameter writing each test case key word in test case is corresponding.
8. device according to claim 6, is characterized in that, also comprises:
Redefine unit, for the testing procedure in the test case determined according to described program to be tested and described testing procedure determining unit, redefine the one or more key words in all key words, upgrade the testing procedure in current keyword.
9. device according to claim 6, it is characterized in that, described definition unit, when performing described at least one key word pre-defined, concrete execution: the testing procedure verified Output rusults that do not need be connected is encapsulated in same key word, as high-order key word; The testing procedure verified Output rusults that needs be connected is encapsulated in same key word, as low order key word.
10. device according to claim 6, is characterized in that, also comprises:
Function determining unit, for determining according to described key word the key function that each key word is corresponding;
Script determining unit, for according to the test case determined and described key function, determines the test script of described test case.
CN201510305545.8A 2015-06-04 2015-06-04 Method and apparatus for generating test case CN104965781A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510305545.8A CN104965781A (en) 2015-06-04 2015-06-04 Method and apparatus for generating test case

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510305545.8A CN104965781A (en) 2015-06-04 2015-06-04 Method and apparatus for generating test case

Publications (1)

Publication Number Publication Date
CN104965781A true CN104965781A (en) 2015-10-07

Family

ID=54219816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510305545.8A CN104965781A (en) 2015-06-04 2015-06-04 Method and apparatus for generating test case

Country Status (1)

Country Link
CN (1) CN104965781A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105893242A (en) * 2015-12-11 2016-08-24 乐视致新电子科技(天津)有限公司 Method for testing application, and test device
CN106528434A (en) * 2016-12-16 2017-03-22 上海携程国际旅行社有限公司 Processing method and system for preposing key word during automated test

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101221503A (en) * 2008-02-01 2008-07-16 中国建设银行股份有限公司 Software testing method and device
CN102135938A (en) * 2011-03-21 2011-07-27 中国工商银行股份有限公司 Software product testing method and system
US8984340B2 (en) * 2012-01-31 2015-03-17 Bank Of America Corporation System and method for test case generation using action keywords
CN104503900A (en) * 2014-11-21 2015-04-08 北京奇虎科技有限公司 Test case generation method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101221503A (en) * 2008-02-01 2008-07-16 中国建设银行股份有限公司 Software testing method and device
CN102135938A (en) * 2011-03-21 2011-07-27 中国工商银行股份有限公司 Software product testing method and system
US8984340B2 (en) * 2012-01-31 2015-03-17 Bank Of America Corporation System and method for test case generation using action keywords
CN104503900A (en) * 2014-11-21 2015-04-08 北京奇虎科技有限公司 Test case generation method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105893242A (en) * 2015-12-11 2016-08-24 乐视致新电子科技(天津)有限公司 Method for testing application, and test device
CN106528434A (en) * 2016-12-16 2017-03-22 上海携程国际旅行社有限公司 Processing method and system for preposing key word during automated test

Similar Documents

Publication Publication Date Title
US7891003B2 (en) Enterprise threat modeling
Steffan et al. Collaborative attack modeling
US7974942B2 (en) Data masking system and method
AU2005203386B2 (en) Test automation stack layering
Campos et al. Model checking interactor specifications
US7685140B2 (en) Dynamic information systems
US8001607B2 (en) System and method for obfuscation of data across an enterprise
US6941546B2 (en) Method and apparatus for testing a software component using an abstraction matrix
US5892947A (en) Test support tool system and method
US8225288B2 (en) Model-based testing using branches, decisions, and options
US20130275446A1 (en) Creating data in a data store using a dynamic ontology
Bernard et al. Generation of test sequences from formal specifications: GSM 11‐11 standard case study
KR101755365B1 (en) Managing record format information
US7216340B1 (en) Analysis data validation tool for use in enterprise architecture modeling with result based model updating
US20040123272A1 (en) Method and system for analysis of software requirements
US7424702B1 (en) Data integration techniques for use in enterprise architecture modeling
US20120158625A1 (en) Creating and Processing a Data Rule
US20030131337A1 (en) Educational method and tool for isolating and teaching programming language concepts
US7328428B2 (en) System and method for generating data validation rules
US20130339930A1 (en) Model-based test code generation for software testing
US8271870B2 (en) Document analysis, commenting, and reporting system
Butterfield et al. A dictionary of computer science
US8683446B2 (en) Generation of test cases for functional testing of applications
US8245186B2 (en) Techniques for offering and applying code modifications
WO2003036469A2 (en) A template-based method and system for reverse engineering

Legal Events

Date Code Title Description
PB01 Publication
C06 Publication
SE01 Entry into force of request for substantive examination
C10 Entry into substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20151007

WD01 Invention patent application deemed withdrawn after publication