CN113157590A - Test case generation method and device - Google Patents

Test case generation method and device Download PDF

Info

Publication number
CN113157590A
CN113157590A CN202110551853.4A CN202110551853A CN113157590A CN 113157590 A CN113157590 A CN 113157590A CN 202110551853 A CN202110551853 A CN 202110551853A CN 113157590 A CN113157590 A CN 113157590A
Authority
CN
China
Prior art keywords
program
function
test case
information
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110551853.4A
Other languages
Chinese (zh)
Other versions
CN113157590B (en
Inventor
杨伦
漆英
刘林新
胡文涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110551853.4A priority Critical patent/CN113157590B/en
Publication of CN113157590A publication Critical patent/CN113157590A/en
Application granted granted Critical
Publication of CN113157590B publication Critical patent/CN113157590B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

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

Abstract

The invention provides a test case generation method and device, which can be used in the financial field or other fields. The method comprises the following steps: according to a program of a test case to be generated, acquiring a plurality of program functions in a calling link of the program, and putting preset access functions in the program functions; running preset test data by using each program function added with the access function, and acquiring calling information of each program function through the access function; and generating a test case of the program according to the calling information of each program function. The invention sets the entrance function and the exit function for the program calling chain and records the calling information, thereby generating the high-quality test case and solving the problems of high cost, low efficiency and difficult maintenance of manually compiling the test case.

Description

Test case generation method and device
Technical Field
The invention relates to the technical field of test cases, in particular to a test case generation method and a test case generation device.
Background
The traditional test case mainly comprises three parts of input, function call and output and expected value comparison, and is a real call for a program. For items using the Mockito framework, services are usually applied outside the Mock, and the dependence among the services is eliminated through recording and replaying, so that the Mockito framework is simulated calling of service functions.
At present, two test cases have respective advantages and disadvantages. The traditional test case has the advantages that the codes are simple and are really called, and the traditional test case has the disadvantages that the traditional test case is relatively dependent on the external environment, is difficult to maintain and is inflexible, and does not conform to the idea of unit test. The Mockito test case is not dependent on environment and is easy to maintain, but input and output of each function call need to be simulated in the writing stage, and a large amount of time cost is also needed.
With the continuous update of scientific and technological products, the research and development period of projects is continuously shortened, the defect density is increased, and a high-quality test script is indispensable. However, writing and maintaining the test cases will inevitably increase the workload of developers and testers, which affects the development efficiency, and because the levels of the code writers are different, the quality of the test cases may not meet the requirements, and the core code is not really guarded.
Disclosure of Invention
Aiming at the problems in the prior art, the embodiment of the invention mainly aims to provide a test case generation method and a test case generation device, so that a high-quality test case is generated, and the problems of high cost, low efficiency and difficult maintenance of manually compiling the test case are solved.
In order to achieve the above object, an embodiment of the present invention provides a test case generation method, where the method includes:
according to a program of a test case to be generated, acquiring a plurality of program functions in a calling link of the program, and putting preset access functions in the program functions;
running preset test data by using each program function added with the access function, and acquiring calling information of each program function through the access function;
and generating a test case of the program according to the calling information of each program function.
Optionally, in an embodiment of the present invention, the obtaining, according to the program of the test case to be generated, a plurality of program functions in a call link of the program includes:
carrying out test class scanning on a program to be generated into a test case, and acquiring a bytecode object corresponding to a test class by using a reflection mechanism;
and according to a reflection mechanism, acquiring a plurality of program functions corresponding to the bytecode object, and labeling the program functions.
Optionally, in an embodiment of the present invention, the method further includes:
decompiling the calling information of each program function acquired by the access function to obtain byte code information;
and obtaining input information and output information corresponding to each program function according to the byte code information.
Optionally, in an embodiment of the present invention, the generating a test case of the program according to the call information of each program function includes: and generating a test case of the program according to the input information and the output information corresponding to each program function.
The embodiment of the invention also provides a test case generating device, which comprises:
the system comprises an access function module, a test case generation module and a test execution module, wherein the access function module is used for acquiring a plurality of program functions in a calling link of a program according to the program of the test case to be generated and putting a preset access function in the program functions;
the system comprises a calling information module, a data processing module and a data processing module, wherein the calling information module is used for running preset test data by utilizing each program function added into an access function and acquiring calling information of each program function through the access function;
and the test case module is used for generating the test case of the program according to the calling information of each program function.
Optionally, in an embodiment of the present invention, the entrance function module includes:
the bytecode object unit is used for scanning a test class of a program to be generated into a test case and acquiring a bytecode object corresponding to the test class by using a reflection mechanism;
and the program function unit is used for acquiring a plurality of program functions corresponding to the bytecode object according to a reflection mechanism and performing tagging processing on the program functions.
Optionally, in an embodiment of the present invention, the apparatus further includes:
the byte code information module is used for decompiling the calling information of each program function collected by the access function to obtain byte code information;
and the input and output information module is used for obtaining input information and output information corresponding to each program function according to the byte code information.
Optionally, in an embodiment of the present invention, the test case module is further configured to generate a test case of the program according to the input information and the output information corresponding to each program function.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
The invention sets the entrance function and the exit function for the program calling chain and records the calling information, thereby generating the high-quality test case and solving the problems of high cost, low efficiency and difficult maintenance of manually compiling the test case.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
FIG. 1 is a flowchart of a test case generation method according to an embodiment of the present invention;
FIG. 2 is a flow chart of obtaining program functions in an embodiment of the present invention;
FIG. 3 is a schematic diagram of an insert entry function according to an embodiment of the present invention;
FIG. 4 is a flow chart of a test case generation method in an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an access function according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a test case generating device according to an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of an entry/exit function module according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a test case generation apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a test case generation method and a test case generation device, which can be used in the financial field or other fields.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart illustrating a test case generating method according to an embodiment of the present invention, and an executing subject of the test case generating method according to the embodiment of the present invention includes, but is not limited to, a computer. The method shown in the figure comprises the following steps:
step S1, according to the program of the test case to be generated, obtaining a plurality of program functions in the calling link of the program, and putting a preset entrance function in the program functions.
The method comprises the steps of scanning a program of a test case to be generated, and acquiring all program functions of a program call link. Specifically, a program to be generated with a test case is scanned by a test class, and a bytecode object corresponding to the test class is acquired by using a reflection mechanism. Specifically, all injected Java bean objects are obtained from the spring container. The Java bean is a reusable component of Java language, and has respective properties and functions. The Spring container is a Java bean factory, is responsible for instantiation, acquisition and destruction of bean classes, and is the core of the Spring framework.
Furthermore, according to a Java reflection mechanism, a plurality of program functions corresponding to the bytecode object are obtained, and the program functions are labeled. Specifically, all bytecode objects of the test class are acquired through a Java reflection mechanism, and whether the objects are in a spring container or not is checked and judged. If yes, all program functions of the bytecode object are acquired through a reflection mechanism and are labeled.
Further, for the labeling procedure, it can be regarded as a section, and the preset access function (i.e. probe) is also put into the section.
And step S2, running preset test data by using each program function added with the access function, and acquiring the calling information of each program function through the access function.
The method comprises the steps of running preset test data by utilizing each program function added with an access function, and acquiring calling information of the program function through a probe, namely the access function.
Furthermore, the probe is a non-invasive collector (buried point) and is used for acquiring information such as input and output of actual calling of a function by adding the probe before and after calling of the program function.
Furthermore, the access function is also used for storing calling information in an array mode, and after the calling of the program function is finished, the calling information is stored in the database. And performing decompiling on the calling information to obtain byte code information, extracting input information and output information from the byte code information, and converting the output information and the input information into a JSON format.
And step S3, generating a test case of the program according to the calling information of each program function.
The input information and the output information acquired through the access function are converted into a test case, and specifically, the test case is a Mockito test case. Specifically, the examples are shown in table 1.
TABLE 1
Figure BDA0003075831260000051
Further, Mockito is a framework for generating proxy classes based on byteuddy (i.e., Java classes created and modified at Java application runtime), which essentially piles through Stub, accurately locates the test piles through function names plus parameters and then returns the expected values.
Furthermore, the Mockito test case, namely all functions, can be Mock away, and the input and output values before and after each function call are recorded, which is equivalent to the complete replay of one program operation, and has the advantages that the test case does not depend on the reproducibility of external data and environmental conditions.
As an embodiment of the present invention, as shown in fig. 2, acquiring, according to a program of a test case to be generated, a plurality of program functions in a call link of the program includes:
step S21, scanning the test class of the program to be generated into the test case, and acquiring the bytecode object corresponding to the test class by using a reflection mechanism;
step S22, according to the reflection mechanism, obtaining a plurality of program functions corresponding to the bytecode object, and performing tagging processing on the program functions.
The method comprises the steps of scanning a program of a test case to be generated, and acquiring all program functions of a program call link. Specifically, a program to be generated with a test case is scanned by a test class, and a bytecode object corresponding to the test class is acquired by using a reflection mechanism. Specifically, all injected Java bean objects are obtained from the spring container. The Java bean is a reusable component of Java language, and has respective properties and functions. The Spring container is a Java bean factory, is responsible for instantiation, acquisition and destruction of bean classes, and is the core of the Spring framework.
Furthermore, according to a Java reflection mechanism, a plurality of program functions corresponding to the bytecode object are obtained, and the program functions are labeled. Specifically, all bytecode objects of the test class are acquired through a Java reflection mechanism, and whether the objects are in a spring container or not is checked and judged. If yes, all program functions of the bytecode object are acquired through a reflection mechanism and are labeled.
Further, for the labeling procedure, it can be regarded as a section, and the preset access function (i.e. probe) is also put into the section.
In this embodiment, the function of adding the label can be regarded as a section, and the preset access function, i.e. the probe, is put into the section, as shown in fig. 3. Moreover, when the test case is started, java agent is used, so that byte codes can be replaced when the class is loaded, and implantation of the embedded point is completed.
In fig. 3, the traceID generates a globally unique link id when the service is invoked. The call logs of a request on the various servers can be concatenated by the traceID. The spanID is the position of the call in the whole call chain tree. onMethodEnter () is a function-in-time call that mainly gets the function's incoming parameters. Byteuddy provides a series of annotations with @ advice. OnMethodExit () is called when the function ends, and the principle is similar to onMethodEnter, and the return value of the function can be obtained.
Among them, Java agent, also called Java proxy, is an interceptor that runs before the main function. And tracking and acquiring the parameter input and parameter output information by utilizing the function of supporting the parameter output of the entry function.
As an embodiment of the present invention, as shown in fig. 4, the method further includes:
step S41, decompiling the calling information of each program function collected by the access function to obtain byte code information;
step S42, obtaining input information and output information corresponding to each program function according to the bytecode information.
The method comprises the steps of running preset test data by utilizing each program function added with an access function, and acquiring calling information of the program function through a probe, namely the access function.
Furthermore, the probe is a non-invasive collector (buried point) and is used for acquiring information such as input and output of actual calling of a function by adding the probe before and after calling of the program function.
Furthermore, the access function is also used for storing calling information in an array mode, and after the calling of the program function is finished, the calling information is stored in the database. And performing decompiling on the calling information to obtain byte code information, extracting input information and output information from the byte code information, and converting the output information and the input information into a JSON format.
Specifically, preset test data is operated in advance, function call information is collected through a probe, the probe is mainly divided into four parts, namely a Collector (Instrument), a transmitter (TransPort), a Collector (Collector) and a converter (Translator), the mutual relation is shown in fig. 5, Zipkin is an open-source distributed real-time data tracking system, and the main function is to gather real-time monitoring data from various heterogeneous systems.
A collector: the method mainly comprises the steps of injecting an onMethodeEnter () function and an OMethodeExit () function into a Mock function (section) in front and at back, and mainly used for acquiring calling information of each function in a calling chain and integrating the calling information into JavaAgents.
A transmitter: storing calling information in an array mode, and after function calling is finished, sending data to a collector for subsequent processing
A collector: and processing the received database, decompiling byte code information, and extracting input and output information.
A converter: and converting the acquired access information into a JSON format.
In this embodiment, generating the test case of the program according to the call information of each program function includes: and generating a test case of the program according to the input information and the output information corresponding to each program function.
The input information and the output information acquired through the access function are converted into a test case, and specifically, the test case is a Mockito test case.
The invention is based on the probe technology, intercepts the input and output information of the function, and converts the input and output information into the Mockito test case, so that the coding quality and the coding efficiency of the test code library can be greatly improved. The invention obtains the function of the bean class by scanning the compiled byte code file of the test class, then executes the preset embedded point logic in a chained mode, and further loads the modified test class. And pre-running test data, and acquiring input and output of each program function in the call chain through javaagent. And carrying out formatting conversion on the obtained data to generate the Mockito test case.
The invention sets the entrance function and the exit function for the program calling chain and records the calling information, thereby generating the high-quality test case and solving the problems of high cost, low efficiency and difficult maintenance of manually compiling the test case.
Fig. 6 is a schematic structural diagram of a test case generating apparatus according to an embodiment of the present invention, where the apparatus includes:
the gateway function module 10 is configured to obtain a plurality of program functions in a call link of a program according to the program of the test case to be generated, and put a preset gateway function in the program functions.
The method comprises the steps of scanning a program of a test case to be generated, and acquiring all program functions of a program call link. Specifically, a program to be generated with a test case is scanned by a test class, and a bytecode object corresponding to the test class is acquired by using a reflection mechanism. Specifically, all injected Java bean objects are obtained from the spring container. The Java bean is a reusable component of Java language, and has respective properties and functions. The Spring container is a Java bean factory, is responsible for instantiation, acquisition and destruction of bean classes, and is the core of the Spring framework.
Furthermore, according to a Java reflection mechanism, a plurality of program functions corresponding to the bytecode object are obtained, and the program functions are labeled. Specifically, all bytecode objects of the test class are acquired through a Java reflection mechanism, and whether the objects are in a spring container or not is checked and judged. If yes, all program functions of the bytecode object are acquired through a reflection mechanism and are labeled.
Further, for the labeling procedure, it can be regarded as a section, and the preset access function (i.e. probe) is also put into the section.
And the call information module 20 is configured to run preset test data by using each program function added to the access function, and collect call information of each program function through the access function.
The method comprises the steps of running preset test data by utilizing each program function added with an access function, and acquiring calling information of the program function through a probe, namely the access function.
Furthermore, the probe is a non-invasive collector (buried point) and is used for acquiring information such as input and output of actual calling of a function by adding the probe before and after calling of the program function.
Furthermore, the access function is also used for storing calling information in an array mode, and after the calling of the program function is finished, the calling information is stored in the database. And performing decompiling on the calling information to obtain byte code information, extracting input information and output information from the byte code information, and converting the output information and the input information into a JSON format.
And the test case module 30 is configured to generate a test case for the program according to the call information of each program function.
The input information and the output information acquired through the access function are converted into a test case, and specifically, the test case is a Mockito test case.
Further, Mockito is a framework for generating proxy classes based on byteuddy (i.e., Java classes created and modified at Java application runtime), which essentially piles through Stub, accurately locates the test piles through function names plus parameters and then returns the expected values.
Furthermore, the Mockito test case, namely all functions, can be Mock away, and the input and output values before and after each function call are recorded, which is equivalent to the complete replay of one program operation, and has the advantages that the test case does not depend on the reproducibility of external data and environmental conditions.
As an embodiment of the present invention, as shown in fig. 7, the inlet/outlet function module 10 includes:
the bytecode object unit 11 is configured to perform test class scanning on a program to be generated into a test case, and acquire a bytecode object corresponding to a test class by using a reflection mechanism;
the program function unit 12 is configured to obtain a plurality of program functions corresponding to the bytecode object according to a reflection mechanism, and perform tagging processing on the program functions.
As an embodiment of the present invention, as shown in fig. 8, the apparatus further includes:
a byte code information module 40, configured to perform decompiling on the call information of each program function collected by the access function, so as to obtain byte code information;
and an input/output information module 50, configured to obtain input information and output information corresponding to each program function according to the bytecode information.
In this embodiment, the test case module is further configured to generate a test case of the program according to the input information and the output information corresponding to each program function.
Based on the same application concept as the test case generation method, the invention also provides the test case generation device. Because the principle of solving the problems of the test case generation device is similar to that of the test case generation method, the implementation of the test case generation device can refer to the implementation of the test case generation method, and repeated parts are not described again.
The invention sets the entrance function and the exit function for the program calling chain and records the calling information, thereby generating the high-quality test case and solving the problems of high cost, low efficiency and difficult maintenance of manually compiling the test case.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
As shown in fig. 9, the electronic device 600 may further include: communication module 110, input unit 120, audio processing unit 130, display 160, power supply 170. It is noted that the electronic device 600 does not necessarily include all of the components shown in FIG. 9; furthermore, the electronic device 600 may also comprise components not shown in fig. 9, which may be referred to in the prior art.
As shown in fig. 9, the central processor 100, sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, the central processor 100 receiving input and controlling the operation of the various components of the electronic device 600.
The memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information relating to the failure may be stored, and a program for executing the information may be stored. And the central processing unit 100 may execute the program stored in the memory 140 to realize information storage or processing, etc.
The input unit 120 provides input to the cpu 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used to display an object to be displayed, such as an image or a character. The display may be, for example, an LCD display, but is not limited thereto.
The memory 140 may be a solid state memory such as Read Only Memory (ROM), Random Access Memory (RAM), a SIM card, or the like. There may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes called an EPROM or the like. The memory 140 may also be some other type of device. Memory 140 includes buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application/function storage section 142, and the application/function storage section 142 is used to store application programs and function programs or a flow for executing the operation of the electronic device 600 by the central processing unit 100.
The memory 140 may also include a data store 143, the data store 143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage portion 144 of the memory 140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging application, address book application, etc.).
The communication module 110 is a transmitter/receiver 110 that transmits and receives signals via an antenna 111. The communication module (transmitter/receiver) 110 is coupled to the central processor 100 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, may be provided in the same electronic device. The communication module (transmitter/receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and receive audio input from the microphone 132 to implement general telecommunications functions. Audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, an audio processor 130 is also coupled to the central processor 100, so that recording on the local can be enabled through a microphone 132, and so that sound stored on the local can be played through a speaker 131.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A test case generation method, characterized in that the method comprises:
according to a program of a test case to be generated, acquiring a plurality of program functions in a calling link of the program, and putting preset access functions in the program functions;
running preset test data by using each program function added with the access function, and acquiring calling information of each program function through the access function;
and generating a test case of the program according to the calling information of each program function.
2. The method of claim 1, wherein the obtaining, according to the program of the test case to be generated, the plurality of program functions in the call link of the program comprises:
carrying out test class scanning on a program to be generated into a test case, and acquiring a bytecode object corresponding to a test class by using a reflection mechanism;
and according to a reflection mechanism, acquiring a plurality of program functions corresponding to the bytecode object, and labeling the program functions.
3. The method of claim 1, further comprising:
decompiling the calling information of each program function acquired by the access function to obtain byte code information;
and obtaining input information and output information corresponding to each program function according to the byte code information.
4. The method of claim 3, wherein generating the test case of the program according to the calling information of each program function comprises: and generating a test case of the program according to the input information and the output information corresponding to each program function.
5. A test case generation apparatus, the apparatus comprising:
the system comprises an access function module, a test case generation module and a test execution module, wherein the access function module is used for acquiring a plurality of program functions in a calling link of a program according to the program of the test case to be generated and putting a preset access function in the program functions;
the system comprises a calling information module, a data processing module and a data processing module, wherein the calling information module is used for running preset test data by utilizing each program function added into an access function and acquiring calling information of each program function through the access function;
and the test case module is used for generating the test case of the program according to the calling information of each program function.
6. The apparatus of claim 5, wherein the inlet and outlet function module comprises:
the bytecode object unit is used for scanning a test class of a program to be generated into a test case and acquiring a bytecode object corresponding to the test class by using a reflection mechanism;
and the program function unit is used for acquiring a plurality of program functions corresponding to the bytecode object according to a reflection mechanism and performing tagging processing on the program functions.
7. The apparatus of claim 5, further comprising:
the byte code information module is used for decompiling the calling information of each program function collected by the access function to obtain byte code information;
and the input and output information module is used for obtaining input information and output information corresponding to each program function according to the byte code information.
8. The apparatus of claim 7, wherein the test case module is further configured to generate the test cases of the program according to the input information and the output information corresponding to each program function.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 4.
CN202110551853.4A 2021-05-20 2021-05-20 Test case generation method and device Active CN113157590B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110551853.4A CN113157590B (en) 2021-05-20 2021-05-20 Test case generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110551853.4A CN113157590B (en) 2021-05-20 2021-05-20 Test case generation method and device

Publications (2)

Publication Number Publication Date
CN113157590A true CN113157590A (en) 2021-07-23
CN113157590B CN113157590B (en) 2024-08-09

Family

ID=76876867

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110551853.4A Active CN113157590B (en) 2021-05-20 2021-05-20 Test case generation method and device

Country Status (1)

Country Link
CN (1) CN113157590B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115344502A (en) * 2022-10-18 2022-11-15 中建电子商务有限责任公司 Method for automatically generating mock data and automatically loading mock data based on real data

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681903A (en) * 2015-11-11 2017-05-17 阿里巴巴集团控股有限公司 Method and device for generating test case
CN111382073A (en) * 2020-03-09 2020-07-07 腾讯科技(深圳)有限公司 Automatic test case determination method, device, equipment and storage medium
CN111459824A (en) * 2020-04-01 2020-07-28 腾讯科技(深圳)有限公司 Test case processing method and device for concurrent service
CN111859380A (en) * 2019-04-25 2020-10-30 北京九州正安科技有限公司 Zero false alarm detection method for Android App vulnerability
CN111930617A (en) * 2020-07-31 2020-11-13 中国工商银行股份有限公司 Automatic testing method and device based on data objectification
CN112749094A (en) * 2021-01-14 2021-05-04 中国工商银行股份有限公司 Test case generation method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106681903A (en) * 2015-11-11 2017-05-17 阿里巴巴集团控股有限公司 Method and device for generating test case
CN111859380A (en) * 2019-04-25 2020-10-30 北京九州正安科技有限公司 Zero false alarm detection method for Android App vulnerability
CN111382073A (en) * 2020-03-09 2020-07-07 腾讯科技(深圳)有限公司 Automatic test case determination method, device, equipment and storage medium
CN111459824A (en) * 2020-04-01 2020-07-28 腾讯科技(深圳)有限公司 Test case processing method and device for concurrent service
CN111930617A (en) * 2020-07-31 2020-11-13 中国工商银行股份有限公司 Automatic testing method and device based on data objectification
CN112749094A (en) * 2021-01-14 2021-05-04 中国工商银行股份有限公司 Test case generation method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115344502A (en) * 2022-10-18 2022-11-15 中建电子商务有限责任公司 Method for automatically generating mock data and automatically loading mock data based on real data
CN115344502B (en) * 2022-10-18 2023-03-10 中建电子商务有限责任公司 Method for automatically generating mock data and automatically loading mock data based on real data

Also Published As

Publication number Publication date
CN113157590B (en) 2024-08-09

Similar Documents

Publication Publication Date Title
CN111930617B (en) Automatic test method and device based on data objectification
CN114138372B (en) Front-end component loading method and device
CN111782266B (en) Software performance benchmark determination method and device
CN110543301B (en) Method and device for generating jenkins code file
CN112988601A (en) Test script development method and device
CN112463634A (en) Software testing method and device under micro-service architecture
CN114003451B (en) Interface testing method, device, system and medium
CN114138674A (en) Automatic testing method and device and computer equipment
CN110196720B (en) Optimization method for generating dynamic link library by Simulink
CN114138633A (en) Method, device and equipment for testing software based on data driving and readable medium
CN112860264A (en) Abstract syntax tree reconstruction method and device
CN110221840B (en) Function implementation method and device of application program, equipment and storage medium
CN113157590A (en) Test case generation method and device
CN113157559B (en) Flow screening method and device
CN112860585B (en) Test script assertion generation method and device
CN112785284B (en) Message warehousing method and device based on structured document
CN112948247A (en) Processing method, system, device and medium for operation playback of application program
CN113297095A (en) Method and device for determining branch of subprogram calling path
CN112749094A (en) Test case generation method and device
CN113515447B (en) Automatic testing method and device for system
CN112988603B (en) Big data test case generation method and device
CN110851313B (en) Sensor debugging method, intelligent terminal, storage medium and electronic equipment
CN114676436A (en) Android application multimedia analysis library vulnerability mining system and method based on structural variation
CN113419957A (en) Rule-based big data offline batch processing performance capacity scanning method and device
CN118261143B (en) Json data analysis method, device, equipment and medium in Unity environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant