CN115328764A - Test code optimization method based on automatic test and related equipment thereof - Google Patents

Test code optimization method based on automatic test and related equipment thereof Download PDF

Info

Publication number
CN115328764A
CN115328764A CN202210837738.8A CN202210837738A CN115328764A CN 115328764 A CN115328764 A CN 115328764A CN 202210837738 A CN202210837738 A CN 202210837738A CN 115328764 A CN115328764 A CN 115328764A
Authority
CN
China
Prior art keywords
test
code
source
code set
optimization
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
CN202210837738.8A
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 Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202210837738.8A priority Critical patent/CN115328764A/en
Publication of CN115328764A publication Critical patent/CN115328764A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Abstract

The embodiment of the application belongs to the field of research and development management, is applied to the field of automatic testing, and relates to a test code optimization method based on automatic testing, which comprises the steps of obtaining a source test code set and a function code to be tested and inputting a pre-constructed automatic testing tool; generating corresponding problem codes for the function codes based on a preset problem code generation model; acquiring a primary selection test code set and a preferred test code set; determining the validity of a source test code set; judging whether the effectiveness can be optimized; if the optimization can be carried out, carrying out optimization; if not, the automated test procedure is terminated. The workload of testing personnel can be reduced through automatic testing, the validity of the testing code can be verified, and automatic optimization is performed, so that the optimized testing code has a reasonable testing range, and the BUG can be found in time when a program has defects.

Description

