CN105912464A - Unit testing method and method - Google Patents

Unit testing method and method Download PDF

Info

Publication number
CN105912464A
CN105912464A CN201610207623.5A CN201610207623A CN105912464A CN 105912464 A CN105912464 A CN 105912464A CN 201610207623 A CN201610207623 A CN 201610207623A CN 105912464 A CN105912464 A CN 105912464A
Authority
CN
China
Prior art keywords
unit
project
test
code
normalization
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.)
Granted
Application number
CN201610207623.5A
Other languages
Chinese (zh)
Other versions
CN105912464B (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.)
Guangzhou Pinwei Software Co Ltd
Original Assignee
GUANGZHOU VIP NETWORK TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by GUANGZHOU VIP NETWORK TECHNOLOGY Co Ltd filed Critical GUANGZHOU VIP NETWORK TECHNOLOGY Co Ltd
Priority to CN201610207623.5A priority Critical patent/CN105912464B/en
Publication of CN105912464A publication Critical patent/CN105912464A/en
Application granted granted Critical
Publication of CN105912464B publication Critical patent/CN105912464B/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/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Landscapes

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

Abstract

The embodiment of the invention discloses a unit testing method. The method comprises following steps: obtaining development plan lists of all subprojects in an overall project and generating a normalized project table according to a pre-set model; recognizing units meeting the pre-set standard according to the above-mentioned normalized project table; and generating a unit testing environment according to the pre-set rule and finishing a test. The embodiment of the unit testing method and method helps increase unit testing efficiency and lower the cost of unit testing.

Description

