CN110309054B - Code validity testing method, computing device and storage medium - Google Patents
Code validity testing method, computing device and storage medium Download PDFInfo
- Publication number
- CN110309054B CN110309054B CN201910430120.8A CN201910430120A CN110309054B CN 110309054 B CN110309054 B CN 110309054B CN 201910430120 A CN201910430120 A CN 201910430120A CN 110309054 B CN110309054 B CN 110309054B
- Authority
- CN
- China
- Prior art keywords
- code
- validity test
- validity
- content
- frame
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Abstract
The invention is suitable for the technical field of computers, and provides a code validity testing method, a computing device and a storage medium, wherein the method comprises the following steps: and detecting whether the content matched with the validity test characteristics exists in the unit test UT code contained in the source code according to the validity test rule containing the validity test characteristics to obtain a validity test result. Therefore, the validity of the UT codes can be tested, in the code development process, a developer can obtain the validity test result and carry out corresponding code correction action according to the validity test result, so that the quality and the development efficiency of the software codes are ensured, the code validity test can be introduced as an important consideration factor in the software test, the developer is prompted to pay attention to the code validity, and a good development habit is formed.
Description
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a code validity testing method, computing equipment and a storage medium.
Background
In current software applications, after software is developed, software codes are generally required to be tested, and software testing is mainly used for analyzing software correctness and detecting software bugs. Unit Testing (UT) refers to detecting and verifying the smallest Unit of testability in software, which may be a module, a function, a class, or the like in software.
When software testing is performed, the execution integrity of the software is generally determined, and then the test work is evaluated according to the execution integrity, so that the software and the like are conveniently adjusted, and software codes are perfected on the basis. Code coverage is a consideration in software testing to describe the proportion or degree of code in software code that is tested. Code coverage is often used as an index to measure software testing capability and even to assess software testing task completion. The existing method mainly can test and collect the code coverage rate aiming at the code needing to be tested by using a code coverage rate statistical tool such as Jacoco and the like, and evaluates the completion condition of the test work based on the code coverage rate.
Statistical tools such as Jacoco, while able to test code coverage, are unable to test code validity, for example: whether valid assertion is written in the UT codes cannot be known, so that the quality of software codes cannot be guaranteed in the code development process, reference information for effectiveness evaluation cannot be provided for developers, the development efficiency cannot be guaranteed, the developers can be guided to pursue high code coverage rate and ignore code effectiveness, and good development habits cannot be developed.
Disclosure of Invention
The invention aims to provide a code validity testing method, a computing device and a storage medium, and aims to solve the problems in the prior art.
In one aspect, the present invention provides a code validity testing method, including:
and detecting whether the content matched with the validity test characteristics exists in the unit test UT code contained in the source code according to the validity test rule containing the validity test characteristics to obtain a validity test result.
Further, the validity test is characterized in that: the method includes the steps of asserting a keyword or an expression containing the assertion keyword, wherein the validity test rule further contains an UT code feature, and detecting whether content matched with the validity test feature exists in a unit test UT code contained in a source code according to the validity test rule containing the validity test feature, and specifically includes:
locating the UT code in the source code in accordance with the UT code characteristics;
determining whether content similar or identical to the validity test feature is present in the located UT code,
if the located UT code has the same content with the validity test characteristic, the validity test result correspondingly indicates that the UT code is written with valid assertion,
if the located UT code has content similar to but different from the validity test feature, or the UT code has neither content similar to but different from the validity test feature nor content identical to the validity test feature, the validity test result correspondingly indicates that the UT code has no valid assertion written therein.
Further, the UT code feature is a UT function key or an expression containing the UT function key.
Further, the validity test rule also comprises a code experience frame used for indicating the logic composition of the source code, the code experience frame comprises experience UT code position indication information,
according to the validity test rule containing the validity test feature, detecting whether the content matched with the validity test feature exists in the unit test UT code contained in the source code, and specifically, the method further comprises the following steps:
judging whether the code frame of the source code is matched with the code experience frame;
if the code frame of the source code is matched with the code experience frame, judging whether the validity test characteristics exist in the UT code corresponding to the position indicated by the experience UT code position indication information in the source code,
if the validity test feature exists in the UT code corresponding to the position indicated by the empirical UT code position indication information in the source code, the validity test result indicates that the UT code corresponding to the position indicated by the empirical UT code position indication information is written with a valid assertion.
Further, when the validity test feature does not exist in the UT code corresponding to the position indicated by the empirical UT code position indication information in the source code, the position indicated by the empirical UT code position indication information is prompted to prompt a developer to perform problem confirmation and/or code correction processing.
Further, the method further comprises:
when the content similar to but different from the validity test characteristics exists in the UT code, the content is positioned, and the validity test result comprises the positioning information of the content, or,
when the UT code has similar but different content than the validity test feature, the validity test result comprises: a situation in which the content is similar to the validity test feature indicates and/or a recommendation that the content be modified in accordance with the validity test feature, or,
when the UT code has content similar to but different from the validity test feature, the content is automatically modified according to the validity test feature, and the modification is prompted to a developer.
On the other hand, the invention also provides a code validity testing method, which comprises the following steps:
obtaining incremental content of a current version source code with a unit test UT code on a previous version source code and a previous validity test result of the previous version source code;
detecting whether the UT codes contained in the incremental content have the content matched with the validity test characteristics according to the validity test rule containing the validity test characteristics to obtain an incremental validity test result;
and combining the previous validity test result with the increment validity test result to obtain the current validity test result of the current version source code.
Further, the validity test rule also comprises a first code experience frame and a second code experience frame, wherein frame difference content exists between the first code experience frame and the second code experience frame, the frame difference content comprises experience UT code position indication information,
according to an effectiveness test rule containing an effectiveness test feature, detecting whether the UT codes contained in the incremental content have content matched with the effectiveness test feature, specifically including:
judging whether the frame of the current version source code is matched with the first code experience frame or not and whether the frame of the previous version source code is matched with the second code experience frame or not;
if the frame of the current version source code is matched with the first code experience frame and the frame of the previous version source code is matched with the second code experience frame, judging whether the validity test characteristics exist in the UT code corresponding to the position indicated by the experience UT code position indication information,
if the validity test feature exists in the UT code corresponding to the position indicated by the empirical UT code position indication information, when the previous validity test result indicates that the UT code of the previous version source code passes the validity test, the current validity test result indicates that the current version source code passes the validity test.
In another aspect, the present invention further provides a computing device, which includes a memory and a processor, and the processor implements the steps in the method when executing the computer program stored in the memory.
In another aspect, the present invention also provides a computer-readable storage medium, which stores a computer program, which when executed by a processor implements the steps in the method as described above.
The invention can detect whether the content matched with the validity test characteristics exists in the unit test UT code contained in the source code according to the validity test rule containing the validity test characteristics, and obtain the validity test result. Therefore, the validity of the UT codes can be tested, in the code development process, a developer can obtain the validity test result and carry out corresponding code correction action according to the validity test result, so that the quality and the development efficiency of the software codes are ensured, the code validity test can be introduced as an important consideration factor in the software test, the developer is prompted to pay attention to the code validity, and a good development habit is formed.
Drawings
FIG. 1 is a flowchart of an implementation of a code validity testing method according to a second embodiment of the present invention;
FIG. 2 is a schematic diagram of the logical composition of source code according to a third embodiment of the present invention;
FIG. 3 is a partial flowchart of a code validity testing method according to a third embodiment of the present invention;
FIG. 4 is a partial flowchart of a code validity testing method according to a fourth embodiment of the present invention;
FIG. 5 is a flowchart of an implementation of a code validity testing method according to a fifth embodiment of the present invention;
FIG. 6 is a partial flowchart of a code validity testing method according to a sixth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a computing device according to a seventh embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention 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 invention and are not intended to limit the invention.
The following detailed description of specific implementations of the present invention is provided in conjunction with specific embodiments:
software testing is key to ensuring software quality. Typically, the time spent by software testing accounts for roughly more than 40% of the entire software project lifecycle. The UT is tested by testing the smallest testable unit (e.g., a class, a function, or a module) in the software, i.e., the unit tests, to verify the correctness of the software or whether the customer's requirements are met. The method for testing the validity of the code provided by the embodiment of the application mainly judges whether the UT code included in the source code to be tested includes validity test characteristics, and particularly detects whether the UT code includes valid assertion under the condition that the current UT code needs an assertion function, so that the purpose of testing the validity of the code is achieved.
The first embodiment is as follows:
the embodiment provides a code validity testing method, which mainly comprises the following steps:
and traversing the source code with the UT code according to an effectiveness test rule containing the effectiveness test characteristic to judge whether the UT code has the content matched with the effectiveness test characteristic, so as to obtain an effectiveness test result.
In this embodiment, an validity test rule may be established in advance, and the validity of the source code to be tested may be tested using the validity test rule.
The source code is a code file written by a developer in a language supported by a development tool, and a series of computer language instructions are formed by corresponding characters, symbols, signal elements or the like. The source code is generally used to implement a complete system function, and the smallest testable unit such as a class, a module, or a function constituting the source code implements a basic function constituting the system function. To verify the correctness of the minimum testable unit, i.e., whether the minimum testable unit base function can be accurately expressed, UT code is typically loaded in the source code for this purpose. The UT code will typically necessarily contain assertion functionality and will also typically contain test cases. Whether valid assertions are included, whether test cases cover common input combinations or boundary conditions, and the like are generally used as test standards for code validity. Among other things, whether a valid assertion is included as an important test criterion for code validity.
For validity testing on the assertion, the validity testing feature may be an assertion key or an expression containing the assertion key, and if no assertion key or no expression containing the assertion key exists in the UT code, the UT code may be considered to fail the validity testing without writing a valid assertion. The situation where no assertion key exists in the UT code or an expression containing the assertion key may specifically be: the contents which are neither similar to nor different from the assertion keywords or the expressions containing the assertion keywords exist in the UT codes, namely, the contents which are similar to or the same as the assertion keywords do not exist in the UT codes completely; alternatively, there may be something in the UT code that is similar but not identical to the assertion key or the expression containing the assertion key, such as: asserting the key as "assert", while there is a similar but not identical content "assert" in the UT code; the expression containing the assertion key is "assertTrue ()", and there is something similar to but not identical to "assertTrue ()" in the UT code.
For validity testing for a test case, the validity testing feature may also be a test case experience data set, the test case experience data set including: different use case experience data with relative attributes, such as: under one test scenario, the test case experience dataset includes: the first example experience data is '1', the second example experience data is '0', and the '1' and the '0' are used as different inputs of the UT codes to carry out validity test on the UT codes; or, in another test scenario, the test case experience data set includes: the first example empirical data is "1", the second example empirical data is "-1", the third example empirical data is "0", the fourth example empirical data is "none", and the UT codes are tested for validity with "1", "0", and "none" as different inputs of the UT codes. The number, the type and the like of the case experience data in the test case experience data set can be set according to actual needs, but all the requirements are as follows: for a UT code, all use case experience data in the use case experience data set can meet the requirement that a test use case covers common input combination as much as possible. By using a preset or real-time generated test case experience data set, whether all case experience data in the UT codes can meet the common input combination requirements covered by the test cases as much as possible can be judged, for example: if the use case experience data existing in the UT code are "-1" and "1", and the UT code is supposed to still exist but has no other use case experience data "none", the use case experience data in the test use case experience data set in the UT code is incomplete, and the UT code can be considered to fail the validity test. Whether the test case covers the common boundary condition or not can be judged through similar situations, and whether the UT codes can pass the validity test or not is finally judged.
The mode of traversing the source code can firstly read the source code directory through the configured source code path, and then traverse all the codes line by line according to the source code directory or carry out the validity test of the UT codes in a targeted manner by positioning the UT codes in the source codes.
The implementation of the code validity testing method of the embodiment can realize testing of the validity of the UT code, and particularly can relate to testing of whether valid assertions are written in the UT code or not, whether a test case in the UT code covers a common input combination or boundary conditions and the like, so that a developer can obtain a validity testing result in a code development process and perform corresponding code correction actions according to the validity testing result, so that the quality and the development efficiency of the software code are ensured, and the code validity testing can be introduced as an important consideration factor in the software testing, so that the developer is prompted to pay attention to the code validity, and a good development habit is developed.
Example two:
in the code validity testing method provided in this embodiment, the validity testing rule further includes a UT code feature, where the UT code feature may be a UT function keyword, or an expression including the UT function keyword, or a classic UT operation code segment, and the like, for example: the UT code characteristics may be "unittest", "import unittest", and the like.
The code validity testing method of the embodiment mainly includes the flow shown in fig. 1:
and S101, positioning the UT codes in the source codes according to the UT code characteristics.
In this embodiment, when the source code has the corresponding UT code feature, one or some UT codes may be quickly located in the source code according to the UT code feature.
Step S102, judging whether the positioned UT codes have contents similar to or the same as validity test characteristics, and when the UT codes have contents the same as the validity test characteristics (assertion keywords, expressions containing the assertion keywords and the like), indicating that the UT codes are written with valid assertions by using validity test results; the validity test result indicates that the UT code is not written with a valid assertion when there is content in the UT code that is similar to but different from the validity test feature, or there is neither content in the UT code that is similar to but different from the validity test feature, nor content that is the same as the validity test feature. In the specific judgment, a character comparison mode can be adopted.
The validity test result may indicate whether the located UT code passes the validity test, and may also indicate a specific reason whether the located UT code passes the validity test, for example: whether a valid assertion is written, etc.
By implementing the code validity testing method of the embodiment, the UT codes in the source codes can be quickly positioned, so that the validity of the UT codes is quickly tested, and the efficiency of validity testing is improved.
Example three:
the present embodiment further provides the following contents on the basis of the above embodiments:
in the code validity testing method provided by this embodiment, the validity testing rule further includes a code experience framework for indicating the source code logic composition, and the code experience framework includes experience UT code position indication information. The logical composition of the source code may include: the basic code for realizing the system function and the UT code are original. In an actual software development process, a developer writes software codes according to a certain code writing logic, so that the written source codes have a certain logic composition rule, as shown in fig. 2, the source codes include a basic code 201 for implementing a system function, and a UT code 202, where the basic code 201 further includes a first partial code 2011 and a second partial code 2012, the first partial code 2011 and the second partial code 2012 are both minimum testable units and both include basic code features (e.g., corresponding function code keywords), and the UT code 202 is placed behind the basic code 201 and used for executing UT on the first partial code 2011 and the second partial code 2012. If a code experience frame comprises a three-section structure, the first two sections comprise corresponding basic code characteristics, and the last section comprises experience UT code position indication information to indicate that the UT codes should appear in the last section, when the code frame of the source codes to be tested is matched with the code experience frame, the position, indicated by the experience UT code position indication information, where the UT codes should exist can be quickly located in the source codes to be tested, so that validity test is carried out on the UT codes at the position. The location indicated by the empirical UT code location indication information can be a start location, an end location, an intermediate location of the UT code, or a location covered by a portion of the code in the UT code, etc., as may exist. When the empirical UT code location indication information correspondingly indicates that no UT code exists at the location in the source code, proximity finding may be performed, and it is also possible to achieve fast location of the UT code. The code experience frame can be obtained directly through a plurality of source code frame samples or obtained through deep learning method training a plurality of source code frame samples. In addition, the amount of code covered by each segment in the code experience framework can be flexibly changed, so that the code experience framework can be suitable for source codes with different code amounts.
It can be understood that the empirical UT code position indication information indicates a position where the UT code should exist in a code empirical framework, the code empirical framework is equivalent to a structural composition logic that can indicate a base code and the UT code, the code empirical framework itself is also a set of position information, and by using the position information, it can be determined whether or not the code framework of the source code matches with the code empirical framework, and even the degree of matching.
Then, according to the validity test rule including the validity test feature, detecting whether there is content matching the validity test feature in the UT code included in the source code, which specifically includes the flow shown in fig. 3:
step S301, judging whether the code frame of the source code is matched with the code experience frame, if so, executing step 302, otherwise, traversing the source code to locate the corresponding UT code so as to carry out validity test of the UT code in the source code.
In this embodiment, the code frame of the source code may be automatically generated in advance according to the characteristics of the basic code when the code is written.
Step S302, determining whether validity test features exist in the UT codes corresponding to the position indicated by the empirical UT code position indication information in the source code, if yes, the validity test result indicates that the UT codes corresponding to the position indicated by the empirical UT code position indication information write valid assertions, otherwise, the validity test result indicates that the UT codes corresponding to the position indicated by the empirical UT code position indication information do not write valid assertions.
By implementing the code validity testing method of the embodiment, not only can the UT codes in the source codes be quickly positioned, but also an ordered logic composition structure of the source codes can be constructed, and positioning, searching, correction and other processing in the code development process are facilitated.
Example four:
on the basis of the third embodiment, the present embodiment further provides the following contents:
as shown in fig. 4, the code validity testing method of this embodiment further includes:
in step S401, when there is no validity test feature in the UT code corresponding to the position indicated by the empirical UT code position indication information in the source code, the validity test result indicates that the UT code corresponding to the position indicated by the empirical UT code position indication information has no valid assertion written therein, and the position indicated by the empirical UT code position indication information is prompted.
By implementing the code validity testing method of the embodiment, when the validity testing feature does not appear at the position where the validity testing feature should exist, it is indicated that the UT code validity test at the position cannot pass, that is, the position indicated by the UT code position indication information can be experienced to prompt a developer to quickly locate the position and to perform problem confirmation and/or code correction processing in a targeted manner.
Example five:
the embodiment provides a code validity testing method, which mainly includes the following steps as shown in fig. 5:
step S501, obtaining the increment content of the current version source code of the UT code on the previous version source code and the previous validity test result of the previous version source code.
Step S502, according to the validity test rule containing the validity test characteristics, whether the UT codes contained in the incremental content have the content matched with the validity test characteristics is detected, and the incremental validity test result is obtained.
And S503, combining the previous validity test result with the increment validity test result to obtain the current validity test result of the current version source code.
In this embodiment, UT code location for incremental content may be performed in a manner traversing the incremental content or as illustrated in embodiments two and three. The previous validity test result and the incremental validity test result may be described according to relevant contents in the above embodiments.
According to a preset combination strategy of validity test results, combining a previous validity test result corresponding to a previous version source code with an increment validity test result corresponding to increment content to obtain a current validity test result of a current version source code, for example: if the current validity test result is that the validity test is passed, and the incremental validity test result is that the validity test is not passed, the current validity test result is that the validity test is not passed, and can indicate that the validity problem exists in the incremental content, and further can position the position and/or reason of the validity problem, etc.; and if the current validity test result is that the validity test passes, and the incremental validity test result is that the validity test passes, the current validity test result is that the validity test passes.
By implementing the code validity testing method of the embodiment, not only can the correspondingly realized effect of the embodiment be realized, but also the validity test can be simplified for the source code of the current version updated by the increment, and the overall operation efficiency is further improved.
Example six:
in this embodiment, on the basis of the fifth embodiment, the following contents are further added:
in the code validity testing method of this embodiment, the validity testing rule further includes a first code experience framework and a second code experience framework, where there is framework difference content between the first code experience framework and the second code experience framework, and the framework difference content includes experience UT code position indication information. The code experience framework and framework difference content is similar to the "code experience framework" section described in example three.
Correspondingly, step S502 specifically includes the flow shown in fig. 6:
step S601, determining whether the frame of the current version source code matches with the first code experience frame and whether the frame of the previous version source code matches with the second code experience frame, if yes, performing step S602, otherwise, traversing the incremental content to locate the corresponding UT code, so as to perform the validity test of the UT code in the incremental content.
Step S602, determining whether validity test features exist in the UT code corresponding to the position indicated by the empirical UT code position indication information, if yes, when the current validity test result indicates that the UT code of the previous version source code passes the validity test in step S503, the current validity test result indicates that the current version source code passes the validity test, otherwise, when the previous validity test result indicates that the UT code of the previous version source code passes the validity test, the current validity test result indicates that the current version source code fails the validity test.
In the embodiment, the contents of steps S601 and S602 may be similar to the related contents in the third embodiment, and are not described herein again.
Alternative schemes in other application examples:
1. the frame of the UT code is a juit frame, a JUnitX frame, a TestNG frame, or a NUnit frame, etc., and the corresponding validity test characteristics may be changed accordingly, for example: under the JUnit framework, the assertion keyword is 'assertesquares'; under the NUnit framework, the assertion key is "alert.
2. And generating a test report for guiding a developer to carry out code repair according to the effectiveness test result.
3. When the UT code has content similar to but different from the validity test feature, the content can also be located, and the validity test result can also include location information of the content. Thus, the UT code validity test that indicates the location may not pass, i.e., the location may be prompted to guide the developer to quickly locate the location and may be directed to problem validation and/or code revision processing.
4. When the UT code has similar but different content from the validity test feature, the validity test result may further include: a description of a situation in which the content approximates the validation test feature, and/or a suggestion that the content be modified in accordance with the validation test feature. Alternatively, the content is automatically modified based on the validity test features and the developer is prompted for the modification.
Example seven:
fig. 7 shows a structure of a computing device according to a seventh embodiment of the present invention, and for convenience of description, only a part related to the embodiment of the present invention is shown.
The computing device according to the embodiment of the present invention includes a processor 701 and a memory 702, and when the processor 701 executes the computer program 703 stored in the memory 702, the steps in the above-described method embodiments, such as the steps S101 to S102 shown in fig. 1, are implemented.
The computing device of the embodiment of the invention can be a personal computer or a network of computers. When the processor 701 in the computing device executes the computer program 703, the steps implemented when the methods are implemented may refer to the description of the foregoing method embodiments, and are not described herein again.
Example eight:
in an embodiment of the present invention, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps in the above-described method embodiments, for example, steps S101 to S102 shown in fig. 1.
The implementations shown in fig. 7 are implemented by hardware components, devices, units, modules, means, and other components of the operations described herein with respect to fig. 1-6. Examples of hardware components include controllers, sensors, generators, drivers, memories, comparators, arithmetic logic units, adders, subtractors, multipliers, dividers, integrators, processors, and any other electronic component known to one of ordinary skill in the art that is configured to perform the operations described herein. In one example, the hardware components are implemented by one or more processors or computers. A processor or computer is implemented by one or more processing elements such as an array of logic gates, a controller and arithmetic logic unit, a digital signal processor, a microcomputer, a programmable logic controller, a field programmable gate array, a programmable logic array, a microprocessor, or any other device or combination of devices known to those of ordinary skill in the art that is capable of responding to and executing instructions in a defined manner to achieve a desired result.
In one example, a processor or computer includes or is connected to one or more memories that store instructions or software for execution by the processor or computer. Instructions or software (such as an operating system, OS, and one or more software applications running on the OS) are executed by a processor or computer-implemented hardware component to perform the operations described herein with respect to fig. 1-6. The hardware components also access, manipulate, process, create, and store data in response to execution of instructions or software. For simplicity, the singular terms "processor" or "computer" may be used in the description of the examples described herein, but in other examples, multiple processors or computers are used, or a processor or computer includes multiple processing elements or multiple types of processing elements, or both. In one example, the hardware component includes a plurality of processors, and in another example, the hardware component includes a processor and a controller. Examples of hardware components having any one or more of a variety of different processing configurations include single processors, independent processors, parallel processors, single instruction single data SISD multiprocessing, single instruction multiple data SIMD multiprocessing, multiple instruction single data MISD multiprocessing, and multiple instruction multiple data MIMD multiprocessing.
The methods illustrated in fig. 1-6 for performing the operations described in this application are performed by computing hardware (e.g., by one or more processors or computers) implemented as executing instructions or software to perform the operations described in this application for performing the methods described in this application as described above. For example, a single operation or two or more operations may be performed by a single processor, or two or more processors, or a processor and a controller. One or more operations may be performed by one or more processors, or a processor and a controller, and one or more other operations may be performed by one or more other processors, or another processor and another controller. One or more processors, or a processor and a controller, may perform a single operation or two or more operations. Instructions or software for controlling a processor or computer-implemented hardware component and performing a method as described above may be written as a computer program, code segments, instructions, or any combination thereof, to individually or collectively instruct or configure the processor or computer to operate as a machine or special purpose computer for performing the operations performed by the hardware component and the method as described above. In one example, the instructions or software include machine code that is executed directly by a processor or computer, such as machine code produced by a compiler. In another example, the instructions or software include higher level code that is executed by a processor or computer using an interpreter. A person of ordinary skill in the art can easily write instructions or software based on the block diagrams and flowcharts shown in the figures and the corresponding description in the specification, which disclose algorithms for performing operations performed by hardware components and methods as described above.
The instructions or software and any associated data, data files, and data structures used to control the processor or computer-implemented hardware components and perform the methods described above may be recorded, stored, or fixed in or on one or more non-transitory computer-readable storage media. Examples of non-transitory computer-readable storage media include: read-only memory ROM, random-access memory RAM, flash memory, CD-ROM, CD-R, CD + R, CD-RW, CD + RW, DVD-ROM, DVD-R, DVD + R, DVD-RW, DVD + RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, magnetic tape, floppy disk, magneto-optical data storage device, hard disk, solid-state disk, and any device known to those of ordinary skill in the art that is capable of storing instructions or software and any associated data, data files, and data structures in a non-transitory manner and providing instructions or software and any associated data, data files, and data structures to a processor or computer so that the processor or computer can execute the instructions. In one example, the instructions or software and any associated data, data files, and data structures are distributed across networked computer systems such that the instructions and software and any associated data, data files, and data structures are stored, accessed, and executed by a processor or computer in a distributed fashion.
While the present disclosure includes specific examples, it will be apparent to those of ordinary skill in the art, after having had a full understanding of the disclosure of the subject application, that: various changes in form and detail may be made to these examples without departing from the spirit and scope of the claims and their equivalents. The examples described herein are to be considered in a descriptive sense only and not for purposes of limitation. The description of features or aspects in each example will be considered applicable to similar features or aspects in other examples. Suitable results may be achieved if the described techniques are performed in a different order and/or if components in the described systems, architectures, devices, or circuits are combined in a different manner and/or replaced or supplemented by other components or their equivalents. Therefore, the scope of the present disclosure is defined not by the detailed description but by the claims and their equivalents, and all changes within the scope of the claims and their equivalents are to be construed as being included in the present disclosure.
Claims (8)
1. A method for testing code validity, comprising:
detecting whether the content matched with the validity test characteristics exists in a unit test UT code contained in a source code according to the validity test rule containing the validity test characteristics to obtain a validity test result; the validity test rule also comprises a code experience frame used for indicating the source code logic composition, the code experience frame comprises experience UT code position indication information,
the detecting, according to the validity test rule including the validity test feature, whether content matching the validity test feature exists in the unit test UT code included in the source code specifically includes:
judging whether the code frame of the source code is matched with the code experience frame;
if the code frame of the source code is matched with the code experience frame, judging whether the validity test characteristics exist in the UT code corresponding to the position indicated by the experience UT code position indication information in the source code;
if the validity test feature exists in the UT code corresponding to the position indicated by the empirical UT code position indication information in the source code, the validity test result indicates that the UT code corresponding to the position indicated by the empirical UT code position indication information is written with a valid assertion.
2. The method of claim 1, wherein the validity test feature is: the method includes the steps of asserting a keyword or an expression containing the assertion keyword, wherein the validity test rule further contains an UT code feature, and detecting whether content matched with the validity test feature exists in a unit test UT code contained in a source code according to the validity test rule containing the validity test feature, and specifically includes:
locating the UT code in the source code in accordance with the UT code characteristics;
determining whether content similar or identical to the validity test feature is present in the located UT code,
if the located UT code has the same content with the validity test characteristic, the validity test result correspondingly indicates that the UT code is written with valid assertion,
if the located UT code has content similar to but different from the validity test feature, or the UT code has neither content similar to but different from the validity test feature nor content identical to the validity test feature, the validity test result correspondingly indicates that the UT code has no valid assertion written therein.
3. The method of claim 2, wherein the UT code characteristics are UT function keys or expressions that contain UT function keys.
4. The method of claim 1, wherein when the validity test features are not present in the UT code corresponding to the location indicated by the empirical UT code location indication information in the source code, then prompting the location indicated by the empirical UT code location indication information to prompt a developer to perform problem validation and/or code modification processing.
5. The method of claim 2, wherein the method further comprises:
when the content similar to but different from the validity test characteristics exists in the UT code, the content is positioned, and the validity test result comprises the positioning information of the content, or,
when the UT code has similar but different content than the validity test feature, the validity test result comprises: a situation in which the content is similar to the validity test feature indicates and/or a recommendation that the content be modified in accordance with the validity test feature, or,
when the UT code has content similar to but different from the validity test feature, the content is automatically modified according to the validity test feature, and the modification is prompted to a developer.
6. A method for testing code validity, comprising:
obtaining incremental content of a current version source code with a unit test UT code on a previous version source code and a previous validity test result of the previous version source code;
detecting whether the UT codes contained in the incremental content have the content matched with the validity test characteristics according to the validity test rule containing the validity test characteristics to obtain an incremental validity test result; the validity test rule also comprises a first code experience frame and a second code experience frame, wherein frame difference content exists between the first code experience frame and the second code experience frame, and the frame difference content comprises experience UT code position indication information;
combining the previous validity test result with the increment validity test result to obtain a current validity test result of the current version source code;
wherein, the detecting whether the UT code included in the incremental content has the content matched with the validity test feature according to the validity test rule including the validity test feature specifically includes:
judging whether the frame of the current version source code is matched with the first code experience frame or not and whether the frame of the previous version source code is matched with the second code experience frame or not;
if the frame of the current version source code is matched with the first code experience frame and the frame of the previous version source code is matched with the second code experience frame, judging whether the validity test characteristics exist in the UT code corresponding to the position indicated by the experience UT code position indication information,
if the validity test feature exists in the UT code corresponding to the position indicated by the empirical UT code position indication information, when the previous validity test result indicates that the UT code of the previous version source code passes the validity test, the current validity test result indicates that the current version source code passes the validity test.
7. A computing device comprising a memory and a processor, wherein the processor implements the steps of the method of any one of claims 1 to 6 when executing a computer program stored in the memory.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910430120.8A CN110309054B (en) | 2019-05-22 | 2019-05-22 | Code validity testing method, computing device and storage medium |
PCT/CN2019/103760 WO2020232906A1 (en) | 2019-05-22 | 2019-08-30 | Code validity test method, computing device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910430120.8A CN110309054B (en) | 2019-05-22 | 2019-05-22 | Code validity testing method, computing device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110309054A CN110309054A (en) | 2019-10-08 |
CN110309054B true CN110309054B (en) | 2021-08-31 |
Family
ID=68074814
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910430120.8A Active CN110309054B (en) | 2019-05-22 | 2019-05-22 | Code validity testing method, computing device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110309054B (en) |
WO (1) | WO2020232906A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114546816B (en) * | 2020-11-25 | 2024-07-16 | 腾讯科技(深圳)有限公司 | Test method, platform, device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102147764A (en) * | 2010-02-08 | 2011-08-10 | 微软公司 | Test code qualitative evaluation |
CN103164335A (en) * | 2011-12-19 | 2013-06-19 | 阿里巴巴集团控股有限公司 | Method and system for detecting unit test quality |
CN106326122A (en) * | 2016-08-23 | 2017-01-11 | 北京精密机电控制设备研究所 | Software unit test case management system |
CN108197036A (en) * | 2018-02-06 | 2018-06-22 | 百度在线网络技术(北京)有限公司 | For determining the method and apparatus of the coverage rate information of incremental code |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150370685A1 (en) * | 2014-06-24 | 2015-12-24 | Juergen Heymann | Defect localization in software integration tests |
CN105512021A (en) * | 2014-09-25 | 2016-04-20 | 阿里巴巴集团控股有限公司 | Method and device for Diff analysis used for software testing |
US10282282B2 (en) * | 2016-06-29 | 2019-05-07 | Synopsys, Inc. | Automated HTTP user flows simulator |
-
2019
- 2019-05-22 CN CN201910430120.8A patent/CN110309054B/en active Active
- 2019-08-30 WO PCT/CN2019/103760 patent/WO2020232906A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102147764A (en) * | 2010-02-08 | 2011-08-10 | 微软公司 | Test code qualitative evaluation |
CN103164335A (en) * | 2011-12-19 | 2013-06-19 | 阿里巴巴集团控股有限公司 | Method and system for detecting unit test quality |
CN106326122A (en) * | 2016-08-23 | 2017-01-11 | 北京精密机电控制设备研究所 | Software unit test case management system |
CN108197036A (en) * | 2018-02-06 | 2018-06-22 | 百度在线网络技术(北京)有限公司 | For determining the method and apparatus of the coverage rate information of incremental code |
Non-Patent Citations (1)
Title |
---|
嵌入式系统下如何提高单元测试有效性的分析研究;陈娟;《电脑知识与技术》;20131231;第9卷(第35期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110309054A (en) | 2019-10-08 |
WO2020232906A1 (en) | 2020-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9898387B2 (en) | Development tools for logging and analyzing software bugs | |
Zhang et al. | Capturing propagation of infected program states | |
Elberzhager et al. | Reducing test effort: A systematic mapping study on existing approaches | |
EP3285171B1 (en) | System and method for cause point analysis for effective handling of static analysis alarms | |
US10789155B2 (en) | Coverage test support device and coverage test support method | |
US9658907B2 (en) | Development tools for refactoring computer code | |
US8397104B2 (en) | Creation of test plans | |
CN111104335B (en) | C language defect detection method and device based on multi-level analysis | |
US10169214B2 (en) | Testing of combined code changesets in a software product | |
US9032339B2 (en) | Ranking verification results for root cause analysis | |
JP6342129B2 (en) | Source code error position detection apparatus and method for mixed mode program | |
US8180780B2 (en) | Collaborative program development method and system | |
US20110145799A1 (en) | Path-sensitive dataflow analysis including path refinement | |
US9910487B1 (en) | Methods, systems and computer program products for guiding users through task flow paths | |
US20120173498A1 (en) | Verifying Correctness of a Database System | |
US8850407B2 (en) | Test script generation | |
US20210318946A1 (en) | Generation of code coverage information during testing of a code sequence | |
CN110309054B (en) | Code validity testing method, computing device and storage medium | |
US9152536B1 (en) | Validating correctness of expression evaluation within a debugger | |
US8739091B1 (en) | Techniques for segmenting of hardware trace and verification of individual trace segments | |
CN108763092B (en) | Code defect detection method and device based on cross validation | |
US7533314B2 (en) | Unit test extender | |
Malburg et al. | Tuning dynamic data flow analysis to support design understanding | |
US8010477B2 (en) | Integrated problem solving system | |
KR102671056B1 (en) | Method, apparatus and program for managing RPA bot for robotic process automation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |