CN109614341A - A kind of test method and system of code coverage - Google Patents
A kind of test method and system of code coverage Download PDFInfo
- Publication number
- CN109614341A CN109614341A CN201811638285.6A CN201811638285A CN109614341A CN 109614341 A CN109614341 A CN 109614341A CN 201811638285 A CN201811638285 A CN 201811638285A CN 109614341 A CN109614341 A CN 109614341A
- Authority
- CN
- China
- Prior art keywords
- test
- code
- file
- code coverage
- environment
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
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 embodiment of the present invention provides the test method and system of a kind of code coverage, comprising: according to the task of test code coverage, obtains and executes parameter;Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine tool, and is set as when container engine tool starts, by file mount relevant to code coverage is generated in host into container engine tool;The implementation of test cases module in the test environment of the dynamic construction, obtains the test result of code coverage.The present invention can obtain corresponding execution parameter, and test environment by dynamic construction, can satisfy the multiple services application scenarios of more scenes, the diversity of test environment deployment be adapted to, so that the degree of automation of software test can be improved according to different test assignments.
Description
Technical field
The present invention relates to software testing technology fields, more particularly to the test method and system of a kind of code coverage.
Background technique
Test code coverage, which mainly passes through, in the prior art manually carries out, larger workload.It is needed before test coverage
Test environment is built according to business demand in advance, and JaCoCo file is respectively configured in each test environment.Test wrapper
After the completion of border is built, there are also a series of preparations such as: according to needing manually to download source code, more before different business demand tests
Change the relevant configuration of coverage rate report and execute corresponding test case etc..These continuous repeated work can waste test
The biggish human resources in field, larger workload cause coverage rate report output efficiency lower, influence the promotion for testing quality.
In addition, integrating the skill that tomcat environment is disposed and JaCoCo plug-in unit is used to generate coverage rate report in Jenkins
Art only realizes the continuous integrating of code coverage report.Wherein test building for environment, the downloading and test case of source code
Calling be still manual execution.And the single coverage rate test technology of this environment is not suitable for multi-service scene, when daily
When coverage rate test is needed for different test environment, original continuous integrating deployment is unable to meet demand.In different surveys
In test ring border, needs dynamically to start according to demand test environment, downloading source code to be tested and dynamically change building report
The XML file of announcement.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery:
The method testing time of test code coverage is long at present, can not adapt to the diversity of test environment deployment, causes
The degree of automation is low.
Summary of the invention
The embodiment of the present invention provides the test method and system of a kind of code coverage, improves the automatic of software code test
Change degree.
On the one hand, the embodiment of the invention provides a kind of test methods of code coverage, comprising:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to appearance
In device engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
On the other hand, the embodiment of the invention provides a kind of test macros of code coverage, comprising:
Parameter acquiring unit is executed, for the task according to test code coverage, obtains and executes parameter;
Environment construction unit is tested, test environment, the test environment construction list are constructed according to the execution dynamic state of parameters
Member includes container starting module, and the container starting module is set as starting container engine tool in container engine work
When tool starting, by file mount relevant to code coverage is generated in host into container engine tool;
Test cell is executed, the implementation of test cases module in the test environment of the dynamic construction obtains code coverage
The test result of rate.
On the other hand, the embodiment of the invention provides a kind of test macros of code coverage, comprising:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the place when executed
It manages device and executes following operation:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to appearance
In device engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
On the other hand, the embodiment of the invention provides a kind of computer readable storage medium, the computer-readable storages
Media storage one or more program, one or more of programs are executed when the electronic equipment for being included multiple application programs
When, so that the electronic equipment executes following operation:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to appearance
In device engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
Above-mentioned technical proposal has the following beneficial effects:
The present invention can obtain corresponding execution parameter, and test environment by dynamic construction according to different test assignments,
It can satisfy the multiple services application scenarios of more scenes, the diversity of test environment deployment adapted to, so that software test can be improved
The degree of automation.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
It obtains other drawings based on these drawings.
Fig. 1 is the flow chart of the test method of code coverage of the present invention;
Fig. 2 is the modular structure schematic diagram of the test macro of code coverage of the present invention;
Fig. 3 is the structural schematic diagram of dynamic construction test environment unit of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Before introducing technical solution of the present invention, some proper nouns being related in following present invention are first introduced:
Code coverage: it indicates covering of the test case to source code has been executed, is measured as one of software test
It is widely used.Code coverage can embody the tested degree and ratio of source code, be clear that source code
Branch, row, class for being covered to and being not covered with etc..When coverage rate ratio is higher, indicate that source code is tested use-case
The ratio gone to is higher.Tester passes through code coverage as a result, can add survey to cover insufficient source code
Example on probation improves the software function of exploitation to further improve test safeguard work.
JaCoCo: being widely applied a kind of Java code coverage rate tool in the market.JaCoCo is using modification bytecode
Method, to modify the jar file or class file of tested code.Statistics codes are inserted, then test coverage point
Analysis can be completed during executing and testing code.
Ant: being a kind of the build tool based on Java, and when operation needs a configuration file based on XML.Each configuration
It is provided with a series of tasks (target) in file, Ant is by calling target, so that it may execute various tasks.In the application
The building that middle Ant is mainly used in the execution of test case and last code coverage is reported.
Docker: being the container engine tool of an open source, can be removable for the creation such as software application, web services one
Container plant, lightweight, for software test and software development etc..Mirror image, container and warehouse are that three of Docker are important
Component: 1) mirror image may include a complete system environments and application program, and mirror image can be used to create Docker appearance
Device.2) container be mirror image creation example, Docker by completed using container application exploitation and operation.3) warehouse is collection
The place of middle storage image file.Warehouse can be public warehouse, the private in warehouse and local network creation on in-company line
There is warehouse etc..
Host: refer to the host for carrying entire Docker service, that is, be used to start the server of Docker container.
The catalogue can be automatically created and replicate in a reservoir by carry host catalogue when Docker container starts.
Continuous integrating: the multi-task is periodically carried out to the process of integration testing.Increasingly with software test requirement
Complexity, test assignment can not carry out simply by the mode of division module, need to cooperate with each other between modules, because
This continuous integrating becomes more and more important.Continuous integrating can be used for completing some periods, cumbersome, complicated task, Ke Yishi
The now full automation of entire test process.
Jenkins: being an open source software tool, is widely applied in continuous integrating field.Wherein Jenkins
Pipeline is the workflow frame operated on Jenkins, and the task of multiple nodes is connected, and realizes individual task
Complete the purpose of Complicated Flow.
Shell: being the bridge that user uses Linux.Shell is both a kind of command lanuage and a kind of program design language
Speech.Shell script is a kind of shell script write for Shell, the various execution tasks write for completing user.
WeTest: being processing API (Application Programming Interface, application programming interface)
The lightweight automated test frame of interface testing, is realized using Java language, has expanded JUnit4 Open Framework, supports Ant/
The executive mode of Maven.The test case that can polymerize equal modules is tested after class name progress canonical matching according to JUnit4, so
It is scheduled afterwards with Shell script, Ant can construct specified polymeric type after executing corresponding XML file, run certain to realize
All test cases of a module.
The object of the present invention is to provide the test methods of code coverage, can obtain and correspond to according to different test assignments
Execution parameter, and environment is tested by dynamic construction, can satisfy the multiple services application scenarios of more scenes, adapt to test environment
The diversity of deployment, so that the degree of automation of software test can be improved.
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, with reference to the accompanying drawing and specific real
Applying mode, the present invention is described in further detail.
As shown in Figure 1, the test method of code coverage of the present invention includes:
Step 101: according to the task of test code coverage, obtaining and execute parameter;
Step 102: test environment being constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting
Container engine tool, and be set as when container engine tool starts, by text relevant to code coverage is generated in host
Part is mounted in container engine tool;
Step 103: the implementation of test cases module in the test environment of the dynamic construction obtains the survey of code coverage
Test result.
Wherein in step 101, test environment parameter: according to different coverage rate business needs, tester can be right
Different types of test assignment is connect, therefore there are many test environment that execute code coverage for meeting.Before executing test, need
Select a kind of test environment that execute code coverage.Such as: with the citing of microblogging business, it is divided into web front-end, library of object front end
The equal rpc such as head end tests environment and library of object rpc, short chain rpc, card rpc test environment.
Image release parameter: after having selected a kind of test environment, before executing test, need to get the test wrapper
The image release number of border service code.Due to regularly going up line interation etc., there are different editions in mirror image warehouse on the line of company
Environment code can choose image release number that is newest or needing herein.Such as: in microblogging business, one of web front-end
Image release number is web_v4_deploy:1.0.100.
Test case module parameter: code coverage is the degree and ratio measured source code and be tested use-case covering.Cause
This needs to be implemented test case after finally configuring test environment.According to the difference of test assignment and source code to be tested
Difference needs to be implemented different test case modules, therefore Jenkins also needs dynamically to obtain the module of corresponding test case
Number.Such as: with the citing of microblogging business, executes comment module and then select comment test case, execution praises module and then selects to praise survey
Example on probation.
For step 102, further preferably, the execution parameter includes test environment parameter, image release parameter
And test case module parameter;And
The starting container engine tool includes:
According to the image release parametric configuration environment mirror;Specifically: it is pulled according to the image release parameter
Corresponding mirror image judges that the corresponding test environment of the mirror image and test case module and the test environment parameter and test are used
Whether example module parameter respectively corresponds, when judging result is not reconfigured the mirror image with build environment to when corresponding to
Mirror image;When judging result is to correspondence using the mirror image as environment mirror;
Start container engine tool according to the environment mirror.
It is further preferred that described reconfigure with build environment mirror image the mirror image, comprising:
For mirror configuration the build tool Ant;
The inserter tool of Java code coverage rate tool JaCoCo file is added in the mirror image;
Configure the proxy parameter of the JaCoCo file in the image starting script.
For structural environment mirror image: in implementation coverage test process, warehouse pulls on the line of subsidiary company test wrapper
The mirror image in border cannot be used directly, and the environmental variance etc. for needing to configure execution code coverage is rebuild.This step exists
It is nonessential during automated execution, such as: the identical test of identical test environment has been selected when executing code coverage
Use-case module, the mirror image built before can executing, other situations need to be rebuild during automated execution.This mould
The realization of block is completed in Jenkins Pipeline, and operating procedure is as follows
1) because last coverage rate test report uses Ant and constructed, in the mirror for pulling indicated release number
As after, it is also necessary to configure Ant environment.
2) inserter tool of JaCoCo file is added in new mirror image.
3) the Java Agent proxy parameter for starting JaCoCo in script in new mirror image is configured, is received for coverage data
Collection.
4) a new mirror image is re-configured to after the completion of configuration, new mirror image compiles after the completion again push to privately owned storehouse
Library.
For step 102, further preferably, the file relevant to code coverage is generated includes: code coverage
Configuration file, source code directory and the code coverage of rate Core Generator report catalogue;
And the dynamic construction tests environment further include: after the starting of container engine tool, downloads source code and by institute
The source code directory that source code is put into the host is stated, the configuration text of the code coverage Core Generator in host is modified
Part restarts container engine tool.
Wherein, start Docker module: the realization of this module is completed in Jenkins Pipeline, mainly include with
Lower step
1) it checks container list, the old Docker container started before is deleted.Such as: want to survey in microblogging business
The code coverage for trying web_v4_deploy:1.0.100, by the unnecessary of other versions of existing web_v4_deploy before
Container deleted, reduce machine loading.
2) using image starting Docker container newly-generated in previous step.It is needed when starting container raw in carry host
At the XML file of code coverage, source code directory and code coverage report catalogue into Docker container, for covering later
The generation of lid rate report.
Further preferably, the configuration file of the code coverage Core Generator in the modification host, comprising:
The address of source code directory and tested code directory is configured in the configuration file of code coverage Core Generator;
Source file and class file configuration are modified in the configuration file of code coverage Core Generator;Wherein, the source document
Part is source code file, and the class file is source code corresponding jar file or class file in tested code.
Wherein, download source code module: JaCoCo is that statistics codes are inserted into tested code in a manner of pitching pile, so
Afterwards according to different business demands, the coverage data of specified source code is exported using Ant, it is therefore desirable to download corresponding source generation
Code.Such as: in microblogging business, selected test web front-end environment the code coverage for not reading pond module, herein should under
Carry the source code of the jar files such as api-sevice and the feed-service in web front-end code.Simultaneously by putting source code
Entering in the source code directory of host can be mounted in Docker container.It also needs after having downloaded modules of source code to place
The XML configuration file of JaCoCo in master machine is modified, and the content of XML file modification mainly includes following content:
1) address that source code directory and tested code directory are configured in XML file generates and exports covering for after
Rate data provide address.
2) source file and class file configuration are modified in XML file, for generating coverage data.Original refers to source
Code file, class file refer to source code corresponding jar file or class file in tested code.
Tested code is a part in test environment, is deposited in the form of jar file or class file in test environment
?.
Source code is the java source code of the jar file or class file.
The downloading of this module and modification process are completed in Shell script.It has downloaded source code and has modified XML text
Docker container is restarted after part.So far, the dynamic construction for executing the test environment of code coverage is realized.
For step 103, implementation of test cases: mainly including the following contents
1) monitoring and test environment start completion is needed before implementation of test cases, i.e. test environment can be adjusted logical, this function exists
It is completed in the construction step Execute Shell of Jenkins, time-out can prompt building to fail without Jenkins when starting successfully.
2) the test case engineering of microblogging uses WeTest interface testing automation framework, and each test module is built into
One corresponding XML file.This process calls Ant to execute completion by using Shell script.Such as: in web front-end environment
It is middle to execute the test case for not reading pond module, i.e., Ant Unread.xml is executed in Shell script.
After the completion of test case executes, under the XML file catalogue of JaCoCo, html is generated using Ant building mode and is surveyed
Examination report, and tester is sent to mail he.
The test method of code coverage of the present invention may be used in the daily test of microblog, the environment of daily test
It mainly include web front-end environment, card rpc environment, short chain rpc environment and library of object rpc environment etc..By using the technology
The dynamic parameterization starting of coverage rate test environment can be greatly improved, improve the testing efficiency for generating code coverage, for
Unlapped source code can carry out test case addition in time, and code coverage ratio significantly improves.Such as:
The test case module for not reading pond is executed in web front-end test environment, the modules of source code of downloading includes: api-
Data, api-engine, web_v4, api-mq, api-comment, api-statuses, feed-service and apollo.
The html of the coverage rate of last output reports result.
Present invention notice uses the measuring technology of automated execution code coverage, can be improved testing efficiency, shortens whole
Test period in a software development flow.And since dynamic construction tests environment, the multiple services application of more scenes can satisfy
Scene.It can be periodically executed by continuous integrating and generate code coverage report, generate the various necessity of testing process to push
Prediction scheme and corrective measure, improve test macro, improve the reliability of test.
This technology realizes the test wrapper that dynamic construction executes code coverage by continuous integrating and Shell script etc.
Border, the dynamic change tasks such as configuration file and automatic implementation of test cases, realize one-key start and execution.It is led in software test
In domain, this technology has originality.
In addition, improving the automation journey of software code test the present invention also provides a kind of test macro of code coverage
Degree.As shown in Fig. 2, the test macro of code coverage of the present invention includes:
Parameter acquiring unit 21 is executed, for obtaining and executing parameter according to test assignment;
Environment construction unit 22 is tested, test environment, the test environment construction are constructed according to the execution dynamic state of parameters
Unit includes container starting module, and the container starting module is set as starting container engine tool in container engine
When instrument start-up, by file mount relevant to code coverage is generated in host into container engine tool;
Test cell 23 is executed, the implementation of test cases module in the test environment of the dynamic construction obtains test knot
Fruit.
Further, the execution parameter includes test environment parameter, image release parameter and test case module ginseng
Number;And
The container starting module is specifically used for according to the image release parametric configuration environment mirror;Specifically: root
Pull corresponding mirror image according to the image release parameter, judge the corresponding test environment of the mirror image and test case module with
Whether the test environment parameter and test case module parameter respectively correspond, when judging result is not to correspondence to the mirror
As being reconfigured with build environment mirror image;When judging result is to correspondence using the mirror image as environment mirror;And according to
The environment mirror starts container engine tool.
The further container starting module, is specifically used for:
For mirror configuration the build tool Ant;
The inserter tool of Java code coverage rate tool JaCoCo file is added in the mirror image;
Configure the proxy parameter of the JaCoCo file in the image starting script.
Further, the file relevant to code coverage is generated includes: the configuration of code coverage Core Generator
File, source code directory and code coverage report catalogue;And
The test environment construction unit further includes downloading source code module, and the downloading source code module is used in container engine
After instrument start-up, downloads source code and the source code is put into the source code directory in the host, modify in host
Code coverage Core Generator configuration file, restart container engine tool.
Further, the downloading source code module, is specifically used for:
The address of source code directory and tested code directory is configured in the configuration file of code coverage Core Generator;
Source file and class file configuration are modified in the configuration file of code coverage Core Generator;Wherein, the source document
Part is source code file, and the class file is source code corresponding jar file or class file in tested code.
In addition, the present invention also provides a kind of test macros of code coverage, comprising:
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the place when executed
It manages device and executes following operation:
According to test assignment, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine
Tool, and be set as when container engine tool starts, file mount relevant to code coverage is generated in host is arrived
In container engine tool;
The implementation of test cases module in the test environment of the dynamic construction, obtains test result.
The present invention also provides a kind of computer readable storage medium, the computer-readable recording medium storage one or more
A program, one or more of programs are when the electronic equipment for being included multiple application programs executes, so that the electronics is set
It is standby to execute following operation:
According to test assignment, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine
Tool, and be set as when container engine tool starts, file mount relevant to code coverage is generated in host is arrived
In container engine tool;
The implementation of test cases module in the test environment of the dynamic construction, obtains test result.
For the prior art, test macro, computer readable storage medium and the above-mentioned code of code coverage of the present invention
The beneficial effect of the test method of coverage rate is identical, and details are not described herein.
It should be understood that the particular order or level of the step of during disclosed are the examples of illustrative methods.Based on setting
Count preference, it should be appreciated that in the process the step of particular order or level can be in the feelings for the protection scope for not departing from the disclosure
It is rearranged under condition.Appended claim to a method is not illustratively sequentially to give the element of various steps, and not
It is to be limited to the particular order or level.
In above-mentioned detailed description, various features are combined together in single embodiment, to simplify the disclosure.No
This published method should be construed to reflect such intention, that is, the embodiment of theme claimed needs to compare
The more features of the feature clearly stated in each claim.On the contrary, as appended claims is reflected
Like that, the present invention is in the state fewer than whole features of disclosed single embodiment.Therefore, appended claims
It is hereby expressly incorporated into detailed description, wherein each claim is used as alone the individual preferred embodiment of the present invention.
For can be realized any technical staff in the art or using the present invention, above to disclosed embodiment into
Description is gone.To those skilled in the art;The various modifications mode of these embodiments will be apparent from, and this
The General Principle of text definition can also be suitable for other embodiments on the basis of not departing from the spirit and scope of the disclosure.
Therefore, the disclosure is not limited to embodiments set forth herein, but most wide with principle disclosed in the present application and novel features
Range is consistent.
Description above includes the citing of one or more embodiments.Certainly, in order to describe above-described embodiment and description portion
The all possible combination of part or method is impossible, but it will be appreciated by one of ordinary skill in the art that each implementation
Example can do further combinations and permutations.Therefore, embodiment described herein is intended to cover fall into the appended claims
Protection scope in all such changes, modifications and variations.In addition, with regard to term used in specification or claims
The mode that covers of "comprising", the word is similar to term " includes ", just as " including " solved in the claims as transitional word
As releasing.In addition, the use of any one of specification in claims term "or" being to indicate " non-exclusionism
Or ".
Those skilled in the art will also be appreciated that the various illustrative components, blocks that the embodiment of the present invention is listed
(illustrative logical block), unit and step can by electronic hardware, computer software, or both knot
Conjunction is realized.For the replaceability (interchangeability) for clearly showing that hardware and software, above-mentioned various explanations
Property component (illustrative components), unit and step universally describe their function.Such function
It can be that the design requirement for depending on specific application and whole system is realized by hardware or software.Those skilled in the art
Can be can be used by various methods and realize the function, but this realization is understood not to for every kind of specific application
Range beyond protection of the embodiment of the present invention.
Various illustrative logical blocks or unit described in the embodiment of the present invention can by general processor,
Digital signal processor, specific integrated circuit (ASIC), field programmable gate array or other programmable logic devices, discrete gate
Or transistor logic, discrete hardware components or above-mentioned any combination of design carry out implementation or operation described function.General place
Managing device can be microprocessor, and optionally, which may be any traditional processor, controller, microcontroller
Device or state machine.Processor can also be realized by the combination of computing device, such as digital signal processor and microprocessor,
Multi-microprocessor, one or more microprocessors combine a digital signal processor core or any other like configuration
To realize.
The step of method described in the embodiment of the present invention or algorithm can be directly embedded into hardware, processor execute it is soft
The combination of part module or the two.Software module can store in RAM memory, flash memory, ROM memory, EPROM storage
Other any form of storaging mediums in device, eeprom memory, register, hard disk, moveable magnetic disc, CD-ROM or this field
In.Illustratively, storaging medium can be connect with processor, so that processor can read information from storaging medium, and
It can be to storaging medium stored and written information.Optionally, storaging medium can also be integrated into the processor.Processor and storaging medium can
To be set in asic, ASIC be can be set in user terminal.Optionally, processor and storaging medium also can be set in
In different components in the terminal of family.
In one or more exemplary designs, above-mentioned function described in the embodiment of the present invention can be in hardware, soft
Part, firmware or any combination of this three are realized.If realized in software, these functions be can store and computer-readable
On medium, or it is transferred on a computer readable medium in the form of one or more instructions or code forms.Computer readable medium includes electricity
Brain storaging medium and convenient for so that computer program is allowed to be transferred to from a place telecommunication media in other places.Storaging medium can be with
It is that any general or special computer can be with the useable medium of access.For example, such computer readable media may include but
It is not limited to RAM, ROM, EEPROM, CD-ROM or other optical disc storages, disk storage or other magnetic storage devices or other
What can be used for carry or store with instruct or data structure and it is other can be by general or special computer or general or specially treated
The medium of the program code of device reading form.In addition, any connection can be properly termed computer readable medium, example
Such as, if software is to pass through a coaxial cable, fiber optic cables, double from a web-site, server or other remote resources
Twisted wire, Digital Subscriber Line (DSL) are defined with being also contained in for the wireless way for transmitting such as example infrared, wireless and microwave
In computer readable medium.The disk (disk) and disk (disc) includes compress disk, radium-shine disk, CD, DVD, floppy disk
And Blu-ray Disc, disk is usually with magnetic replicate data, and disk usually carries out optically replicated data with laser.Combinations of the above
Also it may be embodied in computer readable medium.
Above-described specific embodiment has carried out further the purpose of the present invention, technical scheme and beneficial effects
It is described in detail, it should be understood that being not intended to limit the present invention the foregoing is merely a specific embodiment of the invention
Protection scope, all within the spirits and principles of the present invention, any modification, equivalent substitution, improvement and etc. done should all include
Within protection scope of the present invention.
Claims (12)
1. a kind of test method of code coverage, which comprises the following steps:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine work
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to container
In engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
2. the test method of code coverage according to claim 1, which is characterized in that the execution parameter includes test
Environmental parameter, image release parameter and test case module parameter;And
The starting container engine tool includes:
According to the image release parametric configuration environment mirror;Specifically: correspondence is pulled according to the image release parameter
Mirror image, judge the corresponding test environment of the mirror image and test case module and the test environment parameter and test case mould
Whether block parameter respectively corresponds, when judging result is not reconfigured the mirror image with build environment mirror image to when corresponding to;
When judging result is to correspondence using the mirror image as environment mirror;
Start container engine tool according to the environment mirror.
3. the test method of code coverage according to claim 2, which is characterized in that described to carry out weight to the mirror image
New configuration is with build environment mirror image, comprising:
For mirror configuration the build tool Ant;
The inserter tool of Java code coverage rate tool JaCoCo file is added in the mirror image;
Configure the proxy parameter of the JaCoCo file in the image starting script.
4. the test method of code coverage described in one of -3 according to claim 1, which is characterized in that described and generation code
The relevant file of coverage rate includes: the configuration file, source code directory and code coverage report of code coverage Core Generator
Accuse catalogue;
And the dynamic construction tests environment further include: after the starting of container engine tool, downloads source code and by the source
Code is put into the source code directory in the host, modifies the configuration file of the code coverage Core Generator in host,
Restart container engine tool.
5. the test method of code coverage according to claim 4, which is characterized in that the generation in the modification host
The configuration file of code coverage rate Core Generator, comprising:
The address of source code directory and tested code directory is configured in the configuration file of code coverage Core Generator;
Source file and class file configuration are modified in the configuration file of code coverage Core Generator;Wherein, the source file is
Source code file, the class file are source code corresponding jar file or class file in tested code.
6. a kind of test macro of code coverage characterized by comprising
Parameter acquiring unit is executed, for the task according to test code coverage, obtains and executes parameter;
Environment construction unit is tested, test environment, the test environment construction unit packet are constructed according to the execution dynamic state of parameters
Container starting module is included, the container starting module is starting the same of container engine tool for starting container engine tool
When, by file mount relevant to code coverage is generated in host into container engine tool;
Test cell is executed, the implementation of test cases in the test environment of the dynamic construction obtains the test of code coverage
As a result.
7. the test macro of code coverage according to claim 6, which is characterized in that the execution parameter includes test
Environmental parameter, image release parameter and test case module parameter;And
The container starting module is specifically used for according to the image release parametric configuration environment mirror;Specifically: according to institute
State image release parameter and pull corresponding mirror image, judge the corresponding test environment of the mirror image and test case module with it is described
Whether test environment parameter and test case module parameter respectively correspond, when judging result be not to it is corresponding when to the mirror image into
Row is reconfigured with build environment mirror image;When judging result is to correspondence using the mirror image as environment mirror;And according to described
Environment mirror starts container engine tool.
8. the test macro of code coverage according to claim 7, which is characterized in that the container starting module, tool
Body is used for:
For mirror configuration the build tool Ant;
The inserter tool of Java code coverage rate tool JaCoCo file is added in the mirror image;
Configure the proxy parameter of the JaCoCo file in the image starting script.
9. the test macro of the code coverage according to one of claim 6-8, which is characterized in that described and generation code
The relevant file of coverage rate includes: the configuration file, source code directory and code coverage report of code coverage Core Generator
Accuse catalogue;And
The test environment construction unit further includes downloading source code module, and the downloading source code module is used in container engine tool
After starting, downloads source code and the source code is put into the source code directory in the host, modify the generation in host
The configuration file of code coverage rate Core Generator, restarts container engine tool.
10. the test macro of code coverage according to claim 9, which is characterized in that the downloading source code module, tool
Body is used for:
The address of source code directory and tested code directory is configured in the configuration file of code coverage Core Generator;
Source file and class file configuration are modified in the configuration file of code coverage Core Generator;Wherein, the source file is
Source code file, the class file are source code corresponding jar file or class file in tested code.
11. a kind of test macro of code coverage characterized by comprising
Processor;And
It is arranged to the memory of storage computer executable instructions, the executable instruction makes the processor when executed
Execute following operation:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine work
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to container
In engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
12. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage is one or more
Program, one or more of programs are when the electronic equipment for being included multiple application programs executes, so that the electronic equipment
Execute following operation:
According to test code coverage task, obtains and execute parameter;
Test environment is constructed according to the execution dynamic state of parameters, the dynamic construction test environment includes starting container engine work
Tool, and while starting container engine tool, by file mount relevant to code coverage is generated in host to container
In engine tool;
The implementation of test cases in the test environment of the dynamic construction, obtains the test result of code coverage.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811638285.6A CN109614341A (en) | 2018-12-29 | 2018-12-29 | A kind of test method and system of code coverage |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811638285.6A CN109614341A (en) | 2018-12-29 | 2018-12-29 | A kind of test method and system of code coverage |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109614341A true CN109614341A (en) | 2019-04-12 |
Family
ID=66015768
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811638285.6A Pending CN109614341A (en) | 2018-12-29 | 2018-12-29 | A kind of test method and system of code coverage |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109614341A (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110309055A (en) * | 2019-05-23 | 2019-10-08 | 深圳壹账通智能科技有限公司 | Black-box Testing method, apparatus, terminal and storage medium based on Java Virtual Machine |
CN110750463A (en) * | 2019-10-29 | 2020-02-04 | 百度在线网络技术(北京)有限公司 | Applet testing method, device, system, equipment and medium |
CN110968507A (en) * | 2019-11-20 | 2020-04-07 | 北京创鑫旅程网络技术有限公司 | Coverage rate statistical method and device |
CN111104333A (en) * | 2019-12-20 | 2020-05-05 | 广州品唯软件有限公司 | Coverage rate test method, test device and computer readable storage medium |
CN111240998A (en) * | 2020-02-17 | 2020-06-05 | 网易(杭州)网络有限公司 | Test case processing method and device |
CN111538660A (en) * | 2020-04-24 | 2020-08-14 | 中国工商银行股份有限公司 | Method and device for counting coverage rate of program codes in container on cloud |
CN112069066A (en) * | 2020-09-01 | 2020-12-11 | 招商银行股份有限公司 | Code coverage rate statistical method, device, equipment and computer readable storage medium |
CN112100073A (en) * | 2020-09-16 | 2020-12-18 | 京东数字科技控股股份有限公司 | Online development method and device of application program, electronic equipment and storage medium |
CN112463588A (en) * | 2020-11-02 | 2021-03-09 | 北京健康之家科技有限公司 | Automatic test system and method, storage medium and computing equipment |
CN113110999A (en) * | 2021-04-26 | 2021-07-13 | 浙江工业大学 | Intelligent electric energy meter software white box cross testing method based on lightweight testing framework |
CN113220560A (en) * | 2020-01-21 | 2021-08-06 | 百度在线网络技术(北京)有限公司 | Code testing method and device, electronic equipment and storage medium |
CN113468073A (en) * | 2021-08-02 | 2021-10-01 | 在线途游(北京)科技有限公司 | Automatic testing method |
CN117130917A (en) * | 2023-08-28 | 2023-11-28 | 北京安普诺信息技术有限公司 | Ash box testing method, device and system for containerized Java application |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105224466A (en) * | 2015-11-17 | 2016-01-06 | 广州亦云信息技术有限公司 | A kind of integration test method based on Docker and system |
CN106383852A (en) * | 2016-08-30 | 2017-02-08 | 中国民生银行股份有限公司 | Docker container-based log acquisition method and apparatus |
CN106933635A (en) * | 2017-03-15 | 2017-07-07 | 北京搜狐新媒体信息技术有限公司 | Docker mirror images generation method and Docker containers |
US20180089068A1 (en) * | 2016-09-28 | 2018-03-29 | Wipro Limited | Methods and systems for testing mobile applications |
-
2018
- 2018-12-29 CN CN201811638285.6A patent/CN109614341A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105224466A (en) * | 2015-11-17 | 2016-01-06 | 广州亦云信息技术有限公司 | A kind of integration test method based on Docker and system |
CN106383852A (en) * | 2016-08-30 | 2017-02-08 | 中国民生银行股份有限公司 | Docker container-based log acquisition method and apparatus |
US20180089068A1 (en) * | 2016-09-28 | 2018-03-29 | Wipro Limited | Methods and systems for testing mobile applications |
CN106933635A (en) * | 2017-03-15 | 2017-07-07 | 北京搜狐新媒体信息技术有限公司 | Docker mirror images generation method and Docker containers |
Non-Patent Citations (1)
Title |
---|
蜗牛也是妞: "HttpRunnerManager平台异步生成及展示代码覆盖率报告(ant+jacoco+jenkins+HttpRunnerManager)", 《博客园,HTTPS://WWW.CNBLOGS.COM/SNAILGIRL/P/10075135.HTML》 * |
Cited By (19)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110309055A (en) * | 2019-05-23 | 2019-10-08 | 深圳壹账通智能科技有限公司 | Black-box Testing method, apparatus, terminal and storage medium based on Java Virtual Machine |
CN110750463A (en) * | 2019-10-29 | 2020-02-04 | 百度在线网络技术(北京)有限公司 | Applet testing method, device, system, equipment and medium |
CN110750463B (en) * | 2019-10-29 | 2023-06-23 | 百度在线网络技术(北京)有限公司 | Method, device, system, equipment and medium for testing small program |
CN110968507A (en) * | 2019-11-20 | 2020-04-07 | 北京创鑫旅程网络技术有限公司 | Coverage rate statistical method and device |
CN110968507B (en) * | 2019-11-20 | 2023-07-25 | 北京创鑫旅程网络技术有限公司 | Coverage rate statistics method and coverage rate statistics device |
CN111104333A (en) * | 2019-12-20 | 2020-05-05 | 广州品唯软件有限公司 | Coverage rate test method, test device and computer readable storage medium |
CN113220560A (en) * | 2020-01-21 | 2021-08-06 | 百度在线网络技术(北京)有限公司 | Code testing method and device, electronic equipment and storage medium |
CN111240998A (en) * | 2020-02-17 | 2020-06-05 | 网易(杭州)网络有限公司 | Test case processing method and device |
CN111240998B (en) * | 2020-02-17 | 2024-04-19 | 网易(杭州)网络有限公司 | Test case processing method and device |
CN111538660A (en) * | 2020-04-24 | 2020-08-14 | 中国工商银行股份有限公司 | Method and device for counting coverage rate of program codes in container on cloud |
CN111538660B (en) * | 2020-04-24 | 2023-09-26 | 中国工商银行股份有限公司 | Method and device for counting coverage rate of program codes in cloud container |
CN112069066A (en) * | 2020-09-01 | 2020-12-11 | 招商银行股份有限公司 | Code coverage rate statistical method, device, equipment and computer readable storage medium |
CN112069066B (en) * | 2020-09-01 | 2024-05-07 | 招商银行股份有限公司 | Code coverage rate statistical method, device, equipment and computer readable storage medium |
CN112100073A (en) * | 2020-09-16 | 2020-12-18 | 京东数字科技控股股份有限公司 | Online development method and device of application program, electronic equipment and storage medium |
CN112463588A (en) * | 2020-11-02 | 2021-03-09 | 北京健康之家科技有限公司 | Automatic test system and method, storage medium and computing equipment |
CN113110999A (en) * | 2021-04-26 | 2021-07-13 | 浙江工业大学 | Intelligent electric energy meter software white box cross testing method based on lightweight testing framework |
CN113468073A (en) * | 2021-08-02 | 2021-10-01 | 在线途游(北京)科技有限公司 | Automatic testing method |
CN117130917A (en) * | 2023-08-28 | 2023-11-28 | 北京安普诺信息技术有限公司 | Ash box testing method, device and system for containerized Java application |
CN117130917B (en) * | 2023-08-28 | 2024-01-23 | 北京安普诺信息技术有限公司 | Ash box testing method, device and system for containerized Java application |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109614341A (en) | A kind of test method and system of code coverage | |
US9342273B1 (en) | Automatic communications graphing for a source application | |
US9952852B2 (en) | Automated deployment and servicing of distributed applications | |
CN103778178B (en) | Method and system for reconfiguring snapshot of virtual machine (VM) | |
CN104094226B (en) | Use the application or driving on deployment configuration Automatic Update of File client device | |
US20160350081A1 (en) | Automatic container definition | |
Kazman et al. | Toward a discipline of scenario‐based architectural engineering | |
US20070261027A1 (en) | Method and system for automatically discovering and populating a palette of reusable dialog components | |
CN107832207A (en) | Interface performance test method, apparatus, storage medium and computer equipment | |
CN111259406B (en) | Automatic construction method and system for cloud native application vulnerability reproduction environment | |
CN108228452A (en) | A kind of test method and test device based on simple factory mode | |
CN109144533A (en) | A kind of method, system and the computer installation of update and the load of application program | |
CN110309029A (en) | Acquisition method, device, computer equipment and the storage medium of abnormal data | |
CN110008123A (en) | A kind of method of automatic deployment test software and corresponding device | |
US20160335069A1 (en) | Dependency handling for software extensions | |
CN107807869A (en) | A kind of test system and method for testing | |
CN106502713A (en) | A kind of method for upgrading software and system | |
CN109739704A (en) | A kind of interface test method, server-side and computer readable storage medium | |
CN112306887A (en) | Program test distribution method and corresponding device, equipment and medium | |
CN110825395B (en) | Multi-plug-in layered deployment system, device and medium | |
Rivera et al. | UML-driven automated software deployment | |
US20160335068A1 (en) | Checks for software extensions | |
CN111142861B (en) | Method and device for integrating structured comprehensive control system | |
US7437705B1 (en) | System and method for building an application on a computing device which includes an environment-controlling process | |
White et al. | Automated model-based configuration of enterprise java applications |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190412 |