A kind of unit test method and device
Technical field
The present invention relates to software testing technology, especially propose a kind of unit test method and device.
Background technology
Unit testing be large program exploitation in must through link, be that each component units to global procedures is tested, the most correctly achieve its predetermined function in order to detect each unit.Unit testing at present mainly according to the function that each unit is to be realized, is write test case for unit under test and builds the method realization of test environment.This method maximum problematically, test code operation amount is big, each unit will individually be write substantial amounts of test case and build test environment, expends substantial amounts of manpower and time.Particularly with large software, the workload of test code is even more than the size of code of function code, and the time building test environment accounts for more than the 40% of the whole development time.
Summary of the invention
In order to overcome the deficiencies in the prior art, the present invention is for solve the technical problem that, it is provided that a kind of unit test method and device, effectively raises the overall efficiency of unit testing, reduces the workload writing test code, save the time of unit testing.
For solving the problems referred to above, the technical solution adopted in the present invention is as follows:
A kind of unit test method, comprises the following steps:
Obtain each sub-project information table in overall project;
Normalization Project Information Table is generated according to each sub-project information table in described overall project;
According to described normalization Project Information Table, identify the unit meeting preassigned;
The test environment of the unit of preassigned is met as described in pre-defined rule generates;
Call described test environment, complete described in meet the unit testing of unit of preassigned.
Described normalization Project Information Table includes the normalization project information of each sub-project, the normalization project information of wherein said each sub-project includes, project process session information, logic upstream unit information, logic downstream unit information, the time point information in each stage in the project process stage.
The described project process stage includes newly-built stage, demand stage, waiting stage, development phase, test phase and has reached the standard grade the stage.
Described normalization Project Information Table supports iterative developing or waterfall type exploitation or iterative and waterfall type mixed developing sub-project information table.
The described unit meeting preassigned refers in normalization project informationIn table, the upstream units in the logic function of described unit and the downstream units in logic function had completed the unit testing of respective unit before the test phase time started expected from described unit.
Described by pre-defined rule generation test environment, including performing following steps:
According to the normalization project information of the described unit meeting preassigned, read the upstream units in its logic function and downstream units code;
Upstream units according to described reading and downstream units code, generate respective test module and connect code;
Call described upstream units and exciting test block code thereof, signal generating unit stimulating module;
Call described downstream units and result detection module code thereof, signal generating unit result detection module;
Code, element excitation module, unit result detection module signal generating unit test environment is connected according to described test module.
A kind of unit testing device, it is characterised in that including:
Retrieval unit, is used for obtaining each sub-project development plan table in overall project;
Project form signal generating unit, is used for generating above-mentioned normalization project form;
Detector unit, for identifying the unit meeting preassigned;
Test environment signal generating unit, is used for generating said units test environment;
Test execution unit, is used for calling described test environment, completes unit testing.
Described test environment signal generating unit also includes, tests code generating unit, for generating interface code according to above-mentioned selected upstream and downstream units.
Compared to existing technology, the beneficial effects of the present invention is:
1, by using the upstream of the unit meeting preassigned and the test environment of downstream units, the workload of unit testing environmental structure is effectively reduced.
2, by utilizing normalization project form, support waterfall type software development and iterative software development model simultaneously, improve the unit discrimination meeting preassigned, effectively reduce the workload of unit testing environmental structure.
3, by test code reuse, it is effectively increased testing efficiency.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, and can be practiced according to the content of description, and in order to allow thisInventionAbove and other objects, features and advantages can become apparent, below especially exemplified by preferred embodiment, and coordinateAccompanying drawing, describe in detail as follows.
Accompanying drawing explanation
Figure 1It it is the structure of general cell test environmentFigure
Figure 2It is to utilize upstream and downstream unit to build test environment principleFigure
Figure 3It it is embodiment of the present invention unit test method flow processFigure
Figure 4It is that embodiment of the present invention waterfall type develops principle of aliging with iterative developingSuch as figure
Figure 5It it is the flow process of embodiment of the present invention signal generating unit test environmentFigure
Figure 6It it is unit testing environmental structureFigure
Figure 7It it is the structural representation of a kind of unit testing device that the embodiment of the present invention providesFigure
Detailed description of the invention
Below in conjunction withAccompanying drawingDescribe the detailed description of the invention of the present invention in detail.
In general large-scale software development project, overall software can be divided into several functional modules according to function, and each functional module can be divided into several unit modules according to function to be completed again.The most described unit testing is aiming at the test of these unit modules.Overall software can be completed by multiple project team joint developments, and between different units, development progress is inconsistent, have first complete after complete.So there is some software unit, these unit are after its code development, and before carrying out unit testing, the upstream and downstream unit in its logic function has been developed complete and completed respective unit testing.The upstream and downstream unit in this cellular logic and test environment thereof now can be utilized to build the unit testing environment of this unit applicable, thus reduce the workload of unit testing environmental structure, improve unit testing efficiency.
Figure 1It it is the structure of general cell test environmentFigure, wherein stimulating module produces excited data according to test case and is sent to unit under test;The correctness of the result of result detection module detection unit under test output.Exciting unit simulates all possible input data cases of this unit under test;Detection module detects under stimulating module various input data cases, and whether the output data of unit under test meet the output data in expectation, thus judge whether tested module has designMistake
Figure 2It is to utilize upstream and downstream unit to build test environment principleFigure, complete building of unit testing environment by using the test environment of upstream and downstream unit.
Figure 3It it is embodiment of the present invention unit test method flow processFigure.This flow process originates in step 301.Then each sub-project information table in step 302 obtains overall project.Sub-project information table is relevant with the development scheme of project, and the development scheme of general data is divided into waterfall type software development mode and iterative software development mode two kinds.Disparity items selects oneself development scheme suitable to be operated according to respective demand, wherein waterfall type development scheme is more iterative relatively sharp on time schedule node, so on the basis of typically selecting waterfall type development scheme, iterative developing mode is converted into by certain technological means there is the time schedule node the same with waterfall type development scheme, thus the development plan of the overall project of unification, it is achieved normalization charting project status.
Normalization Project Information Table is generated in step 303, at this, normalization Project Information Table is done brief description, generate normalization form and be because different development schemes, project development pattern is different, time planning mode is the most different, under different development modes, it is difficult to unified clear and definite functional requirement and the development progress of each functional module, so needing to realize the item-function under different mode is developed and progress record by unified normalization form.Illustrate how to the development progress of waterfall type development mode and iterative developing pattern unified by normalization form in detail below, illustrate herein and simply describe a kind of implementation method realizing normalization form, additive method is not formed and limit.Introducing the stage method to the snap of waterfall type project stage of a kind of iterative project, the stage of waterfall type project mainly has herein: newly-built stage, demand stage, waiting stage, development phase, test phase, reach the standard grade the stage;In order to align, the demand of iterative developing is also provided with newly-built stage, demand stage, waiting stage, development phase, test phase, reaches the standard grade these stages in stage, their alignment relationSuch as figure 4Shown in.By the above-mentioned method by iterative developing segmentation, iterative developing is alignd on the project stage with waterfall type exploitation.Normalization form, according to each sub-project stage of alignment, is recorded logical relation and the time scheme of arrangement of the state of each unit, progress and peripheral unit, is generated described form.
The unit meeting preassigned is identified in step 304.Described preassigned refers to meet the standard of structure test environment set in advance, i.e. described in meet the unit of preassigned and refer in normalization project informationIn table, the upstream units in the logic function of this unit and the downstream units in logic function complete eachIndependentThe unit testing time this unit enter test phase timing node before.
In step 305 according to the above-mentioned unit identified, generate this unit testing environment, complete test.
Flow process ends at step 306.
Figure 5Flow process according to pre-defined rule signal generating unit test environment in step 305 is shownFigure.This flow process originates in step 501.Then in step 502 according to the normalization project information of the described unit meeting preassigned, the upstream units in the logic function of the unit meeting preassigned and downstream units code are read.In step 503, the upstream of scanning reading and downstream units code, read module input/output interface definitional part content, generate test module and connect code.Call described upstream units and exciting test block code thereof in step 504, generate the element excitation module of unit under test.Described downstream units and result detection module code thereof, signal generating unit result detection module is called in step 505;In step 506 according to described test module link block, element excitation module, unit result detection module signal generating unit test environment.Step 507 terminates.
Figure 6It isFigure 5Described unit testing environmental structureFigure, the upstream units of unit under test and exciting test block code thereof, generate the element excitation module of unit under test.The downstream units of unit under test and result detection module thereof, signal generating unit result detection module.Unit under test and element excitation module and result detection module are coupled together by test module link block, generate test environment.
Figure 7It it is the structural representation of a kind of unit testing device that the embodiment of the present invention providesFigure.Including retrieval unit 701, project form signal generating unit 702, detector unit 703, test environment signal generating unit 704, test execution unit 705.
Wherein, retrieval unit, it is used for obtaining each sub-project development plan table in overall project;Project form signal generating unit, is used for generating above-mentioned normalization project form;Detector unit, for identifying the unit meeting preassigned;Test environment signal generating unit, is used for generating said units test environment;Test execution unit, is used for calling described test environment, completes unit testing.
Described test environment signal generating unit also includes, tests code generating unit, for generating interface code according to above-mentioned selected upstream and downstream units.
Further, above-mentioned interface code can be write automatically by test code generating unit.Concrete, can be read it define about input and output by shell script scanning upstream and downstream module, and automatically generated the encirclement module that there is input, export definition by script.
Further, it is also possible to realize automatically generating of test environment by test environment signal generating unit.For choosing upstream and the downstream units of above-mentioned unit to be tested, according to the interface code of above-mentioned generation, and call existing test code, signal generating unit test environment.
Although the foregoing describing the detailed description of the invention of the present invention, but it will be understood by those skilled in the art that these are merely illustrative of, these embodiments can be made various changes or modifications, without departing from principle and the essence of the present invention.The scope of the present invention is only limited by described claims.

