CN110502428A - Code test method, device, computer equipment and storage medium - Google Patents
Code test method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110502428A CN110502428A CN201910610901.5A CN201910610901A CN110502428A CN 110502428 A CN110502428 A CN 110502428A CN 201910610901 A CN201910610901 A CN 201910610901A CN 110502428 A CN110502428 A CN 110502428A
- Authority
- CN
- China
- Prior art keywords
- test
- measured
- test case
- examining system
- code
- 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/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
This application involves a kind of code test method, device, computer equipment and storage mediums.This method comprises: test suite is called to start examining system;Obtain test case;The test case includes expected results;The code snippet to be measured in the examining system is executed based on the test case, obtains processing result;The processing result is intercepted and captured by the test suite;When the processing result is consistent with the expected results, determine that the code snippet test to be measured passes through.Code tester accuracy can be improved using this method.
Description
Technical field
This application involves field of computer technology, more particularly to a kind of code test method, device, computer equipment and
Storage medium.
Background technique
With the development of computer technology, business scope involved in operation system becomes more bulky complex.In order to protect
Card operation system can operate normally, and need to carry out white-box testing to the intrinsic function code of operation system.White-box testing refers to
When fully understanding code internal logic structure, all logical paths are tested.In traditional approach, when needing to carry out
When the object of white-box testing is code snippet, usually only the code snippet is tested in such a way that breakpoint is set, gained
To test result would generally and production environment in practical operation situation there are deviation so that the accuracy of code tester compared with
It is low.
Summary of the invention
Based on this, it is necessary in view of the above technical problems, provide a kind of code survey that can be improved code tester accuracy
Method for testing, device, computer equipment and storage medium.
A kind of code test method, which comprises test suite is called to start examining system;Obtain test case;
The test case includes expected results;The code snippet to be measured in the examining system is executed based on the test case, is obtained
To processing result;The processing result is intercepted and captured by the test suite;
When the processing result is consistent with the expected results, determine that the code snippet test to be measured passes through.
In one embodiment, the calling test suite starts examining system, comprising: creation initial processes;When described
When examining system is associated with multiple subsystems to be measured, test suite is called;It is opened in the initial processes by the test suite
Open corresponding with examining system system starting thread, and system corresponding with each subsystem to be measured starts
Thread.
It is in one embodiment, described that code snippet to be measured in the examining system is executed based on the test case,
Including;Obtain the system code file of test case and the examining system;Based on the test case in the system generation
Code snippet to be measured is positioned in code file, and obtains instance object corresponding with the examining system;Pass through the instantiation
Object executes the code snippet to be measured.
It is in one embodiment, described that code snippet to be measured is positioned in the system code file based on test case,
And obtain instance object corresponding with examining system, comprising: extract the function information to be tested in the test case;By institute
It states function information to be tested and is transferred to the examining system;Obtain the function information pair to be tested that the examining system returns
The class file path answered;The class file path is generated via the examining system parsing function information to be tested;Load
The corresponding class file in the class file path;Based on the instantiation pair corresponding with the examining system of creation in the class file
As.
It is in one embodiment, described that code snippet to be measured in the examining system is executed based on the test case,
Obtain processing result, comprising: by executing the code snippet to be measured in the examining system, generate resource acquisition request;By institute
It states resource acquisition request and is sent to third-party server;It receives the third-party server and is based on resource acquisition request return
Third party's resource;The examining system is based on third party's resource and carries out data processing, obtains processing result.
In one embodiment, the method also includes: when there are multiple test cases and multiple code snippets to be measured,
Identification and each associated test case of code snippet to be measured;It will be with the identical associated test case of code snippet to be measured as survey
Examination set;It is opened in the initial processes and starts thread with every kind of test set corresponding system;Start line according to multiple systems
Journey executes the test case in respectively corresponding test set respectively.In one embodiment, the test case is based on described
After executing the code snippet to be measured in the examining system, further includes: monitor the execution duration of the test case;When described
Execute duration be greater than preset duration when, then detect the test case whether entire run;When the test case entire run
When, it is determined that the code snippet test crash to be measured;When the incomplete operation of test case and there are when Network Abnormal information, then
Re-execute the test case.
A kind of code tester device, described device include: system starting module, for calling test suite to start system to be measured
System;Code tester module, for obtaining test case;The test case includes expected results;It is held based on the test case
Code snippet to be measured in the row examining system, obtains processing result;As a result comparison module, for passing through the test suite
Intercept and capture the processing result;When the processing result is consistent with the expected results, the code snippet test to be measured is determined
Pass through.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing
The step of device realizes above-mentioned each code test method as described in the examples when executing the computer program.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor
The step of above-mentioned each code test method as described in the examples is realized when row.
Above-mentioned code test method, device, computer equipment and storage medium, testing service device create initial processes it
Afterwards, open system it can start thread in initial processes with overall startup examining system.Testing service device is obtained comprising expected knot
After the test case of fruit, the code snippet to be measured in examining system can be executed based on test case, obtains processing result.Work as place
When reason result is consistent with the expected results in test case, it is determined that code snippet test to be measured passes through.Start line by system
Journey overall startup examining system, so that the test environment of examining system is close to production environment, so as to more accurately right
Examining system is tested.
Detailed description of the invention
Fig. 1 is the application scenario diagram of code test method in one embodiment;
Fig. 2 is the flow diagram of code test method in one embodiment;
Fig. 3 is the flow diagram of code test method in another embodiment;
Fig. 4 is the structural block diagram of code tester device in one embodiment;
Fig. 5 is the internal structure chart of computer equipment in one embodiment.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood
The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not
For limiting the application.
Code test method provided by the present application can be applied in application environment as shown in Figure 1.Wherein, test clothes
Business device 102 is communicated by network respectively with multiple third-party server 104.Wherein, testing service device 102 and third party take
Business device 104 can be realized with the server cluster of the either multiple server compositions of independent server.Testing service device 102
On can be deployed with examining system, and embeddable in examining system have test suite.Testing service device 102 create initial processes it
Afterwards, open system it can start thread in initial processes, which starts thread and be used for overall startup examining system.Testing service
After device 102 obtains the test case comprising expected results, the code piece to be measured in examining system can be executed based on test case
Section.By executing code snippet to be measured, testing service device 102 can call third party's resource of third-party server 104.System to be measured
System can carry out data processing based on third party's resource, and testing service device 102 can intercept and capture examining system and be carried out based on third party's resource
The processing result that data processing obtains.When processing result is consistent with the expected results in test case, it is determined that code to be measured
Segment test passes through.
In one embodiment, as shown in Fig. 2, providing a kind of code test method, it is applied in Fig. 1 in this way
It is illustrated for testing service device 102, comprising the following steps:
Step 202, test suite is called to start examining system.
Initial processes refer to once operation activity in computer, are that computer system carries out the basic of Resource Distribution and Schedule
Unit is the basis of operating system configuration.Initial processes can be used as the container of system starting thread, for an initial processes meter
Calculation machine system can distribute corresponding Installed System Memory.Startup procedure refers to the thread for overall startup examining system.It is to be measured
System refers to the operation system for needing to carry out code tester.Thread is an entity in initial processes, is to carry out resource allocation
With the minimum unit of scheduling.Corresponding Installed System Memory will not be distributed for a thread computer system, and in initial processes
Thread will share Installed System Memory that is identical, distributing to initial processes.By starting entire examining system, so that examining system
Test environment close to production environment, so as to improve the accuracy of test.
In one embodiment, examining system is an a kind of Java (Object-Oriented Programming Language) software project, test
Component is also a Java software project.Can the Embedded test component in examining system in advance, by test suite with Java thread
The method of starting open system in initial processes starts thread, and system starting thread can open entire examining system.Pass through
Test suite can be operated normally based on the examining system that system starting thread is opened, and can normally connect third party system,
And third party's resource needed for loading from third party system, examining system are based on the progress data processing of third party's resource and are handled
As a result after, test suite can also intercept and capture the processing result.
Step 204, test case is obtained;Test case includes expected results.
Test case refers to for testing whether examining system can normally realize the one group of input data and phase of required function
The intended response result answered.The number being made of multiple input parameters that input data is used when referring to for realizing system function
According to.Expected results refer to according to defined in interface definition document, based on input data can be inferred to as a result, expected results
It also may include multiple output parameters.Test case can be used for carrying out examining system logic testing, such as test examining system
Whether correct response results can be obtained in the case where normal input.Test case can also carry out error survey to examining system
Can examination, such as test examining system normally report an error in input extremely or abnormal scene input.
Code snippet to be measured refers to function code in need of test in examining system.Call examining system in
When test function, the corresponding function code of called function can be executed.When examining system realizes different system functions, then need
Different code snippets to be measured is executed, function code different in examining system can be surveyed by different test cases
Examination.By executing different code snippets to be measured, testing service device can call the interface of different third-party server, to obtain
The third party's resource needed.
In one embodiment, optional parameters library can be preset, is surveyed according to input parameter is chosen in optional parameters library with determining
The input data of example on probation.It, then can be respectively for each to be measured when executing the multiple fields to be tested of code snippet needs to be measured
Examination field prepares optional parameters library in advance, includes multiple optional parameters in each optional parameters library, optional parameters can also include
Normal parameter and anomaly parameter.A ginseng to be tested can be chosen from the corresponding optional parameters library of field to be replaced of each determination
Number, to constitute parameter combination to be tested according to the corresponding parameter to be tested of multiple fields to be replaced;According to each test
Parameter combination carries out dynamic machining processing to static message.Such as when there is 5 fields to be replaced, for each field to be replaced
Prepare 10 optional parameters, then 100000 kinds of parameter combinations to be tested is produced, to reduce the input number of setup test use-case
According to workload.
Step 206, the code snippet to be measured in examining system is executed based on test case, obtains processing result.
In one embodiment, the code snippet to be measured in examining system is executed based on test case, obtains processing result,
It include: to generate resource acquisition request by executing the code snippet to be measured in examining system;Resource acquisition request is sent to the
Tripartite's server;Receive third party's resource that third-party server is returned based on resource acquisition request;Examining system is based on third
Fang Ziyuan carries out data processing, obtains processing result.
Third party's resource refers to external resource of the non-memory inside testing service device.Third party's resource can be pre-stored in
In three servers, or is generated and obtained later by third-party server progress data processing.Third party's resource includes but is not limited to scheme
Piece resource, document resources and data resource etc..Picture resource includes but is not limited to static images, dynamic picture and dynamic video etc.
Resource.Document resources include but is not limited to the resources such as PDF.Data resource includes but is not limited to the money such as dynamic data and tables of data
Source.
For example, for realizing the examining system of foreign exchange transaction, need to connect the corresponding third party in exchange rate data center
Server is to obtain the dynamic exchange rate, risk control calculates the corresponding third-party server in center and calculated with obtaining computing resource
Processing etc., therefore examining system need to call exchange rate data center and risk control calculating center right respectively by code snippet to be measured
After the third-party server interface answered obtains third party's resource, final result can be just calculated to realize foreign exchange transaction business.
Step 208, processing result is intercepted and captured by test suite.
After testing service device gets third party's resource of third-party server return, examining system can be based on to be measured
Code snippet carries out data processing to third party's resource, to obtain processing result.The test suite being embedded in examining system
Processing result can be intercepted and captured from the function return value of code snippet to be measured.Examining system environment is in the case where system is integrally opened
Under, therefore the case where operating normally examining system, will be close to the data handling procedure of third party's resource, so that obtain
Processing result will be close to the obtained processing result of examining system in production environment.
Step 210, when processing result is consistent with expected results, determine that code snippet test to be measured passes through.
To test the number of transaction query function code of examining system for example, when the input data of test case can wrap
When including the input parameter such as user identifier, Sales Channel, product type, examining system can be called corresponding according to those input parameters
Transaction Inquiries function calls Transaction Inquiries function that can accordingly execute number of transaction query function code, then examining system can generate
Transaction Inquiries request, and Transaction Inquiries request is sent to third-party server.Third-party server can be asked according to Transaction Inquiries
User identifier, Sales Channel, product type of carrying etc. is asked to input parameter query Transaction Information resource, and by Transaction Information resource
Return to examining system.Examining system Transaction Information resource can be united by number of transaction query function code based on the received
Meter, obtains number of transaction as processing result.When the expection of the number of transaction in the processing result and test case that statistics obtains
As a result when consistent, then it can determine that number of transaction inquiry code tester passes through.
In above-mentioned code test method, testing service device create initial processes after, can in initial processes open system
Start thread with overall startup examining system.It, can be based on survey after testing service device obtains the test case comprising expected results
Example on probation executes the code snippet to be measured in examining system, obtains processing result.When the expection in processing result and test case
As a result when consistent, it is determined that code snippet test to be measured passes through.Start thread overall startup examining system by system, so as to
The test environment of examining system is close to production environment, so as to more accurately test examining system.
In one embodiment, test suite is called to start examining system, comprising: creation initial processes;Work as examining system
When being associated with multiple subsystems to be measured, test suite is called;It is opened in initial processes by test suite corresponding with examining system
System start thread, and system corresponding with each subsystem to be measured starts thread.
Test suite can first determine subsystem to be measured associated with the examining system of required starting, such as financial transaction system
System can be associated with multiple Java subsystems such as marketing system, ordering system and Order Query System.Test suite can be according to Java
The mode of thread starting is in initial processes respectively for financial transaction system and the creation system starting of correlation Java subsystem
Thread, system start thread and are used for overall startup financial transaction system and correlation Java subsystem.By one initially into
Combined launch examining system and multiple associated subsystems to be measured, enable to examining system and multiple associated sons to be measured in journey
System Sharing computer memory, so that the operating status of examining system is more nearly production environment.
In one embodiment, test case is obtained, the code snippet to be measured in examining system is executed based on test case,
Including;Obtain the system code file of test case and examining system;It is positioned in system code file based on test case
Code snippet to be measured, and obtain instance object corresponding with examining system;Code snippet to be measured is executed by instance object.
System code file refers to the uncompiled text file according to certain programming language specification writing.System
It include the code snippet to be measured of examining system in code file.It can determine the code mark of code snippet to be measured based on test case
Know, such as other specific character strings such as function name, so as to find generation corresponding with marking code in system code file
Chip segment, as code snippet to be measured.After obtaining the corresponding instance object of examining system, it can be called by instance object
The trial function to be measured found obtains third party's resource to execute code snippet to be measured from third-party server.
In one embodiment, code snippet to be measured is positioned in system code file based on test case, and obtain with
The corresponding instance object of examining system, comprising: extract the function information to be tested in test case;By function information to be tested
It is transferred to examining system;Obtain the corresponding class file path of function information to be tested that examining system returns;Class file path warp
Function information to be tested is parsed by examining system to generate;The corresponding class file of loading classes file path;Based on being created in class file
Instance object corresponding with examining system.
After starting business function to be tested, class to be tested and method for testing to be measured are waited test function letter to pass by test suite
Examining system is passed, so that examining system can parse function information to be tested, obtains corresponding class file path.Class file path
It can be the .class file path of class to be tested, so as to obtain corresponding .class text by loading .class file path
Part, i.e. class file.Instance object refers to the obtained object of class by instantiation, and object is abstracted to objective things,
Class is abstracted to object.Instantiation refers in the programming of object-oriented, usually the process with class creation object.Creation is real
After exampleization object, the code snippet to be measured of examining system can be called by instance object.
In one embodiment, method further include: when there are multiple test cases and multiple code snippets to be measured, identification
With each associated test case of code snippet to be measured;It will be with the identical associated test case of code snippet to be measured as test set
It closes;It is opened in initial processes and starts thread with every kind of test set corresponding system;Start thread according to multiple systems, holds respectively
Row is respectively corresponding to test the test case in gathering.
Different test cases can be used for calling the difference trial function to be measured in examining system, then different test cases can correspond to
In different code snippets to be measured.By test case and the required relevance for calling trial function to be measured, can know to obtain with each
The associated test case of code snippet to be measured.By using the associated test case of same test function code as a test set
It closes, then different test function associated codes can correspond to different test set.Due to for corresponding to identical code to be measured
Segment or the test case for occupying same asset, it is necessary to can only serially execute, otherwise it is possible that data collision causes to count
Mistake is calculated, therefore is separately turned on corresponding system starting thread by being directed to each test set in initial processes, then is made
It can be synchronized corresponding to different code snippets to be measured and execute test according to different test cases, and correspond to identical code piece to be measured
The test case of section successively can serially execute test.
In one embodiment, test case is being obtained, the code piece to be measured in examining system is executed based on test case
After section, further includes: monitor the execution duration of test case;When length is greater than preset duration when implemented, then test case is detected
Whether entire run;When test case entire run, it is determined that code snippet test crash to be measured;When test case is incomplete
It runs and there are when Network Abnormal information, then re-executes test case.
When the trial function to be measured in component to be tested is called in implementation of test cases, when the execution duration of test case is greater than
When preset duration, then illustrate that code snippet operation to be measured is unsuccessful.When detecting code snippet to be measured is entire run, but hold
Row duration is greater than preset duration, then it is abnormal to illustrate that the output of code snippet to be measured occurs, it is determined that code snippet test to be measured is lost
It loses, code snippet needs to be measured optimize debugging.When detecting code snippet to be measured is non-entire run, and there are networks
When exception information, then explanation may be different due to there is network during the network interaction of testing service device and third-party server
Code snippet operation to be measured is unsuccessful caused by often, then needs to re-execute test case when network is normal.It can also work as
When same test gathers corresponding test cases and has more than the test cases of preset ratio and execute failure, corresponding generation to be measured is generated
There is abnormal information and be added in test report in chip segment.By executing the corresponding code snippet to be measured of time-out to test case
It is analyzed, can be avoided influence of the incoherent factor to test result is judged.
In one embodiment, data analysis can be carried out by failure situation based on the test case after test.
After all test cases have been carried out, the test case for being identified as test crash can be screened, generate test case
Failure report;Statistical test use-case fails in the corresponding multiple test cases of each code snippet to be measured in report, test crash
Test case quantity;Quantity is sorted, can determine the corresponding code snippet to be measured of most test crash test cases;In
This section of code snippet to be measured is identified in the corresponding system code file of examining system, so that developer is to this section of generation to be measured
Chip segment optimizes adjustment.
In one embodiment, as shown in figure 3, providing another code test method, it is applied in Fig. 1 in this way
Testing service device 102 for be illustrated, comprising the following steps:
Step 302, initial processes are created by test suite, open system starts thread in initial processes;System opens
Moving-wire journey is used for overall startup examining system, and test suite is embedded in examining system.
Step 304, the system code file of test case and examining system is obtained by test suite;Test case
In include expected results.
Step 306, the function information to be tested in test case is extracted by test suite.
Step 308, function information to be tested is transferred to by examining system by test suite.
Step 310, the corresponding class file path of function information to be tested that examining system returns is obtained by test suite;
Class file path parses function information to be tested via examining system and generates.
Step 312, pass through the corresponding class file of test suite loading classes file path.
Step 314, creation instance object corresponding with examining system in class file is based on by test suite.
Step 316, the code snippet to be measured of examining system is executed by instance object, it is corresponding to code snippet to be measured
Third-party server sends resource acquisition request;Third-party server is used to send third party's resource based on resource acquisition request.
Step 318, third party's resource that third-party server returns is received;Third party's resource passes through code snippet tune to be measured
It is obtained with third-party server.
Step 320, examining system is intercepted and captured by test suite and the processing that data processing obtains is carried out based on third party's resource
As a result.
Step 322, when processing result is consistent with expected results, it is determined that code snippet test to be measured passes through.
In above-mentioned code test method, after testing service device creates initial processes, by test suite in initial processes
Middle open system starting thread is with overall startup examining system.Testing service device obtain comprising expected results test case it
Afterwards, the code snippet to be measured in examining system can be executed based on test case, so that testing service device can call third party's service
Third party's resource of device.Examining system can carry out data processing based on third party's resource, and testing service device can intercept and capture examining system
The processing result that data processing obtains is carried out based on third party's resource.When processing result is consistent with the expected results in test case
When, it is determined that code snippet test to be measured passes through.Start thread overall startup examining system by system, so that examining system
Environment is tested close to production environment, so as to more accurately test examining system, and by by test suite
It is embedded in examining system, then the interaction between test suite and examining system is not necessarily to call by interface, so as to more efficiently
Stable tests examining system, improves code tester efficiency.
It should be understood that although each step in the flow chart of Fig. 2 and 3 is successively shown according to the instruction of arrow,
It is these steps is not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps
There is no stringent sequences to limit for rapid execution, these steps can execute in other order.Moreover, in Fig. 2 and 3 at least
A part of step may include that perhaps these sub-steps of multiple stages or stage are not necessarily in same a period of time to multiple sub-steps
Quarter executes completion, but can execute at different times, the execution in these sub-steps or stage be sequentially also not necessarily according to
Secondary progress, but in turn or can replace at least part of the sub-step or stage of other steps or other steps
Ground executes.
In one embodiment, as shown in figure 4, providing a kind of code tester device 400, comprising:
System starting module 402, for calling test suite to start examining system.
Code tester module 404, for obtaining test case;Test case includes expected results;It is held based on test case
Code snippet to be measured in row examining system, obtains processing result.
As a result comparison module 406, for intercepting and capturing processing result by test suite;When processing result is consistent with expected results
When, determine that code snippet test to be measured passes through.
In one embodiment, system starting module 402 is also used to create initial processes;When examining system association it is multiple to
When surveying subsystem, test suite is called, opens system starting corresponding with examining system in initial processes by test suite
Thread, and system corresponding with each subsystem to be measured start thread.
In one embodiment, code tester module 404 is also used to obtain the system generation of test case and examining system
Code file;Code snippet to be measured is positioned in system code file based on test case, and obtains reality corresponding with examining system
Exampleization object;Code snippet to be measured is executed by instance object.
In one embodiment, code tester module 404 is also used to extract the function information to be tested in test case;It will
Function information to be tested is transferred to examining system;Obtain the corresponding class file road of function information to be tested that examining system returns
Diameter;Class file path parses function information to be tested via examining system and generates;The corresponding class file of loading classes file path;Base
Instance object corresponding with examining system is created in class file.
In one embodiment, code tester module 404 is also used to by executing the code snippet to be measured in examining system,
Generate resource acquisition request;Resource acquisition request is sent to third-party server;Third-party server is received to obtain based on resource
The third party's resource for taking request to return;Examining system is based on third party's resource and carries out data processing, obtains processing result.
In one embodiment, which further includes multithreading module 408, for when there are multiple test cases and multiple
When code snippet to be measured, identification and each associated test case of code snippet to be measured;It will be associated with identical code snippet to be measured
Test case as test set;It is opened in initial processes and starts thread with every kind of test set corresponding system;According to more
A system starts thread, executes the test case in respectively corresponding test set respectively.
In one embodiment, which further includes test detection module 410, when for monitoring the execution of test case
It is long;It is long when being greater than preset duration when implemented, then detect test case whether entire run;When test case entire run,
Then determine code snippet test crash to be measured;When the incomplete operation of test case and there are when Network Abnormal information, then hold again
Row test case.
Specific about code tester device limits the restriction that may refer to above for code test method, herein not
It repeats again.Modules in above-mentioned code tester device can be realized fully or partially through software, hardware and combinations thereof.On
Stating each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also store in a software form
In memory in computer equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction
Composition can be as shown in Figure 5.The computer equipment include by system bus connect processor, memory, network interface and
Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment
Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data
Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating
The database of machine equipment is for storing the data such as test case.The network interface of the computer equipment is used for logical with external terminal
Cross network connection communication.To realize a kind of code test method when the computer program is executed by processor.
It will be understood by those skilled in the art that structure shown in Fig. 5, only part relevant to application scheme is tied
The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment
It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, another computer equipment, including memory and processor, memory storage are provided
There is computer program, which realizes the step of the code test method in above-mentioned each embodiment when executing computer program
Suddenly.
In one embodiment, another computer readable storage medium is provided, computer program is stored thereon with, is counted
The step of code test method in the various embodiments described above is realized when calculation machine program is executed by processor.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Instruct relevant hardware to complete by computer program, computer program to can be stored in a non-volatile computer readable
It takes in storage medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, this Shen
Please provided by any reference used in each embodiment to memory, storage, database or other media, may each comprise
Non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
Above embodiments only express the several embodiments of the application, and the description thereof is more specific and detailed, but can not
Therefore it is construed as limiting the scope of the patent.It should be pointed out that for those of ordinary skill in the art, In
Under the premise of not departing from the application design, various modifications and improvements can be made, these belong to the protection scope of the application.
Therefore, the scope of protection shall be subject to the appended claims for the application patent.
Claims (10)
1. a kind of code test method, which comprises
Test suite is called to start examining system;
Obtain test case;The test case includes expected results;
The code snippet to be measured in the examining system is executed based on the test case, obtains processing result;
The processing result is intercepted and captured by the test suite;
When the processing result is consistent with the expected results, determine that the code snippet test to be measured passes through.
2. the method according to claim 1, wherein the calling test suite starts examining system, comprising:
Create initial processes;
When the examining system is associated with multiple subsystems to be measured, test suite is called;
System starting thread corresponding with the examining system is opened in the initial processes by the test suite, and
System corresponding with each subsystem to be measured starts thread.
3. the method according to claim 1, wherein described execute the examining system based on the test case
In code snippet to be measured, including;
Obtain the system code file of test case and the examining system;
Code snippet to be measured is positioned in the system code file based on the test case, and is obtained and the examining system
Corresponding instance object;
The code snippet to be measured is executed by the instance object.
4. according to the method described in claim 3, it is characterized in that, the test case that is based on is in the system code file
Code snippet to be measured is positioned, and obtains instance object corresponding with examining system, comprising:
Extract the function information to be tested in the test case;
The function information to be tested is transferred to the examining system;
The corresponding class file path of the function information to be tested for obtaining that the examining system returns;The class file path warp
It is generated by the examining system parsing function information to be tested;
Load the corresponding class file in the class file path;
Based on creation instance object corresponding with the examining system in the class file.
5. the method according to claim 1, wherein described execute the examining system based on the test case
In code snippet to be measured, obtain processing result, comprising:
By executing the code snippet to be measured in the examining system, resource acquisition request is generated;
Resource acquisition request is sent to third-party server;
Receive third party's resource that the third-party server is returned based on resource acquisition request;
The examining system is based on third party's resource and carries out data processing, obtains processing result.
6. the method according to claim 1, wherein the method also includes:
When there are multiple test cases and multiple code snippets to be measured, identification is used with each associated test of code snippet to be measured
Example;
It will be with the identical associated test case of code snippet to be measured as test set;
It is opened in the initial processes and starts thread with every kind of test set corresponding system;
Start thread according to multiple systems, executes the test case in respectively corresponding test set respectively.
7. the method according to claim 1, wherein executing the system to be measured based on the test case described
After code snippet to be measured in system, further includes:
Monitor the execution duration of the test case;
When the execution duration be greater than preset duration when, then detect the test case whether entire run;
When the test case entire run, it is determined that the code snippet test crash to be measured;
When the incomplete operation of test case and there are when Network Abnormal information, then the test case is re-executed.
8. a kind of code tester device, which is characterized in that described device includes:
System starting module, for calling test suite to start examining system;
Code tester module, for obtaining test case;The test case includes expected results;It is held based on the test case
Code snippet to be measured in the row examining system, obtains processing result;
As a result comparison module, for intercepting and capturing the processing result by the test suite;When the processing result with it is described pre-
When phase result is consistent, determine that the code snippet test to be measured passes through.
9. a kind of computer equipment, including memory and processor, the memory are stored with computer program, feature exists
In the step of processor realizes any one of claims 1 to 7 the method when executing the computer program.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program
The step of method described in any one of claims 1 to 7 is realized when being executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910610901.5A CN110502428A (en) | 2019-07-08 | 2019-07-08 | Code test method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910610901.5A CN110502428A (en) | 2019-07-08 | 2019-07-08 | Code test method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110502428A true CN110502428A (en) | 2019-11-26 |
Family
ID=68586152
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910610901.5A Pending CN110502428A (en) | 2019-07-08 | 2019-07-08 | Code test method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110502428A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113377648A (en) * | 2021-05-31 | 2021-09-10 | 五八到家有限公司 | Software system diagnosis method and device, electronic equipment and computer readable medium |
CN113656322A (en) * | 2021-08-26 | 2021-11-16 | 阿里巴巴(中国)有限公司 | Data processing method and device, electronic equipment and computer storage medium |
WO2022051974A1 (en) * | 2020-09-10 | 2022-03-17 | 深圳市大疆创新科技有限公司 | Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium |
CN116774016A (en) * | 2023-08-22 | 2023-09-19 | 北京象帝先计算技术有限公司 | Chip testing method, device, equipment and storage medium |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030126517A1 (en) * | 2001-07-27 | 2003-07-03 | Accordsqa | Automated software testing and validation system |
US20070240115A1 (en) * | 2006-03-31 | 2007-10-11 | Microsoft Corporation | Debugging in an operating system with multiple subsystems |
US20120284698A1 (en) * | 2011-05-05 | 2012-11-08 | International Business Machines Corporation | Program subset execution and debug |
CN103713991A (en) * | 2012-10-08 | 2014-04-09 | 腾讯科技(深圳)有限公司 | Method and device for testing application programs on Android devices |
CN104679644A (en) * | 2013-11-28 | 2015-06-03 | 比亚迪股份有限公司 | Testing method and system for application program in mobile terminal |
US20150169434A1 (en) * | 2013-12-18 | 2015-06-18 | Software Ag | White-box testing systems and/or methods in web applications |
CN109597759A (en) * | 2018-11-09 | 2019-04-09 | 深圳壹账通智能科技有限公司 | Test method and device, storage medium, the computer equipment of business software |
CN109783354A (en) * | 2018-12-14 | 2019-05-21 | 深圳壹账通智能科技有限公司 | Function test method, terminal device and the medium of application system |
CN109947646A (en) * | 2019-03-13 | 2019-06-28 | 平安信托有限责任公司 | Interface test method, device, computer equipment and storage medium |
-
2019
- 2019-07-08 CN CN201910610901.5A patent/CN110502428A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030126517A1 (en) * | 2001-07-27 | 2003-07-03 | Accordsqa | Automated software testing and validation system |
US20070240115A1 (en) * | 2006-03-31 | 2007-10-11 | Microsoft Corporation | Debugging in an operating system with multiple subsystems |
US20120284698A1 (en) * | 2011-05-05 | 2012-11-08 | International Business Machines Corporation | Program subset execution and debug |
CN103713991A (en) * | 2012-10-08 | 2014-04-09 | 腾讯科技(深圳)有限公司 | Method and device for testing application programs on Android devices |
CN104679644A (en) * | 2013-11-28 | 2015-06-03 | 比亚迪股份有限公司 | Testing method and system for application program in mobile terminal |
US20150169434A1 (en) * | 2013-12-18 | 2015-06-18 | Software Ag | White-box testing systems and/or methods in web applications |
CN109597759A (en) * | 2018-11-09 | 2019-04-09 | 深圳壹账通智能科技有限公司 | Test method and device, storage medium, the computer equipment of business software |
CN109783354A (en) * | 2018-12-14 | 2019-05-21 | 深圳壹账通智能科技有限公司 | Function test method, terminal device and the medium of application system |
CN109947646A (en) * | 2019-03-13 | 2019-06-28 | 平安信托有限责任公司 | Interface test method, device, computer equipment and storage medium |
Non-Patent Citations (4)
Title |
---|
CHANDARLEE: "Instrumentation Test Framework", 《HTTPS://WWW.JIANSHU.COM/P/E28868AB4882》 * |
XIAO1CHAN: "Android白盒测试之Instrumentation初探(一)", 《HTTPS://BLOG.CSDN.NET/YIWACHEN/ARTICLE/DETAILS/52464635》 * |
李江: "基于hook机制的android自动化脚本录制回放框架的设计与实现", 《软件》 * |
雨墨轩痕: "Android基础知识学习-Instrumentation启动源码简析", 《HTTPS://BLOG.CSDN.NET/OUYANGGENGCHENG/ARTICLE/DETAILS/87935561》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022051974A1 (en) * | 2020-09-10 | 2022-03-17 | 深圳市大疆创新科技有限公司 | Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium |
CN113377648A (en) * | 2021-05-31 | 2021-09-10 | 五八到家有限公司 | Software system diagnosis method and device, electronic equipment and computer readable medium |
CN113377648B (en) * | 2021-05-31 | 2023-06-06 | 五八到家有限公司 | Software system diagnosis method, device, electronic equipment and computer readable medium |
CN113656322A (en) * | 2021-08-26 | 2021-11-16 | 阿里巴巴(中国)有限公司 | Data processing method and device, electronic equipment and computer storage medium |
CN113656322B (en) * | 2021-08-26 | 2023-10-10 | 阿里巴巴(中国)有限公司 | Data processing method, device, electronic equipment and computer storage medium |
CN116774016A (en) * | 2023-08-22 | 2023-09-19 | 北京象帝先计算技术有限公司 | Chip testing method, device, equipment and storage medium |
CN116774016B (en) * | 2023-08-22 | 2023-12-19 | 北京象帝先计算技术有限公司 | Chip testing method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110502428A (en) | Code test method, device, computer equipment and storage medium | |
CN110399293B (en) | System test method, device, computer equipment and storage medium | |
US9672137B1 (en) | Shadow test replay service | |
US10909028B1 (en) | Multi-version regression tester for source code | |
US7774757B1 (en) | Dynamic verification of application portability | |
CN109947646A (en) | Interface test method, device, computer equipment and storage medium | |
CN110704306B (en) | Assertion processing method, device, equipment and storage medium in test | |
CN106970880B (en) | Distributed automatic software testing method and system | |
CN108427613B (en) | Abnormal interface positioning method and device, computer equipment and storage medium | |
US9836388B1 (en) | Software testing environment that includes a duplicating proxy service | |
CN109308263B (en) | Applet testing method, device and equipment | |
US20080155560A1 (en) | Multiple-application transaction monitoring facility for debugging and performance tuning | |
US9652353B2 (en) | Monitoring business transaction failures involving database procedure calls | |
CN112491659B (en) | Flow playback test method and device, computer equipment and storage medium | |
CN114978940B (en) | Link monitoring and alarming method, device, computer equipment and storage medium | |
CN112395202B (en) | Interface automation test method and device, computer equipment and storage medium | |
CN113791979B (en) | Dynamic debugging method and device for software product, computer equipment and storage medium | |
CN110413507A (en) | System detection method, device, computer equipment and storage medium | |
CN110928777A (en) | Test case processing method, device, equipment and storage medium | |
CN111858375A (en) | Software testing method, device, electronic equipment and medium | |
US20110016454A1 (en) | Method and system for testing an order management system | |
EP3734460B1 (en) | Probabilistic software testing via dynamic graphs | |
CN108920357A (en) | Operation system detection method, device, computer equipment and storage medium | |
CN109815139A (en) | Interface test method, device, computer equipment and storage medium | |
WO2023185266A1 (en) | Automatic detection method, single board, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191126 |
|
RJ01 | Rejection of invention patent application after publication |