CN112685309A - Unit testing method, unit testing device, storage medium and computer equipment - Google Patents

Unit testing method, unit testing device, storage medium and computer equipment Download PDF

Info

Publication number
CN112685309A
CN112685309A CN202011612000.9A CN202011612000A CN112685309A CN 112685309 A CN112685309 A CN 112685309A CN 202011612000 A CN202011612000 A CN 202011612000A CN 112685309 A CN112685309 A CN 112685309A
Authority
CN
China
Prior art keywords
test
unit
target
case
type
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
CN202011612000.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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011612000.9A priority Critical patent/CN112685309A/en
Publication of CN112685309A publication Critical patent/CN112685309A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application relates to the technical field of test cases and discloses a unit test method, a unit test device, a storage medium and computer equipment, wherein the method comprises the following steps: acquiring a first test unit of an original version and a second test unit of a current version of an application program to be tested; calculating the difference degree of a first test unit and a second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit; classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case; acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type; and executing the target test case of the application program to be tested according to the target test type and generating a test report, so that only the test unit with larger change needs to be tested, the test workload is reduced, and the test efficiency is improved.

Description

Unit testing method, unit testing device, storage medium and computer equipment
Technical Field
The present application relates to the field of test case technologies, and in particular, to a unit test method, an apparatus, a storage medium, and a computer device.
Background
Unit testing refers to testing of the basic constituent units or modules of software, also known as module testing. The basic test unit or module may be a function, a class instance, a method, a stored procedure, etc., or any combination of program code modules with a definite functional definition, a definite specification definition, a definite interface definition, and a small size. The unit test focuses on the unit function and the logic structure of the program module, and aims to find out the logic error of program design or implementation, expose the problem as soon as possible and facilitate the positioning and solving of the problem.
In the prior art, when testing an application program, all test units of the application program are often required to be tested, and therefore when the number of test units is large, a long time is required to be spent on unit testing, which results in low unit testing efficiency.
Disclosure of Invention
The present application mainly aims to provide a unit testing method, an apparatus, a storage medium, and a computer device, and aims to solve the technical problem of low efficiency of the current unit testing method.
In order to achieve the above object, the present application provides a unit testing method, comprising the following steps:
acquiring a test unit of an application program to be tested, wherein the test unit comprises all first test units of an original version of the application program to be tested and all second test units of a current version;
calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type;
and executing the target test case of the application program to be tested according to the target test type, and generating a test report according to an execution result.
In an embodiment, the step of executing the target test case of the application program to be tested according to the target test type and generating a test report according to an execution result includes:
reading test case data of the target test case, wherein the test case data comprises case accessing parameter data, external calling simulation data and an execution expected result;
and executing the target test case according to the case input parameter data and the external calling simulation data, comparing an execution result with the expected execution result, and generating a test report according to the comparison result.
In an embodiment, after the step of generating the test report according to the execution result, the method further includes:
deserializing the serialized operation result in the test report according to a preset rule;
and taking the deserialization result as a final result of the unit test, and displaying the final result through a human-computer interaction interface.
In an embodiment, the step of calculating the difference between the first test unit and the second test unit in the same test unit type includes:
acquiring a first code of the first test unit and a second code of the second test unit;
and calculating the difference degree of the first code and the second code under the same test unit type.
In an embodiment, the step of executing the target test case of the application program to be tested according to the target test type includes:
acquiring a test environment required by the target test case during execution according to the target test type;
and selecting the test equipment corresponding to the test environment to execute the target test case.
In an embodiment, after the step of generating the test report according to the execution result, the method further includes:
sending the test report to an auditing server;
and receiving adjustment information sent by the auditing server, adjusting the target test case based on the adjustment information, and performing retesting by using the adjusted target test case, wherein the adjustment information is information for adjusting the target test case by the auditing server according to the test report.
In an embodiment, before the step of executing the target test case of the application program to be tested according to the target test type, the method further includes:
and clearing the residual installation files and log files of the application program to be tested in the last test by using the batch processing files.
The present application further provides a unit testing device, comprising:
the system comprises an acquisition module, a test module and a control module, wherein the acquisition module is used for acquiring test units of an application program to be tested, and the test units comprise all first test units of an original version of the application program to be tested and all second test units of a current version of the application program to be tested;
the calculation module is used for calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
the classification module is used for classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
the determining module is used for acquiring a target test type selected by a user from the test types and determining a target test case from the test cases according to the target test type;
and the generating module is used for executing the target test case of the application program to be tested according to the target test type and generating a test report according to an execution result.
The present application further provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of any of the above methods when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of any of the above.
According to the unit testing method, the unit testing device, the storage medium and the computer equipment, all first testing units of the original version of the application program to be tested and all second testing units of the current version are obtained; then calculating the difference between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit; classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case; acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type; the target test case of the application program to be tested is executed according to the target test type, and the test report is generated according to the execution result, so that only the test unit with larger change needs to be tested, all the test units do not need to be tested, the test workload is reduced, the problems of large test workload and long time of the test case in the prior art are solved, the automatic unit test is realized, and the test efficiency is improved.
Drawings
FIG. 1 is a schematic flow chart illustrating a unit testing method according to an embodiment of the present application;
FIG. 2 is a block diagram of a unit testing apparatus according to an embodiment of the present application;
fig. 3 is a block diagram illustrating a structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The unit testing method provided in the embodiment of the present application is to solve the technical problem that when testing a currently developed application program, all test units of the application program are often required to be tested, and therefore when the number of the test units is large, a long time is required to be spent for unit testing, which results in low unit testing efficiency, and referring to fig. 1, the unit testing method includes the steps of:
s1, obtaining a test unit of the application program to be tested, wherein the test unit comprises all first test units of the original version of the application program to be tested and all second test units of the current version;
s2, calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
s3, classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
s4, acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type;
and S5, executing the target test case of the application program to be tested according to the target test type, and generating a test report according to an execution result.
In this embodiment, the unit test is a white-box test, which is intended to detect errors and bugs in the program code, to ensure the quality of the application program from the source, and to perform a coverage test on each line of code or code block of the application program to determine whether the line of code or code block is correct. Generally, a test case is used for testing and verifying a source program code, a test report is generated by compiling, and errors and bugs in the source program code are judged by interpreting the test report. Wherein, the report format of the test report can be html, txt or other formats. The test report content may include the test packet name, the test class name, the number of test runs, the number of defects, the success rate, the test status, the test time, the detailed defect details, and so on.
Specifically, in this embodiment, all first test units of an original version of an application program to be tested are compared with all second test units of a current version one by one to determine a new adding, a modification or a deletion condition of the current version compared with the original version, the first test units of the original version and the second test units corresponding to the current version are divided into the same test unit type, a difference between the first test units and the second test units in the same test unit type is calculated, a test unit with a difference higher than a preset value is obtained from the first test units according to the difference to serve as a target test unit, a test case of the target test unit is generated, and a test unit with a larger code new adding, modification or deletion is tested in a subsequent application program development process.
In addition, the present embodiment further classifies the test cases according to the development situation, such as new, modified, or deleted test cases. For example, a database data source may be configured first, after configuration, a program may automatically query tables and fields in the database, and a code may automatically generate three sql statements, i.e., insert, update, and delete, for performing tests of adding, modifying, and deleting to a test case. When the test system is used, a user can click the disable button according to the test requirement, the newly added, modified and deleted actions can be automatically carried out on the database, the tested case can be tested, and the newly added, modified and deleted data can be tested, so that the test purpose is achieved.
Specifically, a data source database is configured firstly, a table of a test case to be tested can be automatically read, and table information including table names, field names, indexes and the like is identified and read in a full amount, and is used for storing all information of the tested case, a program can generate a test template for storing information of the captured table names, field names, indexes and the like, if the tested case only has one table template, the information of one table is displayed, if 100 tables exist, 100 pieces of table information, namely 100 sheets are displayed, data are divided into three columns according to the table names, the field names and the index names, all data of the three columns are displayed, and how much data is displayed in a database. After data is captured, a program can automatically generate a page, and a tester needs to test what test type and clicks a corresponding button. By clicking the target test type, data in the template can be directly operated into a database through a program, for example, a plurality of pieces of borrowed data information are arranged in the template, the borrowed information needs to be written into the database by the program, at the moment, a tester does not need to write a piece of Junit test code, whether the test code can realize the newly-added data or not only needs to maintain a piece of borrowed data in the template in advance, and a page newly-added button is clicked, so that the program automatically tests.
Furthermore, various test cases written by developers and testers can be stored locally in advance, and when an executable application is generated, the test case which can be used for testing the executable application can be selected from the pre-stored test cases according to the application package name of the executable application. Of course, the test case may be selected according to other identifiers that can uniquely determine the executable application.
The unit testing method comprises the steps of obtaining all first testing units of an original version of an application program to be tested and all second testing units of a current version; then calculating the difference between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit; classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case; acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type; the target test case of the application program to be tested is executed according to the target test type, and the test report is generated according to the execution result, so that only the test unit with larger change needs to be tested, all the test units do not need to be tested, the test workload is reduced, the problems of large test workload and long time of the test case in the prior art are solved, the automatic unit test is realized, and the test efficiency is improved.
In an embodiment, in step S5, the step of executing the target test case of the application program to be tested according to the target test type and generating a test report according to an execution result may specifically include:
reading test case data of the target test case, wherein the test case data comprises case accessing parameter data, external calling simulation data and an execution expected result;
and executing the target test case according to the case input parameter data and the external calling simulation data, comparing an execution result with the expected execution result, and generating a test report according to the comparison result.
In this embodiment, the target test case is executed according to the case reference data and the external call simulation data, the execution result is compared with the expected execution result to determine whether the execution result is consistent with the expected execution result, and a test report is generated according to the comparison result. The test report may include a comparison result, error information, version information, and the like.
When the result obtained by executing the target test case is compared with the expected execution result, the target sequence is defaulted to be the character string, then the full-value matching comparison is carried out, and the custom comparison is also supported. If the comparison is self-defined, a self-defined value needs to be preset.
In an embodiment, in step S5, after the step of generating the test report according to the execution result, the method may further include:
deserializing the serialized operation result in the test report according to a preset rule;
and taking the deserialization result as a final result of the unit test, and displaying the final result through a human-computer interaction interface.
The present embodiment may generate a test report in XML format with reference to the automatic schema of the CUnit framework. However, since the test report is a code obtained by sequencing the test result according to the preset rule by CUnit, it needs to be readable by a person with corresponding professional knowledge. Therefore, in order to make the test result easier to understand and understand, the test report needs to be analyzed, the present embodiment may perform deserialization on the test report in the XML format according to the preset rule, take the deserialization result as the final result of the test unit, and display the result through the human-computer interaction interface, so that the result of the test unit is displayed in a more intuitive manner.
In an embodiment, in step S5, the step of executing the target test case of the application program to be tested according to the target test type may further include:
acquiring a test environment required by the target test case during execution according to the target test type;
and selecting the test equipment corresponding to the test environment to execute the target test case.
Generally, in a conventional application program testing process, a tester builds a testing environment, and then completes related tests in the built testing environment. Therefore, it is necessary to detect whether a tester establishes a corresponding test environment in advance before a test operation starts, so that when a target test case is tested, a test device in the corresponding test environment is selected for testing. Specifically, in this embodiment, a suitable test device is selected for the target test case, so that a corresponding test is completed in a test environment of the test device, and after the test is completed, the test device can feed back a corresponding test result to a developer, so as to ensure that the application program after the test can normally work.
It should be noted that the correspondence between the test cases and the executable applications and the test devices may be one-to-one, one-to-many, many-to-one, and the like, which is not limited in the embodiments of the present invention. When the test cases are stored, each test case can be marked with a corresponding test object and a corresponding test environment, so that when the test cases need to be tested, proper test equipment can be quickly selected for the test cases, and corresponding tests can be completed in the test environment of the test equipment. After the test is finished, the test equipment can feed back the test result to the developer.
In an embodiment, in step S2, the step of calculating the difference between the first test unit and the second test unit in the same test unit type may specifically include:
acquiring a first code of the first test unit and a second code of the second test unit;
and calculating the difference degree of the first code and the second code under the same test unit type.
In this embodiment, the first code of the first test unit and the second code of the second test unit are compared one by one to determine the new addition, modification or deletion condition of the code in the version to be tested. During comparison, the code change amount of the first code which is modified, added or deleted on the basis of the original second code can be counted, and the difference degree is calculated according to the code change amount and the code amount of the second code, so that the accuracy of calculating the difference degree is improved.
In an embodiment, in step S5, after the step of generating the test report according to the execution result, the method may further include:
sending the test report to an auditing server;
and receiving adjustment information sent by the auditing server, adjusting the target test case based on the adjustment information, and performing retesting by using the adjusted target test case, wherein the adjustment information is information for adjusting the target test case by the auditing server according to the test report.
In this embodiment, a test report containing a test result is sent to an audit server, the audit server analyzes the test report to adjust the target test case, generate adjustment information, and return the adjustment information to the server, after receiving the adjustment information sent by the audit server, the server adjusts the target test case based on the adjustment information, for example, parameters and codes of the target test case are adjusted, and a retest is performed using the adjusted target test case. Of course, the test report can also be fed back to the developer, so that the developer can judge whether the target test case needs to be improved according to the test report, if so, the update of the developer to the target test case according to the test report is received, and the updated target test case is tested again until the test result meets the expectation.
In an embodiment, in step S5, before the step of executing the target test case of the application program to be tested according to the target test type, the method may further include:
and clearing the residual installation files and log files of the application program to be tested in the last test by using the batch processing files.
In this embodiment, the daily test work is performed every day, and before the formal work is started, the environment on the assembly computer needs to be cleaned up, unnecessary software processes installed on the operating system are closed, the previous setting parameters and flag bits are deleted, temporary files are deleted, and the like, so that the construction process is prevented from being suspended, and the environment can continuously run. And after the environment is cleaned, creating a directory which is required to be used when the version is constructed according to the new parameters configured in the parameter file. The parameters to be set comprise resources on which the built version depends, a target version storage directory, a temporary directory for storing files, a log directory, a compiling directory and the like. In the embodiment, the old version installation file and the log file are cleared, so that the occupation of system resources can be effectively avoided, and the normal operation of the new software version is ensured.
Referring to fig. 2, an embodiment of the present application further provides a unit testing apparatus, including:
the system comprises an acquisition module 1, a test module and a test module, wherein the acquisition module is used for acquiring test units of an application program to be tested, and the test units comprise all first test units of an original version of the application program to be tested and all second test units of a current version of the application program to be tested;
the calculation module 2 is used for calculating the difference between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
the classification module 3 is used for classifying the test cases according to the development condition of the second test unit to obtain the test types of the test cases;
the determining module 4 is configured to obtain a target test type selected by a user from the test types, and determine a target test case from the test cases according to the target test type;
and the generating module 5 is configured to execute the target test case of the application program to be tested according to the target test type, and generate a test report according to an execution result.
In this embodiment, the unit test is a white-box test, which is intended to detect errors and bugs in the program code, to ensure the quality of the application program from the source, and to perform a coverage test on each line of code or code block of the application program to determine whether the line of code or code block is correct. Generally, a test case is used for testing and verifying a source program code, a test report is generated by compiling, and errors and bugs in the source program code are judged by interpreting the test report. Wherein, the report format of the test report can be html, txt or other formats. The test report content may include the test packet name, the test class name, the number of test runs, the number of defects, the success rate, the test status, the test time, the detailed defect details, and so on.
Specifically, in this embodiment, all first test units of an original version of an application program to be tested are compared with all second test units of a current version one by one to determine a new adding, a modification or a deletion condition of the current version compared with the original version, the first test units of the original version and the second test units corresponding to the current version are divided into the same test unit type, a difference between the first test units and the second test units in the same test unit type is calculated, a test unit with a difference higher than a preset value is obtained from the first test units according to the difference to serve as a target test unit, a test case of the target test unit is generated, and a test unit with a larger code new adding, modification or deletion is tested in a subsequent application program development process.
In addition, the present embodiment further classifies the test cases according to the development situation, such as new, modified, or deleted test cases. For example, a database data source may be configured first, after configuration, a program may automatically query tables and fields in the database, and a code may automatically generate three sql statements, i.e., insert, update, and delete, for performing tests of adding, modifying, and deleting to a test case. When the test system is used, a user can click the disable button according to the test requirement, the newly added, modified and deleted actions can be automatically carried out on the database, the tested case can be tested, and the newly added, modified and deleted data can be tested, so that the test purpose is achieved.
Specifically, a data source database is configured firstly, a table of a test case to be tested can be automatically read, and table information including table names, field names, indexes and the like is identified and read in a full amount, and is used for storing all information of the tested case, a program can generate a test template for storing information of the captured table names, field names, indexes and the like, if the tested case only has one table template, the information of one table is displayed, if 100 tables exist, 100 pieces of table information, namely 100 sheets are displayed, data are divided into three columns according to the table names, the field names and the index names, all data of the three columns are displayed, and how much data is displayed in a database. After data is captured, a program can automatically generate a page, and a tester needs to test what test type and clicks a corresponding button. By clicking the target test type, data in the template can be directly operated into a database through a program, for example, a plurality of pieces of borrowed data information are arranged in the template, the borrowed information needs to be written into the database by the program, at the moment, a tester does not need to write a piece of Junit test code, whether the test code can realize the newly-added data or not only needs to maintain a piece of borrowed data in the template in advance, and a page newly-added button is clicked, so that the program automatically tests.
Furthermore, various test cases written by developers and testers can be stored locally in advance, and when an executable application is generated, the test case which can be used for testing the executable application can be selected from the pre-stored test cases according to the application package name of the executable application. Of course, the test case may be selected according to other identifiers that can uniquely determine the executable application.
As described above, it can be understood that each component of the unit testing apparatus provided in the present application may implement the function of any one of the unit testing methods described above, and the detailed structure is not described again.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used for data such as a relational extraction model, a drug discovery model and the like. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a unit testing method.
The processor executes the unit testing method, and the method comprises the following steps:
acquiring a test unit of an application program to be tested, wherein the test unit comprises all first test units of an original version of the application program to be tested and all second test units of a current version;
calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type;
and executing the target test case of the application program to be tested according to the target test type, and generating a test report according to an execution result.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, the computer program, when executed by a processor, implementing a unit testing method, including the steps of:
acquiring a test unit of an application program to be tested, wherein the test unit comprises all first test units of an original version of the application program to be tested and all second test units of a current version;
calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type;
and executing the target test case of the application program to be tested according to the target test type, and generating a test report according to an execution result.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
To sum up, the most beneficial effect of this application lies in:
according to the unit testing method, the unit testing device, the storage medium and the computer equipment, all first testing units of the original version of the application program to be tested and all second testing units of the current version are obtained; then calculating the difference between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit; classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case; acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type; the target test case of the application program to be tested is executed according to the target test type, and the test report is generated according to the execution result, so that only the test unit with larger change needs to be tested, all the test units do not need to be tested, the test workload is reduced, the problems of large test workload and long time of the test case in the prior art are solved, the automatic unit test is realized, and the test efficiency is improved.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A method of unit testing, comprising:
acquiring a test unit of an application program to be tested, wherein the test unit comprises all first test units of an original version of the application program to be tested and all second test units of a current version;
calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
acquiring a target test type selected by a user from the test types, and determining a target test case from the test cases according to the target test type;
and executing the target test case of the application program to be tested according to the target test type, and generating a test report according to an execution result.
2. The method according to claim 1, wherein the step of executing the target test case of the application program to be tested according to the target test type and generating a test report according to an execution result comprises:
reading test case data of the target test case, wherein the test case data comprises case accessing parameter data, external calling simulation data and an execution expected result;
and executing the target test case according to the case input parameter data and the external calling simulation data, comparing an execution result with the expected execution result, and generating a test report according to the comparison result.
3. The method of claim 1, wherein the step of generating a test report according to the execution result is followed by:
deserializing the serialized operation result in the test report according to a preset rule;
and taking the deserialization result as a final result of the unit test, and displaying the final result through a human-computer interaction interface.
4. The method of claim 1, wherein the step of calculating the difference between the first test unit and the second test unit for the same test unit type comprises:
acquiring a first code of the first test unit and a second code of the second test unit;
and calculating the difference degree of the first code and the second code under the same test unit type.
5. The method of claim 1, wherein the step of executing the target test case of the application under test according to the target test type comprises:
acquiring a test environment required by the target test case during execution according to the target test type;
and selecting the test equipment corresponding to the test environment to execute the target test case.
6. The method of claim 1, wherein the step of generating a test report according to the execution result is followed by:
sending the test report to an auditing server;
and receiving adjustment information sent by the auditing server, adjusting the target test case based on the adjustment information, and performing retesting by using the adjusted target test case, wherein the adjustment information is information for adjusting the target test case by the auditing server according to the test report.
7. The method of claim 1, wherein before the step of executing the target test case of the application under test according to the target test type, the method further comprises:
and clearing the residual installation files and log files of the application program to be tested in the last test by using the batch processing files.
8. A unit testing apparatus, comprising:
the system comprises an acquisition module, a test module and a control module, wherein the acquisition module is used for acquiring test units of an application program to be tested, and the test units comprise all first test units of an original version of the application program to be tested and all second test units of a current version of the application program to be tested;
the calculation module is used for calculating the difference degree between the first test unit and the second test unit under the same test unit type, selecting the test unit with the difference degree higher than a preset value from the first test unit as a target test unit, and generating a test case of the target test unit;
the classification module is used for classifying the test cases according to the development condition of the second test unit to obtain the test type of each test case;
the determining module is used for acquiring a target test type selected by a user from the test types and determining a target test case from the test cases according to the target test type;
and the generating module is used for executing the target test case of the application program to be tested according to the target test type and generating a test report according to an execution result.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor when executing the computer program implements the steps of the unit testing method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the unit testing method of any one of claims 1 to 7.
CN202011612000.9A 2020-12-30 2020-12-30 Unit testing method, unit testing device, storage medium and computer equipment Pending CN112685309A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011612000.9A CN112685309A (en) 2020-12-30 2020-12-30 Unit testing method, unit testing device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011612000.9A CN112685309A (en) 2020-12-30 2020-12-30 Unit testing method, unit testing device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN112685309A true CN112685309A (en) 2021-04-20