Claims (8)

1. a unit test method, it is characterised in that comprise the following steps:
Obtain each sub-project information table in overall project;
Normalization Project Information Table is generated according to each sub-project information table in described overall project;
According to described normalization Project Information Table, identify the unit meeting preassigned;
The test environment of the unit of preassigned is met as described in pre-defined rule generates;
Call described test environment, complete described in meet the unit testing of unit of preassigned.
2. want unit test method as described in 1 such as right, it is characterised in that: described normalization Project Information Table includes The normalization project information of each sub-project, the normalization project information of wherein said each sub-project includes, Project process session information, logic upstream unit information, logic downstream unit information, project process rank The time point information in each stage in Duan.
3. want unit test method as described in 2 such as right, it is characterised in that: the described project process stage includes newly-built Stage, demand stage, waiting stage, development phase, test phase and reached the standard grade the stage.
4. want unit test method as described in 1 such as right, it is characterised in that: described normalization Project Information Table is supported Iterative developing or waterfall type are developed or iterative and waterfall type mixed developing sub-project information table.
5. want unit test method as described in 1 such as right, it is characterised in that the unit meeting preassigned described in: is Referring in normalization Project Information Table, upstream and downstream units in the logic function of described unit complete Each the time of unit testing is early than the unit testing time point of described unit.
6. want unit test method as described in 1 such as right, it is characterised in that described by pre-defined rule generation test wrapper Border, including performing following steps:
According to the normalization project information of the described unit meeting preassigned, read the list meeting preassigned Upstream units in the logic function of unit and downstream units code;
Upstream units according to described reading and downstream units code, generate test module and connect code;
Call described upstream units and exciting test block code thereof, signal generating unit stimulating module;
Call described downstream units and result detection module code thereof, signal generating unit result detection module;
Code, element excitation module, unit result detection module signal generating unit is connected according to described test module Test environment.
7. a unit testing device, it is characterised in that including:
Retrieval unit, is used for obtaining each sub-project development plan table in overall project;
Project form signal generating unit, is used for generating above-mentioned normalization project form;
Detector unit, for identifying the unit meeting preassigned;
Test environment signal generating unit, is used for generating said units test environment;
Test execution unit, is used for calling described test environment, completes unit testing.
8. unit testing device as claimed in claim 7, it is characterised in that: described test environment signal generating unit is also Including, test code generating unit, for generating interface according to above-mentioned selected upstream and downstream units Code.
CN201610207623.5A 2016-04-01 2016-04-01 A kind of unit test method and device Active CN105912464B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610207623.5A CN105912464B (en) 2016-04-01 2016-04-01 A kind of unit test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610207623.5A CN105912464B (en) 2016-04-01 2016-04-01 A kind of unit test method and device

