CN116701159A - Test case generation method and device, electronic equipment and storage medium - Google Patents

Test case generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116701159A
CN116701159A CN202210190751.9A CN202210190751A CN116701159A CN 116701159 A CN116701159 A CN 116701159A CN 202210190751 A CN202210190751 A CN 202210190751A CN 116701159 A CN116701159 A CN 116701159A
Authority
CN
China
Prior art keywords
target
service
function
test case
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.)
Pending
Application number
CN202210190751.9A
Other languages
Chinese (zh)
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210190751.9A priority Critical patent/CN116701159A/en
Publication of CN116701159A publication Critical patent/CN116701159A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

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

Abstract

The embodiment of the disclosure provides a test case generation method, a device, electronic equipment and a storage medium, wherein pre-storage request data are obtained, and are generated based on online data, wherein the online data are used for representing a business request for target service; inputting pre-stored request data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and is generated by inserting an objective function in the target service; the test case reference data is used for representing a state value of an objective function in the objective service after responding to the online data; based on the test case reference data, a target test case is generated, and the target test case is used for testing a target function in a target service, and because the target test case is generated based on a real online request, the target test case can be more in line with a real running environment, and the test effect is improved.

Description

Test case generation method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a test case generation method, a device, electronic equipment and a storage medium.
Background
The unit test is a test work for checking the correctness of a functional module, a function or a class in the process of program development, and the change of the module can be well controlled through the unit test, so that the problem that a plurality of modules are mutually overlapped and influenced in the later stage of program development, so that bug is too much and difficult to correct is prevented, and the unit test is a high-cost engineering quality assurance means.
The conventional unit test technology is generally based on manually writing test cases, or generating a unit test template through a unit test template generating tool, and generating the test cases for testing by combining manually set input parameters and output parameters.
However, in the actual unit testing process, for some unit tests affected by the testing environment, because the real running environment of the function cannot be simulated, the simple test can be performed only by manually setting some specific values, so that the test case cannot embody the real running environment of the function, and the unit testing efficiency and the testing effect are affected.
Disclosure of Invention
The embodiment of the disclosure provides a test case generation method, a device, electronic equipment and a storage medium, which are used for solving the problems of low test efficiency and poor test effect caused by the fact that unit test in the prior art cannot simulate the real running environment of a function.
In a first aspect, an embodiment of the present disclosure provides a test case generating method, including:
obtaining pre-stored data, the pre-stored data being generated based on online data, the online data being used to characterize a business request for a target service; inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting a target function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data; and generating a target test case based on the test case reference data, wherein the target test case is used for testing the target function in the target service.
In a second aspect, an embodiment of the present disclosure provides a test case generating apparatus, including:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring pre-stored data, the pre-stored data is generated based on online data, and the online data is used for representing a business request for a target service;
the first generation module is used for inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting an objective function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data;
The second generation module is used for generating a target test case based on the test case reference data, wherein the target test case is used for testing a target function in the target service.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes the computer-executable instructions stored in the memory to implement the test case generation method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer readable storage medium having stored therein computer executable instructions that when executed by a processor implement the test case generating method according to the first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the test case generating method according to the first aspect and the various possible designs of the first aspect.
According to the test case generation method, the device, the electronic equipment and the storage medium, pre-stored data are obtained, the pre-stored data are generated based on online data, and the online data are used for representing business requests for target services; inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting a target function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data; and generating a target test case based on the test case reference data, wherein the target test case is used for testing the target function in the target service, and the test case reference data for generating the target test case is generated based on a real online request, so that the test parameters corresponding to the test case can be more in accordance with the real running environment of the target function, and the unit test effect is improved.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, a brief description will be given below of the drawings that are needed in the embodiments or the description of the prior art, it being obvious that the drawings in the following description are some embodiments of the present disclosure, and that other drawings may be obtained from these drawings without inventive effort to a person of ordinary skill in the art.
FIG. 1 is an application scenario diagram of a test case generation method provided by an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a test case generation method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating steps performed in step S101 in the embodiment shown in FIG. 2;
FIG. 4 is a schematic diagram illustrating the generation of pre-stored data according to an embodiment of the present disclosure;
FIG. 5 is a flowchart showing the steps for generating the target test service in step S102;
FIG. 6 is a second flowchart of a test case generating method according to an embodiment of the present disclosure;
FIG. 7 is a schematic illustration of a directed acyclic graph provided by an embodiment of the disclosure;
FIG. 8 is a schematic diagram of a process for determining the location of an object code according to an embodiment of the present disclosure;
FIG. 9 is a schematic diagram of inserting stub functions at object code locations provided by an embodiment of the present disclosure;
FIG. 10 is a block diagram of a test case generating device according to an embodiment of the present disclosure;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure;
fig. 12 is a schematic hardware structure of an electronic device according to an embodiment of the disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure are intended to be within the scope of this disclosure.
The application scenario of the embodiments of the present disclosure is explained below:
fig. 1 is an application scenario diagram of a test case generating method provided by an embodiment of the present disclosure, where the test case generating method provided by the embodiment of the present disclosure may be applied to an application scenario of an automation unit test. Specifically, the method provided by the embodiment of the present disclosure may be applied to a terminal device or a server, as shown in fig. 1, where the method is introduced by using a code server as an execution body. When a developer user modifies a program code, for example, modifies or adds a certain objective function in the application program, and synchronizes the modified objective function into the code warehouse in the code server, the code server generates a test case corresponding to the objective function indicated by the test information according to the test information (not shown in the figure) input by the user based on the method provided by the embodiment. And sending the generated test case to the terminal equipment to finish the delivery of the test case.
In the prior art, the unit test technology is generally based on manually writing test cases, or generating a unit test template through a unit test template generating tool, and generating the test cases for testing by combining manually set input parameters and output parameters. However, in the actual unit test process, for some complex functions affected by the test environment, such as timing activities, short-term effect credentials, etc., because the constructed unit test is affected by the change of the running time, the environment variables or the return values of the downstream functions in the constructed unit test, the running logic in the function is changed, so that the actual output result of the function is inconsistent with the expected output result, and the unit test accuracy is affected.
Therefore, the test cases cannot embody the real running environment of the functions, so that the problem of influencing the unit test efficiency and the test effect is caused. The embodiment of the disclosure provides a test case generation method to solve the above problems.
Fig. 2 is a flowchart of a test case generating method according to an embodiment of the present disclosure. The method of the embodiment can be applied to a server or terminal equipment, and in the embodiment, introduction is performed by taking the server as an execution main body, and the test case generating method comprises the following steps:
step S101: pre-stored data is obtained, the pre-stored data being generated based on online data, the online data being used to characterize a business request for a target service.
The target service in the present embodiment may refer to a program for running within the service for realizing a specific function, such as a user login service, a verification service, or the like, for example. The target service has a specific service interface, and other applications or services call the target service through the interface of the target service, thereby realizing the specific business request of the target service.
Further, one or more function functions are included in the target service, the function functions include the target function, and the one or more function functions in the target service are used for realizing corresponding functions, so that complete functions of the target service are realized. Specifically, for example, the target service is a service for user login, and in order to realize the function of the target service, the code file corresponding to the target service includes a plurality of function functions, for example, functions for realizing user name validity detection, password validity detection, security detection, database access, login state control, and the like, respectively. The objective function is one or more of all the function functions. In this embodiment, the objective function is a test object for unit test, and in the subsequent step, the function of the objective function is tested by generating a test case corresponding to the objective function, so as to determine that the function of the objective function is normal.
The online data is data representing a service request for a target service, wherein the online data may be real online service data, for example, other terminal devices need to access the target service to achieve the purpose of user login, at this time, the service request for the target service is a login request, further, the login request includes information such as a user name, a password, an IP address, and the like, the login request is generated in a real online service environment, that is, request information sent by a user through other terminal devices truly, and a set of request information sent by the user for the service request for the target service is online data. Further, based on the obtained online data, corresponding response data are obtained, the online data and the response data are copied, necessary encoding and storage are carried out, and the obtained data are pre-stored data. Wherein the pre-stored data is capable of characterizing a business request for the target service and a result of the target service responding to the business request.
In one possible implementation, as shown in fig. 3, the implementation step of step S101 includes:
in step S1011, online data is acquired.
In step S1012, online data is copied to the message queue based on the preset flow agent service.
In step S1013, pre-stored data is generated from the message queue.
Fig. 4 is a schematic diagram of generation of pre-stored data according to an embodiment of the present disclosure, and referring to fig. 4, on a traffic flow link, by setting a traffic proxy service before a target service, a traffic request flow (i.e., online data) is sent to the target service after passing through the traffic proxy service. After obtaining the online data, the flow agent service sequentially copies the online data to a message queue, and then asynchronously stores the online data to a service database in a streaming mode based on the message queue to generate pre-stored data. The above process may be implemented by using a kafka database, and the process will not be described here.
Step S102: inputting pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and is generated by inserting an objective function in the target service; the test case reference data is used for representing state values of the objective function in the objective service after the objective function responds to the online data.
The target test service is illustratively a program generated by instrumentation of the target service, and the target test service is disposed in an offline environment, i.e., an isolated environment, which refers to an environment that is not truly online, but that can run the target service, which may be artificially constructed to simulate a virtual environment of a real online environment. The purpose of instrumentation is to obtain a state value of an objective function when the objective service is running to the objective function based on pre-stored data. More specifically, the target test service is a program generated after the objective function in the target service is inserted, and the stub function is inserted into a position corresponding to the objective function in the target service, so that the target test service can output a state value of the objective function corresponding to the stub function when the objective function is operated in the operation process of the target service, thereby determining information such as an input value, an output value and an operation state in the function of the objective function, namely test case reference data.
Illustratively, before the target test service is used to generate test case reference data, the target service needs to be inserted in advance, so as to generate a target test service corresponding to the target service. In one possible implementation, as shown in fig. 5, the step of generating the target test service includes:
Step S1021, a code file corresponding to the target service is acquired.
Step S1022, the code file is parsed to determine the target code position, and the target code position represents the position of the state value of the target function in the target service in the code file corresponding to the target service.
Step S1023, based on the target code position, the code files corresponding to the target service are inserted, and the target test service is generated.
The code file corresponding to the target service includes codes required for running the target service, and a specific instrumentation position, i.e., a target code position, needs to be determined by traversing the codes in the code file before the target service is instrumented. The state value of the target function corresponds to the position of the state value of the target function in the code file corresponding to the target service, and the state value of the target function comprises at least one of the following: input parameters of the objective function, output parameters of the objective function, return values of downstream functions within the objective function. Accordingly, for example, the object code location includes: the location of the input parameters of the objective function in the code file, the location of the output parameters of the objective function in the code file, the location of the downstream functions of the objective function in the code file, etc. The above process of determining the target code location may be performed by parsing the code file, determining an abstract syntax tree of the code file, and determining based on the abstract syntax tree, which will not be described herein.
Step S103: based on the test case reference data, generating a target test case, wherein the target test case is used for testing a target function in a target service.
After the test case reference data is obtained, the access parameter information of the objective function and the return value of the downstream function inside the objective function can be determined according to the state value of the objective function in the objective service represented by the test case reference data after the objective function responds to the online data, and further, the function environment corresponding to the real service request is restored according to the access parameter information of the objective function and the mock function constructing the downstream function, so that a unit test file matched with the objective function, namely the objective test case, is generated. The target function is tested through the target test case, so that the test effect of testing the target function in a simulated real environment can be achieved.
In this embodiment, pre-stored data is generated based on online data that characterizes a business request for a target service by acquiring the pre-stored data; inputting pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and is generated by inserting an objective function in the target service; the test case reference data is used for representing a state value of an objective function in the objective service after responding to the online data; based on the test case reference data, generating a target test case, wherein the target test case is used for testing the target function in the target service, and because the test case reference data for generating the target test case is generated based on the real online request, the test parameters corresponding to the test case can be more in accordance with the real running environment of the target function, and the unit test effect is improved.
Fig. 6 is a second flowchart of a test case generating method according to an embodiment of the present disclosure. The embodiment refines the steps S102-S103 and adds the step of generating the target test service on the basis of the embodiment shown in fig. 2, and the test case generating method includes:
step S201, a code file corresponding to the target service is obtained, and a directed acyclic graph is obtained based on the code file.
Directed acyclic graph (Directed acyclic graph, DAG) refers to a loop-free directed graph, in which a directed acyclic graph is one if it cannot go from a certain vertex back to the point through several edges. In this embodiment, the directed acyclic graph is a data structure that is obtained after the code file is parsed and represents the priority relationship and the dependency relationship between functions. Specifically, after obtaining a code file corresponding to a target service, the code file is parsed, the code is converted into a syntax tree (AST tree), and then the code text is converted into a directed acyclic graph through the AST tree. The steps of obtaining an AST tree corresponding to the code file and converting the code text in the code file by using the AST tree are known to those skilled in the art, and are not described herein.
Step S202, traversing the directed acyclic graph, and determining the target code position according to the types of the code elements corresponding to each node in the directed acyclic graph.
Fig. 7 is a schematic diagram of a directed acyclic graph provided by an embodiment of the present disclosure, and after a code file is parsed with reference to fig. 7, the obtained directed acyclic graph sequentially includes six nodes according to an execution sequence, where each node corresponds to a code element for implementing a specific function, and more specifically, as shown in the drawing, the specific functions respectively represented by the six nodes are "define function expression", "variable a assignment", "call while statement", "variable B assignment", "variable C assignment", "variable D assignment". The "definition function expression" may correspond to a function a (an implementation of a code element), where the function a includes an assignment statement (an implementation of a code element, the same applies hereinafter) for implementing "variable a assignment", and a function B (an implementation of a code element, corresponding to a downstream function in the function a) corresponding to "while statement", and includes three assignment statements corresponding to "variable B assignment", "variable C assignment", and "variable D assignment" respectively, in the function B. Referring to the directed acyclic graph shown in fig. 7, after traversing each node in the directed acyclic graph, code elements corresponding to each node in the directed acyclic graph, and position information and name information of each code element can be determined, wherein the code elements have corresponding types, such as assignment statements and function call statements, according to a mapping relationship between preset name information and types of the code elements, which nodes can be key nodes capable of representing the running state of the function can be determined, further, according to the position information corresponding to the key nodes, the target code position can be determined, in a subsequent step, by inserting a stub function into the target code position, the node information of the key nodes can be obtained, so that the state value of the target function is formed, and the function of the target test service is realized.
Further, illustratively, the type of code element includes at least one of: assignment statements, stateless system function statements, stateful call function statements, which are statements for calling stateful calculation functions provided by the system. Specifically, stateless system function statements, such as statements that call "delete instructions", stateful system function statements, such as statements that call "system time", are affected by the running environment, while stateless system function statements are not affected by the environment. In this embodiment, for some system call functions, the corresponding positions are not determined as target code positions or are not instrumented (i.e. instrumentation of such system call functions is omitted), because the logic is generally stateless computing logic, belongs to stateless code execution logic, and the corresponding return values are not affected by specific environments, so that data collection may not be performed for such functions. And only the nodes corresponding to the assignment statement and the nodes corresponding to the function statement (e.g. function of time. Now () depending on the environment state) of the stateful system are spliced, so that function operation logic (e.g. when the system time is different, the function operation logic is different and is applied to a timed virtual red packet issuing scene) under different environments can be covered, and the restoration of the function operation site is realized to the greatest extent. In one possible implementation, determining the target code location includes: traversing the directed acyclic graph, and determining the positions of code elements corresponding to the assignment statement and the stateless system function statement as target code positions. In the embodiment, the positions of the code elements corresponding to the assignment statement and the stateless system function statement are determined to be the target code positions, so that the number of the inserted piles can be reduced, the collection of useless data is reduced, and the data collection efficiency is improved.
FIG. 8 is a schematic diagram of a process for determining a target code location according to an embodiment of the present disclosure, with reference to FIG. 8, after a corresponding directed acyclic graph is obtained by parsing and converting a code file of a target service, code elements in the code file are traversed based on the directed acyclic graph, and specifically, the code elements may correspond to code statements of a code line; as shown in fig. 7, after traversing to code element a, determining the target code position (i.e., stub function insertion position, the same applies hereinafter) of code element a as the upper and lower rows of the code row in which code element a is located; after traversing to code element B, determining the target code position of code element B as the next line of the code line in which code element B is located. Specifically, the stub function inserted by the target code position of the code element a is used for uploading the function input function and uploading the parameter value, and the stub function inserted by the target code position of the code element B is used for uploading the downstream function return value, so that test case reference data is generated. Wherein the type of the code element A is a type, the type of the code element B is a B type, and different types of the code elements have corresponding determination rules of target code positions, for example, the target code positions corresponding to the a type are the last row and the next row of the code elements corresponding to the a type; for example, the object code position corresponding to the b type is the next row of the code element corresponding to the b type, and the mapping relationship between the type of the code element and the determination rule of the object code position is preset. Note that, since the target service may be realized by running one function, the code file of the target service corresponds to the code file corresponding to one function.
And step S203, inserting a stub function corresponding to the objective function at the position of the objective code to generate the objective test service, wherein the stub function is used for uploading the state value of the corresponding objective function.
Illustratively, after determining the target code location, inserting a corresponding stub function at the target code location, a target test service capable of uploading a state value of the target function may be generated. Specifically, after confirming the location information, we insert different data collection codes (i.e. stub functions) according to the code elements of the corresponding types, for example, when traversing to the function input parameters, variable name information is extracted, the codes for constructing the uploading variable values are added to the original codes, thus when the functions are running, the corresponding uploading logic is triggered, and the field information of the functions is uploaded to the database related to the test case reference data, so that the function of the target test service is realized.
Fig. 9 is a schematic diagram of inserting a stub function at an object code position, as shown in fig. 9, where a code element "a, B: =childfunc ()" characterizes a function call statement (call function childFunc (), outputs a and B), after determining the object code position of the code element "a, B: =childfunc ()", i.e. the next row of the code line where the code element is located, two stub functions for uploading the output parameter "a" and the output parameter "B" of the function corresponding to the code element, i.e. "upload (). Param1, a)" and "upload (child (). Param2, B)", are inserted at the object code position, so that the output parameter "a" and the output parameter "B" are stored into the child func (). Param1 and child (). Param2, respectively, and then, through the corresponding global variables, the data is uploaded, and the state value of the uploaded object function is reached, and the object function is shown in fig. 9.
Further, in addition to uploading state values of the objective function, the objective test service is further used for outputting a directed acyclic graph representing a function structure of the objective function, and in a subsequent step, path restoration of the objective function can be achieved based on the directed acyclic graph output by the objective test service, and the purpose of building a mock function and simulating return values of downstream functions in the objective function can be achieved.
Step S204, obtaining pre-stored data through a preset request sending service in an offline environment, and analyzing the pre-stored data into online data.
Step S205, according to the online data, each objective function in the objective test service is operated in sequence.
In step S206, when executing the stub function into the target test service, the status value of the corresponding target function is obtained through the stub function.
Step S207, generating test case reference data according to the state value of the objective function.
By way of example, in this embodiment, by setting up an offline environment (isolation environment) in advance, a target service and a request sending service are set up in the offline environment, the request sending service will acquire and parse pre-stored data in the kafka database, and after the organization and the restoration, a request will be initiated to the target service that is instrumented, that is, the target test service. The target test service in the offline environment triggers the embedded point code (stub function) while processing the restored line data, so that the state values of the target functions such as input parameters, output parameters, global variables used by the functions, downstream information (downstream function information) of the target functions and the like are uploaded to a unit test case database to generate test case reference data.
In one possible implementation, the process of generating test case reference data by pre-storing data is equivalent to the process of playing back and utilizing online data, if after the step is completed, that is, after the data playback is completed, the status value uploaded by the function stub points in the target test service is used, it is found that some function returns or the stub points of the branches are not always touched (that is, all function functions in the target service cannot be covered), and combination mutation needs to be performed on online traffic data, for example, random exchange is performed on the values of json fields of a set of online request parameters, so as to obtain some new test cases, and thus, attempt to touch those very difficult to touch stub points.
Step S208, obtaining target test information, wherein the target test information comprises at least one of the following: the function name of the objective function, the input and output parameters of the objective function, the function name of the downstream function within the objective function, the global variable name and the corresponding variable value.
Step S209, based on a preset test case generation rule, generating a target test case according to the generated test case reference data and the target test information.
For example, the test case reference data generated by the target test service includes not only the state value of the target function after responding to the online data, but also the state value of the other function after responding to the online data, so that the test case reference data stored in the database is equivalent to the basic data for generating the target test cases corresponding to different target functions. The objective test information is information for indicating and determining the objective function, and the objective test information may be set based on the user's need, more specifically, for example, when the regression test is required for the objective function a, the objective test information is information for indicating the objective function a. Illustratively, the target test information includes: the function name of the objective function, the input and output parameters of the objective function, the function name of the downstream function within the objective function, the global variable name and the corresponding variable value. Through the information, an objective function can be completely determined, and then, the objective test case can be generated based on the preset test case generation rule and by combining the objective test information.
Specifically, the test case generation rule comprises a unit test code template, the unit test code template provides a basic framework for generating a unit test function, only the function name of a downstream function, the global variable name and value and the actual value of a function access parameter are required to be provided for code rendering, and a unit test file of the target function, namely the target test case, is rendered, wherein the actual value of the function access parameter can be obtained through generating test case reference data, the function name of the target function, the function name of the downstream function and the global variable name and value are obtained through target test information.
Corresponding to the test case generation method of the above embodiment, fig. 10 is a structural block diagram of the test case generation apparatus provided by the embodiment of the present disclosure. For ease of illustration, only portions relevant to embodiments of the present disclosure are shown. Referring to fig. 10, the test case generating device 3 includes:
the obtaining module 31 is configured to obtain pre-stored data, where the pre-stored data is generated based on online data, and the online data is used to characterize a service request for a target service;
the first generating module 32 is configured to input pre-stored data into a target test service corresponding to a target service, and generate test case reference data, where the target test service is set in an offline environment, and the target test service is generated by inserting an objective function in the target service; the test case reference data is used for representing a state value of an objective function in the objective service after responding to the online data;
The second generating module 33 is configured to generate a target test case based on the test case reference data, where the target test case is used to test the target function in the target service.
In one embodiment of the present disclosure, before the pre-stored data is input into the target test service corresponding to the target service and the test case reference data is generated, the first generating module 32 is further configured to: acquiring a code file corresponding to a target service; analyzing the code file, and determining the target code position, wherein the target code position represents the position of a state value of a target function in the target service in the code file corresponding to the target service; and based on the target code position, inserting the code file corresponding to the target service to generate the target test service.
In one embodiment of the present disclosure, the state value of the objective function within the objective service includes at least one of: input parameters of the objective function, output parameters of the objective function, return values of downstream functions within the objective function.
In one embodiment of the present disclosure, the first generation module 32 is specifically configured to, when parsing the code file to determine the target code location: acquiring a directed acyclic graph corresponding to a code file; traversing the directed acyclic graph, and determining the target code position according to the types of the code elements corresponding to each node in the directed acyclic graph.
In one embodiment of the present disclosure, the types of code elements include at least one of: assignment statement, stateless system function statement, stateful call function statement is statement for calling stateful calculation function provided by system;
the first generating module 32 is specifically configured to, when traversing the directed acyclic graph, determine the target code position according to the type of the code element corresponding to each node in the directed acyclic graph: traversing the directed acyclic graph, and determining the positions of code elements corresponding to the assignment statement and the stateless system function statement as target code positions.
In one embodiment of the present disclosure, the first generating module 32 is specifically configured to, when generating the target test service, perform instrumentation on a code file corresponding to the target service based on the target code location: and inserting a stub function corresponding to the objective function at the position of the objective code to generate the objective test service, wherein the stub function is used for uploading the state value of the corresponding objective function.
In one embodiment of the present disclosure, when the first generating module 32 inputs the pre-stored data into the target test service corresponding to the target service, the first generating module is specifically configured to: according to the pre-stored data, sequentially operating all objective functions in the objective test service; when executing the stub function into the target test service, acquiring a state value of a corresponding target function through the stub function; and generating test case reference data according to the state value of the objective function.
In one embodiment of the present disclosure, before the pre-stored data is input to the target test service corresponding to the target service and the test case reference data is generated, the obtaining module 31 is further configured to: the method comprises the steps of obtaining pre-stored data through a preset request sending service in an offline environment, and analyzing the pre-stored data into online data; the first generation module 32 is specifically configured to: and inputting the online data into a target test service to generate test case reference data.
In one embodiment of the present disclosure, the obtaining module 31 is specifically configured to: acquiring online data; copying the online data to a message queue based on a preset flow proxy service; and generating pre-stored data according to the message queue.
In one embodiment of the present disclosure, the second generating module 33 is specifically configured to: obtaining target test information, wherein the target test information comprises at least one of the following: function name of the objective function, input parameters and output parameters of the objective function, function name of downstream function in the objective function, global variable name and corresponding variable value; based on a preset test case generation rule, generating a target test case according to the generated test case reference data and the target test information.
The acquiring module 31, the first generating module 32, and the second generating module 33 are sequentially connected. The test case generating device 3 provided in this embodiment may execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, which is not described herein again.
Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure, where, as shown in fig. 11, the electronic device 4 includes
A processor 41 and a memory 42 communicatively connected to the processor 41;
memory 42 stores computer-executable instructions;
the processor 41 executes computer-executable instructions stored in the memory 42 to implement the test case generation method in the embodiment shown in fig. 2-9.
Wherein optionally the processor 41 and the memory 42 are connected by a bus 43.
The relevant descriptions and effects corresponding to the steps in the embodiments corresponding to fig. 2 to fig. 9 may be understood correspondingly, and are not described in detail herein.
Referring to fig. 12, there is shown a schematic structural diagram of an electronic device 900 suitable for use in implementing embodiments of the present disclosure, which electronic device 900 may be a terminal device or a server. The terminal device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a personal digital assistant (Personal Digital Assistant, PDA for short), a tablet (Portable Android Device, PAD for short), a portable multimedia player (Portable Media Player, PMP for short), an in-vehicle terminal (e.g., an in-vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 12 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 12, the electronic apparatus 900 may include a processing device (e.g., a central processor, a graphics processor, or the like) 901, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 902 or a program loaded from a storage device 908 into a random access Memory (Random Access Memory, RAM) 903. In the RAM 903, various programs and data necessary for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
In general, the following devices may be connected to the I/O interface 905: input devices 906 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 907 including, for example, a liquid crystal display (Liquid Crystal Display, LCD for short), a speaker, a vibrator, and the like; storage 908 including, for example, magnetic tape, hard disk, etc.; and a communication device 909. The communication means 909 may allow the electronic device 900 to communicate wirelessly or by wire with other devices to exchange data. While fig. 12 shows an electronic device 900 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When executed by the processing device 901, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above-described embodiments.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (Local Area Network, LAN for short) or a wide area network (Wide Area Network, WAN for short), or it may be connected to an external computer (e.g., connected via the internet using an internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In a first aspect, according to one or more embodiments of the present disclosure, there is provided a test case generating method, including:
obtaining pre-stored data, the pre-stored data being generated based on online data, the online data being used to characterize a business request for a target service; inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting a target function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data; and generating a target test case based on the test case reference data, wherein the target test case is used for testing the target function in the target service.
According to one or more embodiments of the present disclosure, before inputting the pre-stored data into a target test service corresponding to the target service, and generating test case reference data, the method further includes: acquiring a code file corresponding to the target service; analyzing the code file, and determining a target code position, wherein the target code position represents the position of a state value of a target function in the target service in the code file corresponding to the target service; and based on the target code position, inserting a code file corresponding to the target service to generate the target test service.
According to one or more embodiments of the present disclosure, the state value of the objective function within the objective service includes at least one of: input parameters of the objective function, output parameters of the objective function, return values of downstream functions within the objective function.
According to one or more embodiments of the present disclosure, the parsing the code file, determining an object code location, includes: acquiring a directed acyclic graph corresponding to the code file; and traversing the directed acyclic graph, and determining the target code position according to the type of the code element corresponding to each node in the directed acyclic graph.
According to one or more embodiments of the present disclosure, the types of code elements include at least one of: assignment statement, stateless system function statement, stateful call function statement, wherein the stateful call function statement is statement for calling stateful calculation function provided by system; traversing the directed acyclic graph, determining the target code position according to the types of the code elements corresponding to each node in the directed acyclic graph, including: traversing the directed acyclic graph, and determining the positions of the code elements corresponding to the assignment statement and the stateless system function statement as target code positions.
According to one or more embodiments of the present disclosure, based on the target code location, instrumentation is performed on a code file corresponding to the target service, and the target test service is generated, including: and inserting a stub function corresponding to the objective function in the objective code position to generate the objective test service, wherein the stub function is used for uploading the state value of the corresponding objective function.
According to one or more embodiments of the present disclosure, inputting the pre-stored data into a target test service corresponding to the target service, generating test case reference data includes: sequentially operating each objective function in the objective test service according to the pre-stored data; when the execution of the stub function in the target test service is performed, acquiring a state value of a corresponding target function through the stub function; and generating test case reference data according to the state value of the objective function.
According to one or more embodiments of the present disclosure, before inputting the pre-stored data into the target test service corresponding to the target service and generating the test case reference data, the method further includes: acquiring the pre-stored data through a preset request sending service in an offline environment, and analyzing the pre-stored data into the online data; inputting the pre-stored data into a target test service corresponding to the target service, and generating test case reference data, wherein the method comprises the following steps: and inputting the online data into the target test service to generate the test case reference data.
According to one or more embodiments of the present disclosure, the acquiring pre-stored data includes: acquiring the online data; copying the online data to a message queue based on a preset flow proxy service; and generating pre-stored data according to the message queue.
According to one or more embodiments of the present disclosure, generating a target test case based on the test case reference data includes: obtaining target test information, wherein the target test information comprises at least one of the following: function name of the objective function, input parameters and output parameters of the objective function, function name of downstream function in the objective function, global variable name and corresponding variable value; and generating a target test case according to the generated test case reference data and the target test information based on a preset test case generation rule.
In a second aspect, according to one or more embodiments of the present disclosure, there is provided a test case generating apparatus including:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring pre-stored data, the pre-stored data is generated based on online data, and the online data is used for representing a business request for a target service;
the first generation module is used for inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting an objective function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data;
The second generation module is used for generating a target test case based on the test case reference data, wherein the target test case is used for testing a target function in the target service.
According to one or more embodiments of the present disclosure, before inputting the pre-stored data into a target test service corresponding to the target service and generating test case reference data, the first generating module is further configured to: acquiring a code file corresponding to the target service; analyzing the code file, and determining a target code position, wherein the target code position represents the position of a state value of a target function in the target service in the code file corresponding to the target service; and based on the target code position, inserting a code file corresponding to the target service to generate the target test service.
According to one or more embodiments of the present disclosure, the state value of the objective function within the objective service includes at least one of: input parameters of the objective function, output parameters of the objective function, return values of downstream functions within the objective function.
According to one or more embodiments of the present disclosure, the first generating module is specifically configured to, when parsing the code file to determine an object code location: acquiring a directed acyclic graph corresponding to the code file; and traversing the directed acyclic graph, and determining the target code position according to the type of the code element corresponding to each node in the directed acyclic graph.
According to one or more embodiments of the present disclosure, the types of code elements include at least one of: assignment statement, stateless system function statement, stateful call function statement, wherein the stateful call function statement is statement for calling stateful calculation function provided by system; the first generation module is specifically configured to, when traversing the directed acyclic graph and determining the target code position according to the type of the code element corresponding to each node in the directed acyclic graph: traversing the directed acyclic graph, and determining the positions of the code elements corresponding to the assignment statement and the stateless system function statement as target code positions.
According to one or more embodiments of the present disclosure, when the first generating module performs instrumentation on a code file corresponding to the target service based on the target code location, the first generating module is specifically configured to: and inserting a stub function corresponding to the objective function in the objective code position to generate the objective test service, wherein the stub function is used for uploading the state value of the corresponding objective function.
According to one or more embodiments of the present disclosure, when the first generating module inputs the pre-stored data into a target test service corresponding to the target service, the first generating module is specifically configured to: sequentially operating each objective function in the objective test service according to the pre-stored data; when the execution of the stub function in the target test service is performed, acquiring a state value of a corresponding target function through the stub function; and generating test case reference data according to the state value of the objective function.
According to one or more embodiments of the present disclosure, before inputting the pre-stored data into a target test service corresponding to the target service and generating test case reference data, the obtaining module is further configured to: acquiring the pre-stored data through a preset request sending service in an offline environment, and analyzing the pre-stored data into the online data; the first generation module is specifically configured to: and inputting the online data into the target test service to generate the test case reference data.
According to one or more embodiments of the present disclosure, the acquiring module is specifically configured to: acquiring the online data; copying the online data to a message queue based on a preset flow proxy service; and generating pre-stored data according to the message queue.
According to one or more embodiments of the present disclosure, the second generating module is specifically configured to: obtaining target test information, wherein the target test information comprises at least one of the following: function name of the objective function, input parameters and output parameters of the objective function, function name of downstream function in the objective function, global variable name and corresponding variable value; and generating a target test case according to the generated test case reference data and the target test information based on a preset test case generation rule.
In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes the computer-executable instructions stored in the memory to implement the test case generation method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, implement the test case generating method according to the above first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the test case generating method according to the first aspect and the various possible designs of the first aspect.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (14)

1. A test case generation method, comprising:
obtaining pre-stored data, the pre-stored data being generated based on online data, the online data being used to characterize a business request for a target service;
Inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting a target function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data;
and generating a target test case based on the test case reference data, wherein the target test case is used for testing the target function in the target service.
2. The method of claim 1, wherein prior to entering the pre-stored data into a target test service corresponding to the target service, generating test case reference data, the method further comprises:
acquiring a code file corresponding to the target service;
analyzing the code file, and determining a target code position, wherein the target code position represents the position of a state value of a target function in the target service in the code file corresponding to the target service;
and based on the target code position, inserting a code file corresponding to the target service to generate the target test service.
3. The method of claim 2, wherein the state value of the objective function within the objective service comprises at least one of:
input parameters of the objective function, output parameters of the objective function, return values of downstream functions within the objective function.
4. The method of claim 2, wherein said parsing the code file to determine an object code location comprises:
acquiring a directed acyclic graph corresponding to the code file;
and traversing the directed acyclic graph, and determining the target code position according to the type of the code element corresponding to each node in the directed acyclic graph.
5. The method of claim 4, wherein the type of code element comprises at least one of:
assignment statement, stateless system function statement, stateful call function statement, wherein the stateful call function statement is statement for calling stateful calculation function provided by system;
traversing the directed acyclic graph, determining the target code position according to the types of the code elements corresponding to each node in the directed acyclic graph, including:
traversing the directed acyclic graph, and determining the positions of the code elements corresponding to the assignment statement and the stateless system function statement as target code positions.
6. The method of claim 2, wherein the instrumentation of the code file corresponding to the target service based on the target code location to generate the target test service comprises:
and inserting a stub function corresponding to the objective function in the objective code position to generate the objective test service, wherein the stub function is used for uploading the state value of the corresponding objective function.
7. The method of claim 1, wherein inputting the pre-stored data into a target test service corresponding to the target service, generating test case reference data, comprises:
sequentially operating each objective function in the objective test service according to the pre-stored data;
when the execution of the stub function in the target test service is performed, acquiring a state value of a corresponding target function through the stub function;
and generating test case reference data according to the state value of the objective function.
8. The method of claim 1, wherein inputting the pre-stored data into a target test service corresponding to the target service, before generating test case reference data, further comprises:
acquiring the pre-stored data through a preset request sending service in an offline environment, and analyzing the pre-stored data into the online data;
Inputting the pre-stored data into a target test service corresponding to the target service, and generating test case reference data, wherein the method comprises the following steps:
and inputting the online data into the target test service to generate the test case reference data.
9. The method of any of claims 1-8, wherein the obtaining pre-stored data comprises:
acquiring the online data;
copying the online data to a message queue based on a preset flow proxy service;
and generating pre-stored data according to the message queue.
10. The method of any of claims 1-8, wherein generating a target test case based on the test case reference data comprises:
obtaining target test information, wherein the target test information comprises at least one of the following: function name of the objective function, input parameters and output parameters of the objective function, function name of downstream function in the objective function, global variable name and corresponding variable value;
and generating a target test case according to the generated test case reference data and the target test information based on a preset test case generation rule.
11. A test case generating apparatus, comprising:
The system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring pre-stored data, the pre-stored data is generated based on online data, and the online data is used for representing a business request for a target service;
the first generation module is used for inputting the pre-stored data into a target test service corresponding to the target service to generate test case reference data, wherein the target test service is arranged in an offline environment, and the target test service is generated by inserting an objective function in the target service; the test case reference data is used for representing state values of objective functions in the objective service after the objective functions respond to the online data;
the second generation module is used for generating a target test case based on the test case reference data, wherein the target test case is used for testing a target function in the target service.
12. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory to implement the test case generation method of any one of claims 1 to 10.
13. A computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement the test case generation method of any of claims 1 to 10.
14. A computer program product comprising a computer program which when executed by a processor implements the test case generation method of any one of claims 1 to 10.
CN202210190751.9A 2022-02-28 2022-02-28 Test case generation method and device, electronic equipment and storage medium Pending CN116701159A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210190751.9A CN116701159A (en) 2022-02-28 2022-02-28 Test case generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210190751.9A CN116701159A (en) 2022-02-28 2022-02-28 Test case generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116701159A true CN116701159A (en) 2023-09-05

Family

ID=87828122

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210190751.9A Pending CN116701159A (en) 2022-02-28 2022-02-28 Test case generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116701159A (en)

Similar Documents

Publication Publication Date Title
US9910941B2 (en) Test case generation
CN111625473B (en) Interface test case generation method and device, storage medium and electronic equipment
US20100251209A1 (en) Generating Validation Test Suites
CN112597047A (en) Test method, test device, electronic equipment and computer readable medium
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN110727869A (en) Page construction method and device
CN113590454A (en) Test method, test device, computer equipment and storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN116225886A (en) Test case generation method, device, equipment, storage medium and program product
US20100251208A1 (en) Validating Behavioral Diagrams
US11475191B2 (en) Generating and adding additional control information to logic under test to facilitate debugging and comprehension of a simulation
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN115022328B (en) Server cluster, testing method and device of server cluster and electronic equipment
CN107562629B (en) Method and device for testing
CN115952089A (en) Software automation unit testing method and device, server and storage medium
CN111382058A (en) Service testing method and device, server and storage medium
CN116701159A (en) Test case generation method and device, electronic equipment and storage medium
CN114547521A (en) Authority-based interactive interface publishing method and device and electronic equipment
CN111367791B (en) Method, device, medium and electronic equipment for generating test case
CN112286808A (en) Application program testing method and device, electronic equipment and medium
CN111382057A (en) Test case generation method, test method and device, server and storage medium
CN111382056A (en) Service testing method and device, server and storage medium
CN116467178B (en) Database detection method, apparatus, electronic device and computer readable medium
CN115203988B (en) Operation method, device, equipment and storage medium of numerical reservoir simulation example
CN114168466A (en) Unit testing method, device, system 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