CN116204403A - 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 PDFInfo
- Publication number
- CN116204403A CN116204403A CN202111450932.2A CN202111450932A CN116204403A CN 116204403 A CN116204403 A CN 116204403A CN 202111450932 A CN202111450932 A CN 202111450932A CN 116204403 A CN116204403 A CN 116204403A
- Authority
- CN
- China
- Prior art keywords
- unit
- test
- parameter
- input
- assertion
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 514
- 238000000034 method Methods 0.000 title claims abstract description 63
- 230000004044 response Effects 0.000 claims abstract description 75
- 230000009471 action Effects 0.000 claims abstract description 15
- 238000004590 computer program Methods 0.000 claims description 14
- 230000008569 process Effects 0.000 abstract description 14
- 230000006870 function Effects 0.000 description 45
- 238000010586 diagram Methods 0.000 description 12
- 238000011161 development Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000003252 repetitive effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the invention discloses a test case generation method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: generating a first unit test file of a first unit in source code to be tested in response to a first operation on the first unit, wherein the first unit is determined by part of codes in the source code to be tested; responding to a second operation of a scope of the first unit test file, and acquiring test information of the first unit, wherein the test information of the first unit comprises a first input parameter, a first output parameter and a first assertion of the first unit; and in the action domain of the first unit test file, generating a first unit test case of the first unit according to the test information of the first unit. According to the embodiment of the invention, in the process of generating the test case for unit test, the participation times of the user are reduced, and the generation efficiency of the test case can be improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a test case generation method, a device, electronic equipment and a storage medium.
Background
After the source code is compiled by the software developer, the compiled source code needs to be tested in order to detect whether the compiled source code can normally run. In the testing process, the unit is tested, i.e. the unit is tested, in most cases. Before the unit test is performed, a software developer or a tester is required to write the test case, and in the process of writing the test case, the software developer or the tester participates in more times, so that the efficiency is lower.
Disclosure of Invention
The embodiment of the invention discloses a test case generation method, a device, electronic equipment and a storage medium, which are used for improving the generation efficiency of test cases.
The first aspect discloses a test case generation method, which includes:
generating a first unit test file of a first unit in source code to be tested in response to a first operation on the first unit, wherein the first unit is determined by part of codes in the source code to be tested;
responding to a second operation of a scope of the first unit test file, and acquiring test information of the first unit, wherein the test information of the first unit comprises a first input parameter, a first output parameter and a first assertion of the first unit;
And in the action domain of the first unit test file, generating a first unit test case of the first unit according to the test information of the first unit.
As a possible implementation manner, the obtaining, in response to the second operation of the scope of the test file for the first unit, the test information of the first unit includes:
responsive to a second operation of the scope for the first unit test file, outputting a prompt interface comprising an in-parameter input box, an out-parameter input box, and an assertion input box;
and responding to a third operation aiming at the prompt interface, and acquiring the test information of the first unit.
As a possible implementation manner, the outputting, in response to the second operation of the scope of the first unit test file, a prompt interface includes:
responsive to a second operation of the scope for the first unit test file, configuring an assertion input box according to an assertion list, the assertion list including identifications of one or more assertions;
outputting a prompt interface according to the assertion input box;
the third operation includes a fourth operation and a selection operation, and the responding to the third operation for the prompt interface obtains the test information of the first unit includes:
Outputting the assertion list in response to the fourth operation for the assertion input box;
the first assertion is obtained in response to the selection operation for identification of one or more assertions in the assertion list.
As a possible implementation, the assertion list further includes function description information of the one or more assertions.
As a possible implementation manner, the outputting, in response to the second operation of the scope of the first unit test file, a prompt interface includes:
analyzing the first unit in response to a second operation of the scope of the first unit test file to obtain an in-parameter and an out-parameter of the first unit;
determining a parameter input box according to the parameter input of the first unit;
determining a parameter input box according to parameter output of the first unit;
and outputting a prompt interface according to the parameter input box and the parameter output input box.
As a possible implementation manner, the analyzing the first unit to obtain the in-parameter and the out-parameter of the first unit includes:
analyzing the first unit to obtain an input parameter and an output parameter of the first unit, wherein the type of the input parameter of the first unit is a first type;
The third operation includes an input operation, and the responding to the third operation for the prompt interface, obtaining the test information of the first unit includes:
acquiring a second entry in response to the input operation for the entry input box;
and determining the second entry as the first entry in the case that the type of the second entry is the first type.
As a possible implementation manner, the method further comprises:
generating a first unit test template according to the first unit test file and a default test template, wherein the first unit test template comprises a scope;
the second operation responsive to the scope for the first unit test file comprises: responsive to a second operation for a scope in the first unit test template;
the generating, in the scope of the first unit test file, a first unit test case of the first unit according to the test information of the first unit includes:
and in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
A second aspect discloses a test case generating device, including:
the generating unit is used for responding to a first operation of a first unit in source codes to be tested, generating a first unit test file of the first unit, wherein the first unit is determined by part of codes in the source codes to be tested;
an obtaining unit, configured to obtain, in response to a second operation for a scope of the first unit test file, test information of the first unit, where the test information of the first unit includes a first input parameter, a first output parameter, and a first assertion of the first unit;
the generating unit is further configured to generate a first unit test case of the first unit according to the test information of the first unit in the scope of the first unit test file.
As a possible implementation manner, the acquiring unit is specifically configured to:
responsive to a second operation of the scope for the first unit test file, outputting a prompt interface comprising an in-parameter input box, an out-parameter input box, and an assertion input box;
and responding to a third operation aiming at the prompt interface, and acquiring the test information of the first unit.
As a possible implementation manner, the obtaining unit outputs a prompt interface in response to a second operation of the scope of the first unit test file, including:
responsive to a second operation of the scope for the first unit test file, configuring an assertion input box according to an assertion list, the assertion list including identifications of one or more assertions;
outputting a prompt interface according to the assertion input box;
the third operation includes a fourth operation and a selection operation, and the obtaining unit obtains the test information of the first unit in response to the third operation for the prompt interface, including:
outputting the assertion list in response to the fourth operation for the assertion input box;
the first assertion is obtained in response to the selection operation for identification of one or more assertions in the assertion list.
As a possible implementation, the assertion list further includes function description information of the one or more assertions.
As a possible implementation manner, the obtaining unit outputs a prompt interface in response to a second operation of the scope of the first unit test file, including:
Analyzing the first unit in response to a second operation of the scope of the first unit test file to obtain an in-parameter and an out-parameter of the first unit;
determining a parameter input box according to the parameter input of the first unit;
determining a parameter input box according to parameter output of the first unit;
and outputting a prompt interface according to the parameter input box and the parameter output input box.
As a possible implementation manner, the obtaining unit analyzes the first unit to obtain the input parameter and the output parameter of the first unit, including:
analyzing the first unit to obtain an input parameter and an output parameter of the first unit, wherein the type of the input parameter of the first unit is a first type;
the third operation includes an input operation, and the obtaining unit obtains the test information of the first unit in response to the third operation for the prompt interface, including:
acquiring a second entry in response to the input operation for the entry input box;
and determining the second entry as the first entry in the case that the type of the second entry is the first type.
As a possible implementation manner, the generating unit is further configured to generate a first unit test template according to the first unit test file and a default test template, where the first unit test template includes a scope;
The second operation responsive to the scope for the first unit test file comprises: responsive to a second operation for a scope in the first unit test template;
the generating unit generates a first unit test case of the first unit according to the test information of the first unit in the action domain of the first unit test file, and the generating unit comprises the following steps:
and in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
A third aspect discloses an electronic device, which may comprise a processor and a memory for storing a set of computer programs, which when used to invoke the computer programs stored in the memory, cause the processor to perform the method disclosed in the first aspect or any possible implementation of the first aspect.
A fourth aspect discloses a computer readable storage medium having stored thereon a computer program or computer instructions which, when run, implement a method as disclosed in the first aspect or any possible implementation of the first aspect.
A fifth aspect discloses a computer program product which, when run on a computer, causes the computer to perform the method disclosed in the first aspect or any possible implementation of the first aspect.
In the embodiment of the invention, a first unit test file of a first unit is generated in response to a first operation of the first unit in source code to be tested, test information of the first unit including a first input parameter, a first output parameter and a first assertion of the first unit is acquired in response to a second operation of a scope of the first unit test file, and a first unit test case of the first unit is generated in the scope of the first unit test file according to the test information of the first unit. Therefore, in the process of generating the test cases for unit test, the test cases can be generated only by simple operation of a user, and the participation process and the number of times of software developers or testers are reduced, so that the generation efficiency of the test cases can be improved.
Drawings
FIG. 1 is a schematic flow chart of a test case generation method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an interface of a source code editor according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an interface of another source code editor disclosed in an embodiment of the invention;
FIG. 4 is a schematic diagram of a prompt interface according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of another prompt interface disclosed in an embodiment of the present invention;
FIG. 6 is a flow chart of another test case generation method according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a test case generating device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and thoroughly described below with reference to the accompanying drawings.
The terms "first," "second," and the like, are used below for descriptive purposes only and are not to be construed as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature, and in the description of embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" is two or more.
The embodiment of the invention discloses a test case generation method, a device, electronic equipment and a storage medium, which are used for improving the generation efficiency of test cases. The following will describe in detail.
For a better understanding of embodiments of the present invention, some concepts or users are described below.
The source code editor is a text editor used by programmers to write computer programs. It is typically a stand-alone application, either existing as part of an integrated development environment, or a web page editor running in a browser. Such as Atom, brackets, chong high Text (Sublime Text), VS Code (Visual Studio Code), notepad++, vim, coda, komod edition (Komod edition), and the like.
A plug-in is a program written by an application program interface that complies with certain specifications. It can only run under a program-specified system platform (possibly supporting multiple platforms simultaneously), such as a source code editor, and cannot run separately from the specified platform.
Unit testing (unitizing), also known as module testing, is a test work that performs correctness checking with respect to program modules (the smallest unit of software design), i.e., checks and validates the smallest testable unit in software. For the meaning of a unit in a unit test, generally, the specific meaning of the unit is to be determined according to practical situations, for example, a unit in a C language refers to a function, a unit in Java refers to a class, and a unit in graphic software may refer to a window or a menu. In general, a unit is an artificially defined minimum measured function module. Unit testing is the lowest level of testing activity to be performed during the development of software, where individual units of software will be tested in isolation from other parts of the program.
A description (describe) forms a scope, referred to as a "test suite," representing a set of related tests.
it is called a "test case" and represents a single test, which is the smallest unit of test.
Assertions (expected) are determinations of whether the actual execution result of source code is consistent with the expected result.
TypeScript: typed javascript at any scale (TS), a type of javascript is added.
For a better understanding of the embodiments of the present invention, the related art will be described first.
After the source code is compiled by the software developer, the compiled source code needs to be tested in order to detect whether the compiled source code can normally run. In the testing process, the unit is tested, i.e. the unit is tested, in most cases. Before unit testing, software developers or testers are required to write test cases.
In the process of writing test cases by a software developer or a tester, the software developer or the tester is required to firstly pull out the unit to be tested and write the unit to be tested into an independent file, then generate a unit test file based on the independent file, and then write a scope, an assertion, a parameter entering, a parameter exiting and the like. In each step, a software developer or a tester is required to participate, so that the software developer or the tester participates in the process and the times are more, and the efficiency is lower. In addition, for the test cases of different units, software developers or testers are required to continuously repeat the process, and a great deal of manpower is required to be consumed, so that the labor cost is high and the universality is poor.
The invention can quickly generate the test case for unit test through the plug-in which can be installed in the source code editor, and can improve the generation efficiency of the test case. In addition, for different units, the repetitive work of software developers or testers can be reduced, so that the labor cost can be reduced and the universality can be improved.
The plug-in the invention refers to a quick unit test plug-in which can run in a source code editor, namely, a plug-in which can be used for quick unit test, and can quickly generate unit test cases for test. The fast unit test plug-in may hereinafter be referred to as test plug-in.
Referring to fig. 1, fig. 1 is a flow chart of a test case generating method according to an embodiment of the invention. The test case generation method can be applied to test plug-ins. The test plug-in may be installed in and run on the source code editor. The source code editor may be installed on the electronic device and may be run on the electronic device. The electronic device may be a device capable of installing and running an application, as well as capable of displaying information. The electronic equipment can be a mobile phone, a notebook computer, a desktop computer, a tablet personal computer, an intelligent television and the like. As shown in fig. 1, the test case generation method may include the following steps.
101. A first unit test file for the first unit is generated in response to a first operation for the first unit in the source code to be tested.
In the case that a software developer or a tester (hereinafter referred to as a user) needs to generate a first unit test case of a first unit in source code to be tested through a test plug-in, the user can operate the first unit in the source code to be tested through electronic equipment. After the test plug-in detects the first operation on the first unit in the source code to be tested, the first unit test file of the first unit can be generated in response to the first operation, namely, the first unit test file is generated according to the first unit.
The source code to be tested can be any source code in source codes edited by a user in a source code editor, and can also be any source code in source codes imported into the source code editor by the user from other positions. The source code to be tested may be stored in the electronic device, i.e. locally, or in a server. The first unit is determined by the part of the code in the source code to be tested.
In the case where the user needs to use the test plug-in, if the source code editor with the test plug-in installed is not running on the electronic device, the user may first input a start instruction for starting the source code editor to the electronic device by operating the electronic device.
For example, in a case where the electronic device is provided with a touch screen, a user may perform operations such as clicking, double-clicking, and the like on an icon of the source code editor to input a start instruction for starting the source code editor to the electronic device. For another example, in a case where the electronic device is provided with a mouse, the user may input a start instruction for starting the source code editor to the electronic device by performing an operation such as double-clicking the left part of the mouse on an icon of the source code editor.
After the electronic device detects a start instruction input by a user for starting the source code editor, the source code editor may be started, i.e. the source code editor is run, in response to the start instruction. During the start-up of the source code editor, the test plug-in installed on the source code editor will also start (i.e., run). After the source code editor is started, the user can call the test plug-in through the source code editor if the user needs the test plug-in.
The test plug-in is a plug-in which is developed by a software developer in advance. The user can install the test plug-in the source code editor in advance, so that the test plug-in is only required to be called when the user uses the test plug-in subsequently. Wherein the source code editor and the test plug-in may be homologous, i.e., may be developed by the same company or enterprise; but may also be of different origin, i.e. may be developed by different companies or enterprises.
The software developer may register a command or instruction in the test plug-in for generating the unit test file, the command or instruction being one that can be executed on the source code editor. The command or instruction may be named createttestfile or other, without limitation. When the test plug-in is installed on the source code editor, firstly, a user can bind a command Identification (ID) in the source code editor with the command or instruction in the test plug-in, secondly, the user can register the command or instruction in the source code editor, and finally, the user can configure the command or instruction in a right-key menu in the source code editor so that the user can use the command or instruction in a right-key menu column through a right-key attribute in the case that the user needs to generate a unit test file later.
Similarly, a user may register a command or instruction in the test plug-in for generating (or creating) a unit test case, which may be executed on the source code editor. When the test plug-in is installed on the source code editor, firstly, a user can bind a command ID in the source code editor with the command or instruction in the test plug-in, secondly, the user can register the command or instruction in the source code editor, and finally, the user can configure the command or instruction into a right-key menu so that the user can use the command or instruction in the right-key menu bar through the right-key attribute in the source code editor under the condition that the user needs to generate the unit test case later.
For example, the user may invoke commands.registrationcommand in the source code editor to bind a command ID in the source code editor to the command or instruction in the test plug-in. For example, the user may register this command or instruction in the source code editor by an active of the source code editor's entry file extension.ts. For example, the user may configure this command or instruction in the package. Json into the right-key menu in the source code editor.
It should be appreciated that the above examples are illustrative of the installation of test plug-ins in a source code editor and are not limiting. For example, the user may also invoke other instructions in the source code editor, binding a command ID in the source code editor with the one command or instruction in the test plug-in.
The user may operate the first unit in the source code to be tested through the electronic device, which may be understood that the user may operate the first unit in the source code to be tested in the source code editor through the electronic device. The test plug-in detects the first operation for the first unit in the source code to be tested, which can be understood as that the test plug-in detects the first operation for the first unit in the source code to be tested through the source code editor.
Referring to fig. 2, fig. 2 is an interface schematic diagram of a source code editor according to an embodiment of the invention. As shown in fig. 2, the content in the lower frame of 1 is information of the first unit, and the user can cause the source code editor to acquire the content of the first unit by operating on the information of the first unit, and display the content of the first unit in the right area. As indicated by the uppermost arrow in fig. 2. For example, the user may click or double click on the information of the first unit through the left mouse button, and after the source code editor detects this operation through the electronic device, the content of the first unit may be acquired and displayed in the right frame area. For another example, the user may select the information of the first unit by an operation, and then may drag the information of the first unit to the right area, and in case that the source code editor detects the drag operation through the electronic device, may acquire the content of the first unit and display the content of the first unit in the right area.
After the source code editor displays the content of the first unit via the electronic device, the user may select the content of the first unit by manipulating. For example, the content of the selected first cell may be as in the lower box of FIG. 2. The user may then continue to operate on the content of the selected first cell to input output instructions to the source code editor for outputting the menu of functions. For example, after the user selects the content of the first unit, an output instruction for outputting a function menu may be input to the source code editor by clicking a right mouse button.
The source code editor may detect this operation by the electronic device and may then output a first list of function options in response to the operation, i.e. send a right-click menu bar to the electronic device. After the electronic device receives the first function option, a first function option list (i.e., a right-key menu bar) may be displayed. The first function option list may include a function option of "generate unit test file", i.e., a first function option for generating unit test file. The first list of function options may also include copy, paste cut, etc. function options.
The user may then operate the first functional option of "generate unit test file" via the electronic device. For example, the user may first move the cursor to the position where the "generate unit test file" is located, and then may click the left button. The source code editor may detect a first operation for "generating a unit test file" via the electronic device, and may then send the first operation to the test plug-in, which may then generate a first unit test file for the first unit in response to the first operation.
After the test plug-in detects the first operation, whether the file format of the first unit is a specific format can be judged first, and if the file format of the first unit is judged not to be the specific format, the first unit is judged to be inconsistent with the requirements, and a second unit with the file format being the specific format can be generated according to the first unit, namely, the format of the first unit is converted into the specific format. And then the test plug-in can generate a unit test file according to the second unit to obtain a first unit test file of the first unit. The specific format may be a pure TS format or other formats, which are not limited herein.
After the test plug-in generates the second unit, the second unit may be stored in the source code editor. In case of a source code editor built-in node. Js, the test plug-in may call fs.writefilesycn to store the second element in the source code editor, i.e. create a file in the source code editor and store the second element in this file. The software developer may configure to store the second unit under a certain folder in the test plug-in, i.e. this file may be created under a certain folder. This particular folder may be a folder such as static, commom.
It should be appreciated that the above example is illustrative of storing the second element in the source code editor and is not limiting. For example, in the case where the source code editor built-in information is different, the information called by the test plug-in may be different.
In case it is determined that the file format of the first unit is a specific format, the test plug-in may continue to determine whether the first unit has a export function, i.e. the "export" function in fig. 2. Under the condition that the first unit is judged to have no export function, the first unit cannot be exported from the source code to be tested, the test plug-in can firstly insert the export function for the first unit to obtain a third unit, and then a unit test file can be generated according to the third unit to obtain the first unit test file of the first unit. Under the condition that the first unit is judged to have the export function, the test plug-in unit can directly generate the unit test file according to the first unit to obtain the first unit test file of the first unit.
After the test plug-in generates the first unit test file for the first unit, the information of the first unit test file may be added under the left test (test) of the source code editor, as shown in fig. 2.
After the test plug-in generates the first unit test file, the first unit test file may be stored in the source code editor. The test plug-in may first determine if a test (test) directory exists in the source code editor. In the case that it is determined that the test directory exists in the source code editor, the test plug-in may store the first unit test file under the test directory in the source code editor. In the case where it is determined that the test directory does not exist in the source code editor, the test plug-in may first create a test folder in the source code editor, and then may store the first unit test file in the test folder. The first unit test file may be named using the name of the first unit, or may be named using other information of the first unit.
For example, the test plug-in may first call a workspace.workspace eFoles in the source code editor to obtain all folders in the source code editor, and then may determine whether a test (test) directory exists in all folders. And under the condition that the existence of the test catalogue in all folders is judged, determining that the test catalogue exists in the source code editor. In the case where there is no test directory in all folders, there is no test directory in the source code editor. The test plug-in may call fs.writefilesycn to store the first unit test file under a test directory or in a test folder in the source code editor.
It should be appreciated that the above example is illustrative of storing the first unit test file in the source code editor and is not limiting in its composition. For example, the source code editors may differ and the information that the test plug-in may call may differ.
102. In response to a second operation of the scope for the first unit test file, test information of the first unit of the first in-parameter, the first out-parameter, and the first assertion is obtained.
After generating the first unit test file for the first unit, the user may continue to operate on the scope of the first unit test file. After the test plug-in detects the second operation of the scope of the test file of the first unit, the test information of the first unit may be acquired in response to the second operation, and the test information of the first unit may include a first in parameter, a first out parameter, and a first assertion of the first unit.
Because the generated first unit test file has no scope, the test plug-in can write the scope in the first unit test file to obtain the first unit test template. The test plug-in may generate a first unit test template from the first unit test file and a default unit test template. The default unit test template may be a default unit test template of the test plug-in, or may be a default unit test template of the source code editor, which is not limited herein. The default unit test templates used may be the same unit test templates for different units. The first unit test template may include a scope. The first unit test template may also include it. This it is the default it, which is the same for different units.
Referring to fig. 3, fig. 3 is an interface schematic diagram of another source code editor according to an embodiment of the invention. As shown in fig. 3, the area where the left border is located is used to represent information of the corresponding first unit test file, the top right box is used to represent which unit is imported, and the large right box below represents the generated first unit test module. The first unit test module may include a scope (Descriibe) and an it.
The user operating the scope of the first unit test file may be understood as the user operating the scope in the first unit test template. The test plug-in being responsive to a second operation for the scope of the first unit test file may be understood as being responsive to a second operation for the scope in the first unit test template.
The user may enter an operation for displaying the function options into the source code editor by operating the electronic device to select the scope. For example, after the user selects the scope, the right mouse button may be clicked. The source code editor may detect an operation for the scope through the electronic device and may then output a second list of function options to the electronic device, i.e. send a right-click menu bar to the electronic device, in response to the operation. The electronic device may display a second list of function options (i.e., a right-key menu bar). The second function option list may include a second function option for generating unit test cases, i.e., a second function option of "generate unit test cases". The second list of function options may also include copy, cut, etc. function options.
The user may then operate the second functional option of "generate Unit test case" via the electronic device. For example, the user may first move the cursor to the location of the "generate unit test case" and then may click the left button. The source code editor may detect a second operation for the "generate unit test case" through the electronic device, after which the second operation may be sent to the test plug-in. After receiving the second operation, the test plug-in may output a hint interface in response to the second operation for the scope of the first unit test file.
When the test plug-in responds to the second operation of the scope of the first unit test file, a prompt interface can be output first. The prompt interface may include an in-parameter input box, an out-parameter input box, and an assertion input box. The parameter entry box is used for a user to enter parameters of the first unit. The parameter-out input box is used for a user to input parameter-out, i.e. a desired value, of the first unit. The assertion input box is for a user to input an assertion of the first unit.
When the test plug-in responds to the second operation aiming at the scope of the first unit test file, the first unit can be analyzed to obtain the input parameters and the output parameters of the first unit, then the input parameters input frame can be determined according to the input parameters of the first unit, and the input parameters input frame can be determined according to the output parameters of the first unit.
The test plug-in analyzes the first unit, and can also obtain that the type of the input parameter of the first unit is the first type.
By analyzing the first unit, the test plug-in can determine the number and type of incoming parameters required by the first unit, as well as the number of outgoing parameters. Under the condition that the number of the input frames required by the first unit is larger than 1, the number of the input frames is larger than 1, namely the input frames are in one-to-one correspondence with the input frames required by the first unit, namely the first unit needs a plurality of input frames, and the test plug-in unit determines a plurality of input frames, namely one input frame corresponds to one input frame only. Similarly, when the number of the parameter output boxes required by the first unit is greater than 1, the number of the parameter output input boxes is greater than 1, that is, the parameter output input boxes are in one-to-one correspondence with the parameter output boxes required by the first unit, that is, the first unit requires several parameter output boxes, and the test plug-in determines several parameter output input boxes, that is, one parameter output input box corresponds to one parameter output input box only.
The test plug-in may also configure the predicate input box according to the predicate list. The predicate list may include an identification of one or more predicates. The predicate list may be as shown in table 1:
TABLE 1
Identification of |
Assertion |
1 |
|
… |
The predicate list may also include functionality for the one or more predicates. The predicate list may also be as shown in table 2:
TABLE 2
Identification of assertions | |
Assertion | |
1 | |
|
|
… | … |
In one case, the predicate list may be self-contained with the test plug-in. I.e. the assertion list may be pre-generated and stored in the test plug-in. At this time, the assertion list is fixed.
In another case, the predicate list may be generated by the test plug-in response to a second operation of the scope of the test file for the first unit. The information such as the identification of the assertion in the assertion list can be self-contained by the plug-in, or can be obtained by the test plug-in from the source code editor. At this time, the test plug-in may also generate an assertion list according to the asserted information. The predicate lists generated by the test plug-ins may be the same or different for different units.
The test plug-in may generate a prompt interface according to the in-parameter input box, the out-parameter input box, and the assertion input box. Under the condition that the test plug-in obtains the first type, the test plug-in can generate a prompt interface according to the first type, the input-in input box, the output-out input box and the assertion input box.
Referring to fig. 4, fig. 4 is a schematic diagram of a prompt interface according to an embodiment of the invention. As shown in fig. 4, the prompt interface may include a prompt 401, an in-parameter input box 402, an out-parameter input box 403, an assert input box 404, and a determine control 405. In one embodiment, the alert interface may not include alert information 401.
The test plug-in may determine the in-parameter input box, the out-parameter input box, and the assertion input box first, and then invoke the webview interface to generate the hint interface.
Specifically, the test plug-in may call window webview panel to open a webview interface, and then may add the in-input box, the out-input box, and the assertion input box to this interface to obtain a prompt interface. The test plug-in may add the in-parameter input box, the out-parameter input box, and the assertion input box to this webview interface through webview.
After the test plug-in outputs the prompt interface, the user can operate the prompt interface. After the test plug-in detects the third operation of the user on the prompt interface, the test information of the first unit can be obtained in response to the third operation on the prompt interface.
It should be understood that the third operation may include only one operation, or may include a plurality of operations.
The third operation may include an input operation of the parameter entry box by the user. The user can input the entry by operating the entry input box. The user may input a second entry by operating the entry input box. After the prompt interface detects an input operation for the parameter entry box, a second parameter entry may be obtained. The hint interface may then transmit the second entry to the test plug-in via webview. The test plug-in may determine whether the type of the second entry is the first type. And under the condition that the type of the second input parameter is judged to be the first type, indicating that the input parameter input by the user meets the input parameter requirement of the first unit, and determining the second input parameter as the first input parameter. Under the condition that the type of the second input parameter is judged to be not the first type, the condition that the input parameter input by the user does not meet the input parameter requirement of the first unit is indicated, and prompt information that the second input parameter does not meet the requirement can be output on a prompt interface, so that the user can input the input parameter again according to the prompt information, and the condition that test cases cannot be generated due to the fact that the type of the input parameter is wrong can be avoided.
Under the condition, the prompt interface can also directly output prompt information of the type of the first unit needed to enter the parameters above or below the parameter entering input box 402, so that a user can input proper parameters according to the prompt information, and the situation that the user frequently inputs wrong parameters because the user does not know the type of the first unit needed to enter the parameters is avoided.
The third operation may further include a fourth operation and a selection operation. The user may input an assertion by operating an assertion input box. After the test plug-in detects the fourth operation of the user on the assertion input box, the assertion list may be output. Referring to fig. 5, fig. 5 is a schematic diagram of another prompt interface according to an embodiment of the invention. As shown in fig. 5, after the test plug-in detects the fourth operation for the assertion input box, the assertion list may be output under the assertion input box in the form of a drop-down menu. The user may then select an identification of one or more desired assertions from the list of assertions, and after the test plug-in detects a selection operation for the identification of one or more assertions in the list of assertions, the first assertion may be obtained in response to the selection operation for the identification of one or more assertions in the list of assertions. The user can identify the previous by manipulating the assertions in the assertions list To select the identity of the desired assertion.
The third operation may further include an input operation of the parameter input box by the user. The user can input the play out by operating the play out input box. After the prompt interface may detect an input operation for the parameter-out input box, the first parameter-out may be acquired in response to the operation for the parameter-out input box.
The third operation may also include a user operation of the determine control 405. After the user has entered the desired in-parameter 402, desired out-parameter 403, and desired assertion input 404, the user may operate the determination control 405. After the test plug-in detects this operation, the entry in the entry box may be determined to be the first entry, the exit in the exit box may be determined to be the first exit, and the user-selected assertion may be determined to be the first assertion. That is, after the prompt interface detects the operation, the input parameters based on the input parameters input by the input parameters box, the output parameters based on the input parameters input by the output parameters input box, and the assertion selected based on the assertion input box can be transmitted to the test plug-in through webview. The test plug-in may determine these in parameters as first in parameters, determine these out parameters as first out parameters, and determine this assertion as first assertion.
103. And in the action domain of the first unit test file, generating a first unit test case of the first unit according to the test information of the first unit.
After the test plug-in obtains the test information of the first unit, a first unit test case of the first unit can be generated in the action domain of the first unit test file according to the test information of the first unit.
The test plug-in can generate a first unit test case of the first unit according to the test information of the first unit in a scope in the first unit test template. And generating a test case according to the first unit test template and the test information of the first unit to obtain the first unit test case of the first unit.
In the test case generation method described in fig. 1, a first unit test file of a first unit is generated in response to a first operation for the first unit in source code to be tested, test information of the first unit including a first input parameter, a first output parameter and a first assertion of the first unit is acquired in response to a second operation for a scope of the first unit test file, and a first unit test case of the first unit is generated in the scope of the first unit test file according to the test information of the first unit. Therefore, in the process of generating the test cases for unit test, the test cases can be generated only by simple operation of a user, and the participation times and processes of software developers or testers are reduced, so that the generation efficiency of the test cases can be improved.
Referring to fig. 6, fig. 6 is a flowchart illustrating another test case generating method according to an embodiment of the invention. The test case generation method can be applied to test plug-ins. The test plug-in may be installed in and run on the source code editor. The source code editor may be installed on the electronic device and may be run on the electronic device. The electronic device may be a device capable of installing and running an application, as well as capable of displaying information. The electronic equipment can be a mobile phone, a notebook computer, a desktop computer, a tablet personal computer, an intelligent television and the like. As shown in fig. 6, the test case generation method may include the following steps.
601. A first unit test file for the first unit is generated in response to a first operation for the first unit in the source code to be tested.
Step 601 is the same as step 101, and the detailed description may refer to the description of step 101.
602. A first unit test template including a scope is generated from the first unit test file and the default test template.
603. In response to a second operation for the scope in the first unit test template, test information for the first unit is obtained that includes the first in-parameter, the first out-parameter, and the first assertion for the first unit.
The details of step 602-step 603 may refer to the relevant content in step 102.
604. And in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
The detailed description of step 604 may refer to the description of step 103.
In the test case generation method described in fig. 6, a first unit test file of a first unit is generated in response to a first operation for the first unit in source code to be tested, a first unit test template including a scope is generated according to the first unit test file and a default test template, test information of the first unit including a first input parameter, a first output parameter and a first assertion of the first unit is acquired in response to a second operation for the scope in the first unit test template, and the first unit test case of the first unit is generated in the scope in the first unit test template. Therefore, in the process of generating the test cases for unit test, the test cases can be generated only by simple operation of a user, and the participation times and processes of software developers or testers are reduced, so that the generation efficiency of the test cases can be improved.
The embodiment of the invention also provides a test case generation method which is applied to the test plug-in, the test plug-in can run in a source code editor, and the source code editor can display source codes to be tested. An exemplary description of the test case generation process and its implementation is provided below.
In this embodiment, the user may select a portion of the code to be tested as the first unit, for example, the portion of the code may be a code corresponding to a method function. The test plug-in generates a first unit test file of the first unit in response to a first operation for the first unit, for example, a user can select a corresponding menu option by selecting the method function for a method function to be tested or trigger the first operation for the method function by a shortcut key form, and the test plug-in generates a unit test file corresponding to the method function in response to the first operation.
One or more menu options can be displayed in a menu triggered and displayed by the method function to be tested by the user right key, and one menu option is used for indicating the test plug-in to automatically generate a corresponding unit test file for the selected method function.
In some embodiments, a test plug-in may be created based on a source code editor, such as vscode (visualstudiocode), for example, when the test plug-in is to obtain a method function to be tested, a test plug-in, such as a vscore plug-in API, may provide a vscore. Specifically, the test plug-in may obtain the currently selected text through selection of the text editor object vscore.
Further, in one example, to implement the test plug-in to automatically generate the unit test file, a vscore command may be registered, a command ID is first bound to the test plug-in with a vscore.
As a way, the first unit test file may be a pure TS file named by the function name of the first unit, or the first unit may be created under a folder in the configuration file of the test plug-in, such as static, common, etc. For example, node. Js is built in the test plug-in, and when the test plug-in generates the first unit test file, the fs module may be used to create a function file corresponding to the first unit by using fs.writefilesync.
For example, the test plug-in may obtain all folder arrays in the current working area through vscore.workspace.workspace eFoles, if a test single-test directory exists, then the first unit test file is newly built in the directory, if not, a test folder may be newly built first, then by analyzing the function file of the first unit, the file name to be created may be named by the function method name of the first unit, and the first unit test file of the first unit may be created by fs.writefileSync of node. The first unit test file may be named by a function name of the first unit, or may be named by other manners, as long as the first unit can be indexed, and the naming manner is not limited in this embodiment.
Taking an example of an operational procedure that may be implemented as an example, after a user selects a text in a source code to be tested (i.e., a text corresponding to a first unit), a menu option "generate a unit test file" for generating a unit test file may be displayed on an interface of a source code editor, and when the user applies a trigger operation (i.e., a first operation) to the menu option, a test plug-in may obtain a command for generating the first unit test file of the first unit, and at this time, the test plug-in may respond to the command corresponding to the first operation, pull the selected first unit off, and generate a corresponding first unit test file.
In some implementations, a unit test file can include an import of the file, a scope, and a unit test case. In one embodiment, the unit test cases may also be written manually by a person. In another embodiment, the unit test cases may also be generated by a test plug-in, for example, the user may click a right mouse button for the first unit or the first unit test file, and trigger the test plug-in to generate the first unit test cases of the first unit in response to the operation for the first unit or the first unit test file.
In some embodiments, in the created first unit test file, the test plug-in may default to a function file of the first unit, and write a descale scope in the function file, and may write a default it unit test case. Thus, the first unit test file generated by the test plug-in at least comprises the scope of the first unit.
Further, the test plug-in may obtain test information for the first unit in response to a second operation on the scope of the first unit test file, the test information for the first unit may include a first reference for the first unit and a first assertion. And generating a first unit test case of the first unit according to the test information of the first unit in the action domain of the first unit test file. Therefore, the efficiency of writing the unit test by the developer is greatly improved, most repetitive work can be solved, and a novice developer can be helped to enter and know the writing of the unit test quickly.
In some embodiments, when generating the unit test case of the first unit, a vscore command may be registered with reference to the foregoing manner of generating the first unit test file, where the vscore command is used to display a corresponding right-click menu when the user triggers a second operation on the scope, for example, right-click the scope, and the right-click menu includes a right-click menu option "new unit test case", and when the user selects the right-click menu option (which may correspond to the second operation), the test plug-in may open a web view interface, for example, may open a web view interface through vscore.
Therefore, the input frame (namely, the input frame) containing the input in the prompt interface to be output can be determined according to the quantity and the type of the input parameters by analyzing the input parameters of the first unit through webview. In one embodiment, the test plug-in may perform a strong check on the parameter entry box, so that the user may meet the parameter entry requirement of the first unit based on the data entered by the parameter entry box (e.g., the input data meets the parameter entry type, etc., and may acquire the input data as the first parameter entry of the first unit).
Additionally, the predicate list may be configured and a corresponding predicate input box determined, for example, the predicate list may be provided in the form of a drop down list to the user to select a desired predicate. Wherein the predicate list includes an identification of one or more predicates that can be selected from a library of predicates, and in one way, functional descriptive information of the predicates can also be displayed in the predicate list (i.e., annotating the role of each predicate, which can help a developer quickly select a desired predicate).
In addition, in some embodiments, a parameter output input box may be further configured, and the parameter output box is displayed on a prompt interface, so as to obtain a parameter output expected by a user, so that a first unit test case for the first unit is generated, and the parameter output input by the user can be obtained through the parameter output input box as the first parameter output. In other embodiments, the first parameter may be preconfigured, and the test plug-in may be directly obtained when generating the first unit test case of the first unit. This embodiment is not limited thereto.
In addition, after the user submits, the test plug-in can obtain the test information of the first unit through webview. Postmessage, and in the Descriibe action domain, according to the test information of the first unit, the first unit test case is generated, and in one mode, the generated first unit test case is simple and can be edited manually.
It can be understood that the above embodiment is described by taking a test plug-in based on a vscore as an example, which can be made based on vue+typescript, and the unit test framework can use the most basic jest architecture, and subsequently, the test case generation method provided by the embodiment of the present invention can be further applied to any language without limitation.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a test case generating device according to an embodiment of the invention. The test case generating means may be a test plug-in installed in the source code editor. As shown in fig. 7, the test case generating device may include:
a generating unit 701, configured to generate a first unit test file of a first unit in response to a first operation for the first unit in the source code to be tested, where the first unit is determined by a part of codes in the source code to be tested;
An obtaining unit 702, configured to obtain, in response to a second operation for a scope of the first unit test file, test information of the first unit, where the test information of the first unit includes a first input parameter, a first output parameter, and a first assertion of the first unit;
the generating unit 701 is further configured to generate, in a scope of the first unit test file, a first unit test case of the first unit according to the test information of the first unit.
As a possible implementation manner, the obtaining unit 702 is specifically configured to:
responding to a second operation of the scope of the first unit test file, and outputting a prompt interface, wherein the prompt interface comprises a parameter input box, a parameter output box and an assertion input box;
and responding to a third operation aiming at the prompt interface, and acquiring the test information of the first unit.
As one possible implementation, the obtaining unit 702 outputs a prompt interface in response to a second operation of the scope for the first unit test file, including:
responsive to a second operation for the scope of the first unit test file, configuring an assertion input box according to an assertion list that includes identifications of one or more assertions;
outputting a prompt interface according to the assertion input box;
The third operation includes a fourth operation and a selection operation, and the acquiring unit 702 acquires test information of the first unit in response to the third operation for the prompt interface, including:
outputting an assertion list in response to a fourth operation for the assertion input box;
the first assertion is obtained in response to a selection operation for identification of one or more assertions in the assertion list.
As one possible implementation, the assertion list further includes functional description information of the one or more assertions.
As one possible implementation, the obtaining unit 702 outputs a prompt interface in response to a second operation of the scope for the first unit test file, including:
analyzing the first unit in response to a second operation of the scope of the test file for the first unit to obtain an in-parameter and an out-parameter of the first unit;
determining a parameter input box according to the parameter input of the first unit;
determining a parameter input box according to parameter output of the first unit;
and outputting a prompt interface according to the input parameter box and the output parameter box.
As a possible implementation manner, the obtaining unit 702 analyzes the first unit to obtain the in-parameter and the out-parameter of the first unit, including:
analyzing the first unit to obtain an input parameter and an output parameter of the first unit, wherein the type of the input parameter of the first unit is a first type;
The third operation includes an input operation, and the acquiring unit 702 acquires test information of the first unit in response to the third operation for the prompt interface, including:
acquiring a second input parameter in response to an input operation for the input parameter box;
in the case that the type of the second entry is the first type, the second entry is determined as the first entry.
As a possible implementation manner, the generating unit 701 is further configured to generate a first unit test template according to the first unit test file and the default test template, where the first unit test template includes a scope;
the second operation responsive to the scope for the first unit test file includes: responsive to a second operation for the scope in the first unit test template;
the generating unit 701 generates a first unit test case of the first unit according to the test information of the first unit in the scope of the first unit test file, including:
and in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
The detailed description of the generating unit 701 and the acquiring unit 702 may be directly obtained by referring to the test plug-ins in the method embodiments shown in fig. 1-2, which are not described herein.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the invention. As shown in fig. 8, the electronic device may include a processor 801, a memory 802, an input device 803, an output device 804, and a connection line 805. The memory 802 may be stand alone with the connection 805 connected to the processor 801. Memory 802 may also be integrated with processor 801. The connection 805 may include a path to communicate information between the above components. Wherein the memory 802 stores computer program instructions, and the processor 801 is configured to execute the computer program instructions stored in the memory 802. The input device 803 may be a touch screen, keyboard, mouse, etc. The output device 804 may be a display screen, or may be other output devices. Wherein:
input means 803 for detecting a first operation for a first unit in the source code to be tested;
the processor 801, when executed, is configured to invoke the computer program stored in the memory 802 to perform the following operations:
generating a first unit test file of a first unit in response to a first operation on the first unit in the source code to be tested, the first unit being determined by a portion of code in the source code to be tested;
Input means 803 for detecting a second operation of the scope for the first unit test file;
the processor 801 is further configured to invoke a computer program stored in the memory 802 to:
in response to a second operation of the scope for the first unit test file, obtaining test information of the first unit, the test information of the first unit including a first entry, a first exit, and a first assertion of the first unit;
and in the action domain of the first unit test file, generating a first unit test case of the first unit according to the test information of the first unit.
As one possible implementation, the processor 801, in response to a second operation for the scope of the first unit test file, obtains test information for the first unit including:
the input means 803 detects a second operation for the scope of the first unit test file;
the output device 804 responds to the second operation of the scope of the first unit test file and outputs a prompt interface, wherein the prompt interface comprises an input-in input box, an output-out input box and an assertion input box;
the input device 803 detects a third operation for the prompt interface;
the processor 801 acquires test information of the first unit in response to a third operation for the prompt interface.
As one possible implementation, the outputting means 804 outputs a prompt interface in response to a second operation of the scope for the first unit test file, including:
the processor 801 configures an assertion input box according to an assertion list in response to a second operation of the scope for the first unit test file, the assertion list including an identification of one or more assertions;
the output device 804 outputs a prompt interface according to the assertion input box;
the third operation includes a fourth operation and a selection operation, and the processor 801 obtains test information of the first unit in response to the third operation for the prompt interface, including:
the input means 803 detects a fourth operation for asserting the input box;
output means 804 outputs the assertion list in response to a fourth operation for the assertion input box;
the input means 803 detects a selection operation for identification of one or more assertions in the assertions list;
the processor 801 obtains a first assertion in response to a selection operation for identification of one or more assertions in the assertion list.
As one possible implementation, the assertion list further includes functional description information of the one or more assertions.
As one possible implementation, the output device 804 outputs a prompt interface in response to a second operation of the scope for the first unit test file, and further includes:
The processor 801 analyzes the first unit in response to a second operation of the scope for the first unit test file to obtain an in-parameter and an out-parameter for the first unit;
the processor 801 determines a parameter input box according to the parameter input of the first unit;
the processor 801 determines a parameter input box according to the parameter output of the first unit;
the output device 804 outputs a prompt interface according to the input-input box and the output-input box.
As a possible implementation, the processor 801 analyzes the first unit to obtain the in-parameter and the out-parameter of the first unit, including:
analyzing the first unit to obtain an input parameter and an output parameter of the first unit, wherein the type of the input parameter of the first unit is a first type;
the third operation includes an input operation, and the processor 801 obtains test information of the first unit in response to the third operation for the prompt interface, including:
the input device 803 detects an input operation for a parameter input box;
the processor 801 acquires a second entry in response to an input operation for the entry input box;
the processor 801 determines the second entry as the first entry in the case where the type of the second entry is the first type.
As a possible implementation, the processor 801 is further configured to invoke a computer program stored in the memory 802 to perform the following operations:
Generating a first unit test template according to the first unit test file and a default test template, wherein the first unit test template comprises a scope;
the second operation responsive to the scope for the first unit test file includes: responsive to a second operation for the scope in the first unit test template;
the processor 801 generates a first unit test case of the first unit according to the test information of the first unit in the scope of the first unit test file, including:
and in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
The embodiment of the invention also discloses a computer readable storage medium, on which computer instructions are stored, which when executed, perform the method in the above method embodiment.
The present invention also discloses a computer program product comprising computer instructions which, when executed, perform the method of the above method embodiments.
The foregoing embodiments have been provided for the purpose of illustrating the technical solution and advantageous effects of the present application in further detail, and it should be understood that the foregoing embodiments are merely illustrative of the present application and are not intended to limit the scope of the present application, and any modifications, equivalents, improvements, etc. made on the basis of the technical solution of the present application should be included in the scope of the present application.
Claims (10)
1. A test case generation method, comprising:
generating a first unit test file of a first unit in source code to be tested in response to a first operation on the first unit, wherein the first unit is determined by part of codes in the source code to be tested;
responding to a second operation of a scope of the first unit test file, and acquiring test information of the first unit, wherein the test information of the first unit comprises a first input parameter, a first output parameter and a first assertion of the first unit;
and in the action domain of the first unit test file, generating a first unit test case of the first unit according to the test information of the first unit.
2. The method of claim 1, wherein the obtaining test information for the first unit in response to a second operation for a scope of the first unit test file comprises:
responsive to a second operation of the scope for the first unit test file, outputting a prompt interface comprising an in-parameter input box, an out-parameter input box, and an assertion input box;
and responding to a third operation aiming at the prompt interface, and acquiring the test information of the first unit.
3. The method of claim 2, wherein outputting a hint interface in response to a second operation of a scope for the first unit test file comprises:
responsive to a second operation of the scope for the first unit test file, configuring an assertion input box according to an assertion list, the assertion list including identifications of one or more assertions;
outputting a prompt interface according to the assertion input box;
the third operation includes a fourth operation and a selection operation, and the responding to the third operation for the prompt interface obtains the test information of the first unit includes:
outputting the assertion list in response to the fourth operation for the assertion input box;
the first assertion is obtained in response to the selection operation for identification of one or more assertions in the assertion list.
4. The method of claim 3, wherein the list of assertions further comprises functional description information of the one or more assertions.
5. The method of claim 2, wherein outputting a hint interface in response to a second operation of a scope for the first unit test file comprises:
Analyzing the first unit in response to a second operation of the scope of the first unit test file to obtain an in-parameter and an out-parameter of the first unit;
determining a parameter input box according to the parameter input of the first unit;
determining a parameter input box according to parameter output of the first unit;
and outputting a prompt interface according to the parameter input box and the parameter output input box.
6. The method of claim 5, wherein analyzing the first unit to obtain the in-parameters and the out-parameters of the first unit comprises:
analyzing the first unit to obtain an input parameter and an output parameter of the first unit, wherein the type of the input parameter of the first unit is a first type;
the third operation includes an input operation, and the responding to the third operation for the prompt interface, obtaining the test information of the first unit includes:
acquiring a second entry in response to the input operation for the entry input box;
and determining the second entry as the first entry in the case that the type of the second entry is the first type.
7. The method according to claim 1, wherein the method further comprises:
Generating a first unit test template according to the first unit test file and a default test template, wherein the first unit test template comprises a scope;
the second operation responsive to the scope for the first unit test file comprises: responsive to a second operation for a scope in the first unit test template;
the generating, in the scope of the first unit test file, a first unit test case of the first unit according to the test information of the first unit includes:
and in the action domain in the first unit test template, generating a first unit test case of the first unit according to the test information of the first unit.
8. A test case generating apparatus, comprising:
the generating unit is used for responding to a first operation of a first unit in source codes to be tested, generating a first unit test file of the first unit, wherein the first unit is determined by part of codes in the source codes to be tested;
an obtaining unit, configured to obtain, in response to a second operation for a scope of the first unit test file, test information of the first unit, where the test information of the first unit includes a first input parameter, a first output parameter, and a first assertion of the first unit;
The generating unit is further configured to generate a first unit test case of the first unit according to the test information of the first unit in the scope of the first unit test file.
9. An electronic device comprising a processor and a memory, the memory for storing a set of computer programs, the processor for invoking the computer programs stored in the memory to perform the method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program or computer instructions, which, when executed, implement the method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111450932.2A CN116204403A (en) | 2021-11-30 | 2021-11-30 | Test case generation method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111450932.2A CN116204403A (en) | 2021-11-30 | 2021-11-30 | Test case generation method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116204403A true CN116204403A (en) | 2023-06-02 |
Family
ID=86517906
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111450932.2A Pending CN116204403A (en) | 2021-11-30 | 2021-11-30 | Test case generation method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116204403A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117609104A (en) * | 2024-01-24 | 2024-02-27 | 盛威时代科技股份有限公司 | Page exception processing method, system and equipment in client test process |
-
2021
- 2021-11-30 CN CN202111450932.2A patent/CN116204403A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117609104A (en) * | 2024-01-24 | 2024-02-27 | 盛威时代科技股份有限公司 | Page exception processing method, system and equipment in client test process |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111061526B (en) | Automatic test method, device, computer equipment and storage medium | |
US8392886B2 (en) | System, program product, and methods to enable visual recording and editing of test automation scenarios for web application | |
US7529977B2 (en) | Automated extensible user interface testing | |
US9396098B2 (en) | Apparatuses, methods, and computer program products for conducting automated tests | |
US8375356B2 (en) | Tabular completion lists | |
US8881105B2 (en) | Test case manager | |
US8201143B2 (en) | Dynamic mating of a modified user interface with pre-modified user interface code library | |
US20060230319A1 (en) | Automated migration of software instructions | |
US7761859B2 (en) | Application development environment with features for aiding a user in writing function calls | |
US20110208470A1 (en) | Operation verifying apparatus, operation verifying method and operation verifying system | |
US8042095B2 (en) | Application development environment with features for increasing the ease and efficiency of viewing function help text | |
CN111427760B (en) | Page test method, device, equipment and storage medium | |
CN104798067A (en) | Web server system, dictionary system, dictionary call method, screen control display method, and demonstration application generation method | |
US20080016488A1 (en) | Output styling in an IDE console | |
CN109189388A (en) | Page configuration method, server and computer-readable medium | |
CN109189688B (en) | Test case script generation method and device and electronic equipment | |
CN116204403A (en) | Test case generation method and device, electronic equipment and storage medium | |
US20090328000A1 (en) | System, apparatus and method for programming a computing device | |
CN115543835A (en) | Method and device for testing front-end page, testing equipment and storage medium | |
CN116257232A (en) | Table generation method, device, equipment and storage medium based on table component | |
US20070089052A1 (en) | Systems, methods, and media for enforcing accessible content development | |
US9268560B2 (en) | Displaying dependent files for computer code in a tabbed-application user interface | |
CN114860302A (en) | Page configuration method and device, electronic equipment and storage medium | |
CN114490330A (en) | Method and device for generating test case | |
CN112765040A (en) | Page testing method, system, computer equipment 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 |