Publications (2)

Publication Number Publication Date
CN105912464A true CN105912464A (en) 2016-08-31
CN105912464B CN105912464B (en) 2018-08-24

Family

ID=56745578

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610207623.5A Active CN105912464B (en) 2016-04-01 2016-04-01 A kind of unit test method and device

Country Status (1)

Country Link
CN (1) CN105912464B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040078693A1 (en) * 2002-03-22 2004-04-22 Kellett Stephen Richard Software testing
CN103970648A (en) * 2013-01-30 2014-08-06 百度国际科技(深圳)有限公司 Test method and system of installation package
CN104618955A (en) * 2015-03-04 2015-05-13 上海华东电信研究院 Mobile communication terminal consistency test item set generating method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040078693A1 (en) * 2002-03-22 2004-04-22 Kellett Stephen Richard Software testing
CN103970648A (en) * 2013-01-30 2014-08-06 百度国际科技(深圳)有限公司 Test method and system of installation package
CN104618955A (en) * 2015-03-04 2015-05-13 上海华东电信研究院 Mobile communication terminal consistency test item set generating method and system

Also Published As

Publication number Publication date
CN105912464B (en) 2018-08-24

Similar Documents

Publication Publication Date Title
CN106528424B (en) Test method and test platform based on background system service or interface
US8214803B2 (en) Program testing method and testing device
CN106940428A (en) Chip verification method, apparatus and system
CN102521122B (en) Dynamic scene oriented method and system for generating test sequence
CN105022691B (en) A kind of increasingly automated method for testing software based on uml diagram
CN105760296B (en) Automatic test control method, device and terminal
CN111950212A (en) Efficient multi-mode verification platform and method
CN115828839A (en) System-level verification system and method for SOC (System on chip)
CN108111364B (en) Service system testing method and device
CN108415830A (en) A kind of generation method and device of software test case
CN102314395A (en) Method and system for generating test case
CN110321292A (en) Chip detecting method, device, electronic equipment and computer readable storage medium
CN101604290B (en) Background module test method and backstage module test system
CN103049374B (en) Automatic testing method and device
CN102135939B (en) Test case operation dispatching device and method
CN112765014B (en) Automatic test system for multi-user simultaneous operation and working method
CN106201859A (en) A kind of regression testing method and system
Yu Design and application on agile software exploratory testing model
CN105550103A (en) Custom test script based automated testing method
CN102004660A (en) Realizing method and device of business flows
CN105912464A (en) Unit testing method and method
CN100458800C (en) Automatic construction system and method for electronic circuit design
CN106775691A (en) A kind of storage management software design for based on front and back end separate
CN102279798B (en) Software testing method and system based on point function driving
CN104424096A (en) Automatic testing system and method for Android platform based device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20180117

Address after: 510370 Guangzhou City, Guangzhou, Guangdong, Fangcun Avenue, one of the 314 self compiled

Applicant after: Guangzhou Pinwei Software Co., Ltd.

Address before: No. 20, Liwan District Huahai street, Guangzhou, Guangdong Province

Applicant before: GUANGZHOU VIP NETWORK TECHNOLOGY CO., LTD.

GR01 Patent grant
GR01 Patent grant