Test code optimization method based on automatic test and related equipment thereof
Technical Field
The application relates to the technical field of research and development management and test code optimization based on automatic testing, in particular to a test code optimization method based on automatic testing and related equipment thereof.
Background
The test codes have the functions of finding and expanding the test range, reasonably expanding the test coverage and finding potential defects in software in advance, so that when a tester designs the test codes, the tester is required to design the test codes with the reasonable test range and avoid the potential defects of the service.
At present, most of testers often use an automatic test tool to automatically generate test cases in order to improve the test efficiency and shorten the construction time of test codes, and the test cases can ensure the comprehensiveness of test coverage, but a large amount of ineffective test codes are easily generated, and potential defects in software cannot be found in advance. Therefore, it is desirable to provide a test code optimization scheme for automated testing to optimize an automated test case to solve the above technical problems.
Disclosure of Invention
The embodiment of the application aims to provide a test code optimization method, a test code optimization device, computer equipment and a storage medium based on automatic testing, so that when the automatic testing is carried out, the workload of testers can be reduced through the automatic testing, the validity of test codes can be verified, and the test codes are automatically optimized, so that the optimized test codes have a reasonable test range, and BUG can be timely discovered when a program has a defect.
In order to solve the above technical problem, an embodiment of the present application provides a test code optimization method based on an automated test, which adopts the following technical solutions:
a test code optimization method based on automatic test comprises the following steps:
acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool;
based on the source test code set, performing a first test on the function code to be tested to obtain a first test success set which is used as a primary selection test code set;
generating corresponding problem codes for the function codes based on a preset problem code generation model;
performing a second test on the problem codes based on the initially selected test code set to obtain a second test failure set serving as a preferred test code set;
respectively acquiring the number of test code entries in a source test code set and a preferred test code set, and determining the effectiveness of the source test code set based on a preset test effectiveness algorithm;
judging whether the effectiveness can be optimized or not based on preset optimization conditions;
if the optimization can be carried out, replacing the preferred test code set with the source test code set;
and if the optimization cannot be carried out, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
Further, after the step of obtaining the first test success set as the initially selected test code set, the method further includes:
and acquiring a source test code item used by the functional code when the test is successful based on the test log and the test return value, and adding the source test code item as a set element into the first test success set.
Further, after the step of obtaining a source test code entry used by the function code when the test is successful, taking the source test code entry as a set element, adding the source test code entry into the first test success set, and constructing the first test success set, the method further includes:
identifying elements in the first test success set;
and if the first test success concentrated element is a null value, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
Further, the step of generating the corresponding problem code for the function code based on the preset problem code generation model specifically includes:
pre-constructing a problem code generation model, wherein the problem code generation model comprises the following steps: the system comprises a model input layer, a model processing layer and a model output layer;
acquiring a function code input from the model input layer, taking a problem introduction condition preset by the model processing layer as a replacement condition, and replacing a corresponding code position in the function code;
and outputting the replaced function code through the model output layer, and taking the function code as a problem code.
Further, the step of determining the validity of the source test code set based on the preset test validity algorithm specifically includes:
the preset test validity algorithm comprises the following steps:
Figure BDA0003749364450000031
determining validity of a source test code set, wherein Q 2 Representing the number, Q, of test code entries in a preferred test code set 1 The number of test code entries in the source test code set is indicated, and P indicates the validity of the source test code set.
Further, the determining whether the validity can be optimized based on the preset optimization condition specifically includes:
if the test effectiveness is 0 or 100%, the test effectiveness cannot be optimized;
and if the test effectiveness is not 0 and not 100%, optimizing the test effectiveness.
Further, after determining the validity of the source test code set, the method further includes:
and when the preset monitoring interface is monitored to receive a test ending instruction, obtaining the test validity when the automatic test program is terminated and a source test code set corresponding to the test validity, and outputting the source test code set as an automatic test result.
In order to solve the above technical problem, an embodiment of the present application further provides a test code optimization apparatus based on an automated test, which adopts the following technical solutions:
an automated test-based test code optimization apparatus, comprising:
the test preparation module is used for acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool;
the first testing module is used for carrying out first testing on the function codes to be tested based on the source testing code set to obtain a first testing success set which is used as a primary selection testing code set;
the problem code generation module is used for generating corresponding problem codes for the function codes based on a preset problem code generation model;
the second testing module is used for carrying out second testing on the problem codes based on the initially selected testing code set to obtain a second testing failure set which is used as a preferred testing code set;
the test validity algorithm module is used for respectively acquiring the number of test code entries in the source test code set and the preferred test code set and determining the validity of the source test code set based on a preset test validity algorithm;
the optimization judgment module is used for judging whether the effectiveness can be optimized or not based on preset optimization conditions;
the optimization processing module is used for replacing the preferred test code set with the source test code set if the optimization is available;
and the test termination module is used for sending a test termination instruction to the preset monitoring interface and terminating the automatic test program if the optimization cannot be performed.
Compared with the prior art, the embodiment of the application mainly has the following beneficial effects:
according to the test code optimization method based on the automatic test, a source test code set and a function code to be tested are obtained and input into a pre-constructed automatic test tool; generating corresponding problem codes for the function codes based on a preset problem code generation model; acquiring a primary selection test code set and a preferred test code set; determining the validity of a source test code set; judging whether the effectiveness can be optimized; if the optimization can be carried out, carrying out optimization; if not, the automated test procedure is terminated. The workload of testing personnel can be reduced through automatic testing, the validity of the testing code can be verified, and automatic optimization is performed, so that the optimized testing code has a reasonable testing range, and the BUG can be found in time when a program has defects.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for automated test-based test code optimization according to the present application;
FIG. 3 is a flowchart of one embodiment of step 203 of FIG. 2;
FIG. 4 is a schematic block diagram illustrating one embodiment of an automated test-based test code optimization apparatus according to the present application;
FIG. 5 is a block diagram illustrating one embodiment of module 403 shown in FIG. 4;
FIG. 6 is a schematic block diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof in the description and claims of this application and the description of the figures above, are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the foregoing drawings are used for distinguishing between different objects and not for describing a particular sequential order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various communication client applications, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the test code optimization method based on the automated test provided in the embodiments of the present application is generally executed by a server/terminal device, and accordingly, the test code optimization apparatus based on the automated test is generally disposed in the server/terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation.
With continued reference to FIG. 2, a flow diagram of one embodiment of a method for automated test-based test code optimization is shown, in accordance with the present application. The test code optimization method based on the automatic test comprises the following steps:
step 201, a source test code set and a function code to be tested are obtained and input into a pre-constructed automatic test tool.
In this embodiment, the automatic testing tool may be an existing open-source automatic testing tool, or an automatic testing tool designed by a tester and conforming to the testing logic in this embodiment, and the automatic testing tool conforms to the requirements of the automatic testing tool in this embodiment as long as the automatic testing tool includes an input layer, a testing layer, and an output layer.
The automatic test tool can be selected to improve the test logic of the test layer, can be designed by self, can meet the test logic of the embodiment, is convenient to select the test tool, does not need to introduce a complex test tool, and is friendly to a new testing hand.
In this embodiment, the source test code set includes: a plurality of verification codes constructed in advance by a tester.
In this embodiment, the function code to be tested includes: service code and performance code to be tested.
The function code to be tested can be a single function method or a plurality of function methods in a service scene, if the function code to be tested is a single function method, the validity of the test code of the method is directly tested to obtain a test result, if the function code is a plurality of function methods in the service scene, each method is directly tested by a plurality of pre-constructed verification codes, then the test code and the test validity corresponding to each method are optimized, the test classification of the test code is indirectly realized, a tester does not need to establish the test code according to the single method, the test is automatically carried out, the function method suitable for the test code is identified, and the labor consumption of the tester is saved.
Step 202, based on the source test code set, performing a first test on the function code to be tested, and acquiring a first test success set as a primary selection test code set.
In this embodiment, after the step of obtaining the first test success set as the initially selected test code set, the method further includes: and based on the test log and the test return value, acquiring a source test code entry used by the functional code when the test is successful, and adding the source test code entry as a set element into the first test success set.
In this embodiment, after the steps of obtaining a source test code entry used by the functional code when the test is successful, taking the source test code entry as a set element, adding the source test code entry into the set element, and constructing the first test success set, the method further includes: identifying elements in the first test success set; and if the elements in the first test success set are null values, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
If the first test success concentrated element is a null value, the source test code set is represented, and no source test code entry capable of enabling the function code to be tested to be successful exists, obviously, the test validity does not exist at the moment, a test ending instruction is sent to a preset monitoring interface in time to remind a test monitoring person that the source test code set is invalid, and the automatic test program is terminated, so that the test monitoring person can provide a new source test code set in time.
And 203, generating corresponding problem codes for the function codes based on a preset problem code generation model.
In this embodiment, the step of generating the corresponding problem code for the function code based on the preset problem code generation model specifically includes: pre-constructing a problem code generation model, wherein the problem code generation model comprises the following steps: the system comprises a model input layer, a model processing layer and a model output layer; acquiring a function code input from the model input layer, taking a problem introduction condition preset by the model processing layer as a replacement condition, and replacing a corresponding code position in the function code; and outputting the replaced function code through the model output layer, and taking the function code as a problem code.
With continuing reference to fig. 3, a flowchart of one embodiment of the problem code generation in step 203 is shown, which specifically includes:
step 301, pre-constructing a problem code generation model, wherein the problem code generation model includes: the system comprises a model input layer, a model processing layer and a model output layer;
step 302, acquiring a function code input from the model input layer, taking a problem introduction condition preset by the model processing layer as a replacement condition, and replacing a corresponding code position in the function code;
in this embodiment, the problem introduction condition includes: when the function code to be tested comprises the following codes, corresponding changes are carried out, specifically:
when an operator exists, the operator + change-, + change/, + change-, ", the relation operator"! = change =, > change <, = = change! =, < change >, | change, > > change, < < < < ", logical operator" & & change |, | change & ", assignment operator" + = change- =, - =;
when a specific code structure exists, such as a loop structure, a conditional statement, an exception statement, and an empty judgment, corresponding changes are made, for example: the loop structure 'break changes continue, continue changes break', the conditional statement 'if statement is always true, if statement is always false', the exception statement 'deletes the try catch exception code block', and the null decision 'deletes all types of null statements';
for specific variable values, such as Boolean value, date format, numerical accuracy, corresponding changes are made, for example: boolean values "true to false, false to true", date formats "YYYY to YYYY, YYYY to YYYY", numerical precisions "integer to fractional, fractional to integer";
for a specific function call, such as a similar function, a polymorphic function, an error-prone function, a corresponding change is made, for example: the similarity function "getList changes getWhiteList, getWhiteList changes getList", the polymorphic functions "foo (xx, 0) changes foo (xx), foo (xx) changes foo (xx, 0)", the error-prone function "parseBool changes getBoool, getBoool changes parseBool".
And step 303, outputting the replaced function code through the model output layer, and taking the function code as a problem code.
And 204, performing a second test on the problem codes based on the initially selected test code set to obtain a second test failure set serving as a preferred test code set.
In this embodiment, after the step of obtaining the second test failure set as the preferred test code set, the method further includes: and acquiring a primary test code entry used by the problem code when the test fails based on the test log and the test return value, and adding the primary test code entry as a set element into the second test failure set.
And verifying the source test code item successfully tested by the function code by using the problem code in an anti-test mode, wherein when the source test code item can also be successfully tested, the test results of the source test code item on the problem code and the function code are the same, and the problem code and the function code cannot be distinguished, so that the source test code item corresponding to the test failure is obtained and used as an optimized test code item.
And through a positive and negative test mode, the source test code items without distinguishing utility for the automatic test are screened out, only the source test code items with distinguishing utility for the automatic test are reserved, and the storage pressure of a related database is reduced.
Step 205, respectively obtaining the number of test code entries in the source test code set and the preferred test code set, and determining the validity of the source test code set based on a preset validity test algorithm.
In this embodiment, the step of determining the validity of the source test code set based on the preset test validity algorithm specifically includes: the preset test validity algorithm comprises the following steps:
Figure BDA0003749364450000101
determining validity of a source test code set, wherein Q 2 Representing the number, Q, of test code entries in a preferred test code set 1 The number of test code entries in the source test code set is indicated, and P indicates the validity of the source test code set.
And step 206, judging whether the effectiveness can be optimized or not based on preset optimization conditions.
In this embodiment, the determining whether the effectiveness can be optimized based on the preset optimization condition specifically includes: if the test effectiveness is 0 or 100%, the test effectiveness cannot be optimized; and if the test effectiveness is not 0 and not 100%, optimizing the test effectiveness.
If the test validity is 0, that is, when the second test is performed, the second test failure set has no element, that is, the function code can be successfully tested, and the problem code can also be successfully tested, so that the test validity is 0, if the test validity is 100%, that is, when the second test is performed, the second test failure set includes all elements in the initially selected test code set, that is, the function code can be successfully tested, and the problem code cannot be successfully tested, and therefore, the test validity is 100%, if the test validity is not 0 and not 100%, that is, when the second test is performed, the second test failure set has elements, but the number of the elements is smaller than that of the elements in the initially selected test code set, and therefore, the preferred test code set can be replaced by the source test code set, and automatic optimization is performed.
And step 207, if the optimization is available, replacing the preferred test code set with the source test code set.
And step 208, if the optimization cannot be performed, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
In this embodiment, after determining the validity of the source test code set, the method further includes: and when the preset monitoring interface is monitored to receive a test ending instruction, obtaining the test validity when the automatic test program is terminated and a source test code set corresponding to the test validity, and outputting the source test code set as an automatic test result. In essence, if a test ending instruction is received, the test validity when the automatic test program is terminated and the source test code set corresponding to the test validity are obtained and used as an automatic test result, at this time, the output test validity is a binarization result, namely, not 0, namely, 100%, and an automatic test tool is sampled to obtain the binarization test validity result, so that a tester can distinguish the binarization test validity more conveniently, the distinguishing difficulty when the test validity is a plurality of interval values in the past is avoided, and meanwhile, the source test code set corresponding to the test validity, namely, an empty set corresponding to 0 or an optimal test code set corresponding to 100% is also provided, so that the tester can construct a further source test code set conveniently, and select an applicable test code.
The method comprises the steps of acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool; generating corresponding problem codes for the function codes based on a preset problem code generation model; acquiring a primary selection test code set and a preferred test code set; determining the validity of a source test code set; judging whether the effectiveness can be optimized; if the optimization can be carried out, carrying out optimization; if the test code cannot be optimized, the automatic test program is terminated, wherein a problem code generation model is introduced during automatic test processing to perform positive and negative tests and automatic optimization, and binary test validity and output results are obtained.
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 may be implemented by hardware that is configured to be instructed by computer-readable instructions, which can be stored in a computer-readable storage medium, and when executed, the programs may include the processes of the embodiments of the methods described above. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of execution is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 4, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a test code optimization apparatus based on an automated test, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 4, the test code optimization apparatus 400 based on automated testing according to this embodiment includes: the system comprises a test preparation module 401, a first test module 402, a problem code generation module 403, a second test module 404, a test validity algorithm module 405, an optimization judgment module 406, an optimization processing module 407 and a test termination module 408. Wherein:
the test preparation module 401 is used for acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool;
a first testing module 402, configured to perform a first test on a to-be-tested function code based on the source test code set, to obtain a first test success set, which is used as a primary selection test code set;
a problem code generation module 403, configured to generate a corresponding problem code for the function code based on a preset problem code generation model;
a second testing module 404, configured to perform a second test on the problem code based on the initially selected test code set, and obtain a second test failure set as an optimal test code set;
a test validity algorithm module 405, configured to obtain the number of test code entries in the source test code set and the preferred test code set, respectively, and determine validity of the source test code set based on a preset test validity algorithm;
an optimization judgment module 406, configured to judge whether the validity can be optimized based on a preset optimization condition;
an optimization processing module 407, configured to replace the preferred test code set with the source test code set if optimization is possible;
and a test termination module 408, configured to send a test termination instruction to the preset monitoring interface and terminate the automated test program if the optimization is not possible.
Continuing to refer to fig. 5, which is a schematic structural diagram of a specific embodiment of the problem code generating module, the problem code generating module includes a model building sub-module 4031, a model processing sub-module 4032 and a problem code output sub-module 4033,
the model construction submodule 4031 is used to construct a problem code generation model in advance, where the problem code generation model includes: the system comprises a model input layer, a model processing layer and a model output layer;
the model processing submodule 4032 is used for acquiring the function codes input from the model input layer, taking the problem introduction conditions preset by the model processing layer as replacement conditions, and replacing the corresponding code positions in the function codes;
and the problem code output sub-module 4033 is used for outputting the replaced function code through the model output layer and taking the replaced function code as a problem code.
According to the test code optimization device based on the automatic test, a source test code set and a function code to be tested are obtained and input into a pre-constructed automatic test tool; generating corresponding problem codes for the function codes based on a preset problem code generation model; acquiring a primary selection test code set and a preferred test code set; determining the validity of a source test code set; judging whether the effectiveness can be optimized; if the optimization can be carried out, carrying out optimization; if the optimization cannot be carried out, stopping the automatic test program to pre-construct an automatic test tool; acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a first input layer; performing automatic test processing on the source test code set and the function code to be tested based on the test layer; the method comprises the steps that until preset output conditions are met, automatic test results are output based on a first output layer, positive and negative tests and automatic optimization are carried out by introducing a problem code generation model during automatic test processing, binary test effectiveness and output results are obtained, the workload of testers can be reduced through automatic tests, the effectiveness of test codes can be verified, automatic optimization is carried out, the optimized test codes have reasonable test ranges, and BUG can be found in time when a program has defects.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 6, fig. 6 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 6 comprises a memory 61, a processor 62, a network interface 63 communicatively connected to each other via a system bus. It is noted that only a computer device 6 having components 61-63 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user in a keyboard mode, a mouse mode, a remote controller mode, a touch panel mode or a voice control equipment mode.
The memory 61 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 6. Of course, the memory 61 may also comprise both an internal storage unit of the computer device 6 and an external storage device thereof. In this embodiment, the memory 61 is generally used for storing an operating system and various types of application software installed on the computer device 6, such as computer readable instructions of a test code optimization method based on an automated test. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is configured to execute computer readable instructions stored in the memory 61 or process data, such as computer readable instructions for executing the test code optimization method based on the automated test.
The network interface 63 may comprise a wireless network interface or a wired network interface, and the network interface 63 is typically used for establishing a communication connection between the computer device 6 and other electronic devices.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It should be understood that the above-described embodiments are merely exemplary of some, and not all, embodiments of the present application, and that the drawings illustrate preferred embodiments of the present application without limiting the scope of the claims appended hereto. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that modifications can be made to the embodiments described in the foregoing detailed description, or equivalents can be substituted for some of the features described therein. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A test code optimization method based on automatic test is characterized by comprising the following steps:
acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool;
based on the source test code set, performing a first test on the function code to be tested to obtain a first test success set which is used as a primary selection test code set;
generating corresponding problem codes for the function codes based on a preset problem code generation model;
performing a second test on the problem codes based on the initially selected test code set to obtain a second test failure set as an optimal test code set;
respectively acquiring the number of test code entries in a source test code set and a preferred test code set, and determining the effectiveness of the source test code set based on a preset test effectiveness algorithm;
judging whether the effectiveness can be optimized or not based on preset optimization conditions;
if the optimization can be carried out, replacing the preferred test code set with the source test code set;
and if the optimization cannot be carried out, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
2. The method of claim 1, wherein after the step of obtaining the first set of test successes as the initially selected set of test codes, the method further comprises:
and based on the test log and the test return value, acquiring a source test code entry used by the functional code when the test is successful, and adding the source test code entry as a set element into the first test success set.
3. The method according to claim 2, wherein after the step of obtaining, adding and constructing a first test success set as a set element, a source test code entry used by the function code when the test succeeds, the method further comprises:
identifying elements in the first test success set;
and if the first test success concentrated element is a null value, sending a test ending instruction to a preset monitoring interface and terminating the automatic test program.
4. The method for optimizing test codes based on automated testing according to claim 1, wherein the step of generating corresponding problem codes for the function codes based on a preset problem code generation model specifically comprises:
pre-constructing a problem code generation model, wherein the problem code generation model comprises: the system comprises a model input layer, a model processing layer and a model output layer;
acquiring a function code input from the model input layer, taking a problem introduction condition preset by the model processing layer as a replacement condition, and replacing a corresponding code position in the function code;
and outputting the replaced function code through the model output layer, and taking the function code as a problem code.
5. The method for optimizing test codes based on the automated test according to claim 1, wherein the step of determining the validity of the source test code set based on a preset test validity algorithm specifically comprises:
the preset test validity algorithm comprises the following steps:
Figure FDA0003749364440000021
determining validity of a source test code set, wherein Q 2 Representing the number, Q, of test code entries in a preferred test code set 1 The number of test code entries in the source test code set is indicated, and P indicates the validity of the source test code set.
6. The method for optimizing test codes based on the automated test according to claim 5, wherein the determining whether the validity can be optimized based on the preset optimization condition specifically includes:
if the test effectiveness is 0 or 100%, the test effectiveness cannot be optimized;
and if the test effectiveness is not 0 and not 100%, optimizing the test effectiveness.
7. The method for optimizing test code based on automated testing according to any one of claims 1 to 6, wherein after determining the validity of the source test code set, the method further comprises:
and when the preset monitoring interface is monitored to receive a test ending instruction, obtaining the test validity when the automatic test program is terminated and a source test code set corresponding to the test validity, and outputting the source test code set as an automatic test result.
8. A test code optimization device based on automated testing, comprising:
the test preparation module is used for acquiring a source test code set and a function code to be tested and inputting the source test code set and the function code to be tested into a pre-constructed automatic test tool;
the first testing module is used for carrying out first testing on the function codes to be tested based on the source testing code set to obtain a first testing success set which is used as a primary selection testing code set;
the problem code generation module is used for generating corresponding problem codes for the function codes based on a preset problem code generation model;
the second testing module is used for carrying out second testing on the problem codes based on the primarily selected testing code set to obtain a second testing failure set which is used as an optimal testing code set;
the test validity algorithm module is used for respectively acquiring the number of test code entries in the source test code set and the preferred test code set and determining the validity of the source test code set based on a preset test validity algorithm;
the optimization judging module is used for judging whether the effectiveness can be optimized or not based on preset optimization conditions;
the optimization processing module is used for replacing the preferred test code set with the source test code set if the optimization is available;
and the test termination module is used for sending a test termination instruction to the preset monitoring interface and terminating the automatic test program if the optimization cannot be performed.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor which when executed implements the steps of the automated test based test code optimization method of any one of claims 1 to 7.
10. A computer-readable storage medium having computer-readable instructions stored thereon which, when executed by a processor, implement the steps of the automated test-based test code optimization method of any one of claims 1 to 7.
CN202210837738.8A 2022-07-15 2022-07-15 Test code optimization method based on automatic test and related equipment thereof Pending CN115328764A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210837738.8A CN115328764A (en) 2022-07-15 2022-07-15 Test code optimization method based on automatic test and related equipment thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210837738.8A CN115328764A (en) 2022-07-15 2022-07-15 Test code optimization method based on automatic test and related equipment thereof