Family

ID=75455337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011612000.9A Pending CN112685309A (en) 2020-12-30 2020-12-30 Unit testing method, unit testing device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN112685309A (en)

Similar Documents

Publication Publication Date Title
US11379348B2 (en) System and method for performing automated API tests
US11023367B1 (en) Systems and methods for testing a software application
CN110941546A (en) Automatic test method, device, equipment and storage medium for WEB page case
US8954930B2 (en) System and method for reducing test effort by object risk analysis
US9880832B2 (en) Software patch evaluator
US20190005111A1 (en) Relational log entry instituting system
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN113127347B (en) Interface testing method, device, equipment and readable storage medium
CN110908895A (en) Page automatic testing method and device, computer equipment and storage medium
CN112527815A (en) Script migration method and device for database, computer equipment and storage medium
CN110851351A (en) Deployment environment testing method and device, computer equipment and storage medium
CN113448862B (en) Software version testing method and device and computer equipment
CN113434395B (en) Automatic generation method, device, equipment and medium for test cases
CN112540924A (en) Interface automation test method, device, equipment and storage medium
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN113126955A (en) Random data generation method and device, intelligent terminal and storage medium
CN113268470A (en) Efficient database rollback scheme verification method
CN117493188A (en) Interface testing method and device, electronic equipment and storage medium
CN114816971A (en) Data processing method, related equipment and storage medium
CN112685309A (en) Unit testing method, unit testing device, storage medium and computer equipment
CN115033481A (en) Method and device for automatic test code generation based on browser access and computer equipment
CN111813665A (en) Big data platform interface data testing method and system based on python
CN113052463B (en) Workflow verification method, workflow verification device, computer equipment and storage medium
CN116594918B (en) Test case change influence analysis method, device, equipment and storage medium
CN111104318B (en) Unit test result export method and device and electronic equipment

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