Publications (1)

Publication Number Publication Date
CN115328764A true CN115328764A (en) 2022-11-11

Family

ID=83917571

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210837738.8A Pending CN115328764A (en) 2022-07-15 2022-07-15 Test code optimization method based on automatic test and related equipment thereof

Country Status (1)

Country Link
CN (1) CN115328764A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115809622A (en) * 2023-01-19 2023-03-17 南京集成电路产业服务中心有限公司 Chip simulation acceleration system with automatic optimization configuration function

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115809622A (en) * 2023-01-19 2023-03-17 南京集成电路产业服务中心有限公司 Chip simulation acceleration system with automatic optimization configuration function

Similar Documents

Publication Publication Date Title
CN112052111B (en) Processing method, device and equipment for server abnormity early warning and storage medium
CN111400125A (en) Memory overflow monitoring method, device, equipment and storage medium of JAVA process
CN110764798A (en) Microcode upgrading method, device, computer equipment and storage medium
CN112631924A (en) Automatic testing method and device, computer equipment and storage medium
CN112631911A (en) Automatic testing method and device, computer equipment and storage medium
CN112394908A (en) Method and device for automatically generating embedded point page, computer equipment and storage medium
CN112506757A (en) Automatic test method, system, computer device and medium thereof
CN113986564A (en) Application data flow monitoring method and device, computer equipment and medium
CN110807050B (en) Performance analysis method, device, computer equipment and storage medium
CN113254445B (en) Real-time data storage method, device, computer equipment and storage medium
CN115328764A (en) Test code optimization method based on automatic test and related equipment thereof
CN112835808A (en) Interface testing method and device, computer equipment and storage medium
CN112860662A (en) Data blood relationship establishing method and device, computer equipment and storage medium
CN111475388A (en) Data push test method and device, computer equipment and storage medium
CN115757075A (en) Task abnormity detection method and device, computer equipment and storage medium
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN114281817A (en) Data cleaning method and device, computer equipment and storage medium
CN114615325A (en) Message pushing method and device, computer equipment and storage medium
CN112965721A (en) Android-based project compiling method and device, computer equipment and storage medium
CN110851346A (en) Method, device and equipment for detecting boundary problem of query statement and storage medium
CN111327513B (en) Message data pushing method and device, computer equipment and storage medium
CN115878460A (en) Regression testing method, device, computer equipment and storage medium
CN116302847B (en) Dynamic acquisition method and device of abnormal information, computer equipment and medium
CN109547290B (en) Cloud platform garbage data detection processing method, device, equipment and storage medium
CN117827661A (en) Code grammar checking method, system, computer device and storage medium

Legal Events

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