[go: up one dir, main page]

CN116204445A - Test case generation method, device, code testing method, equipment and medium - Google Patents

Test case generation method, device, code testing method, equipment and medium Download PDF

Info

Publication number
CN116204445A
CN116204445A CN202310473155.6A CN202310473155A CN116204445A CN 116204445 A CN116204445 A CN 116204445A CN 202310473155 A CN202310473155 A CN 202310473155A CN 116204445 A CN116204445 A CN 116204445A
Authority
CN
China
Prior art keywords
node
population
test case
code
weight value
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.)
Granted
Application number
CN202310473155.6A
Other languages
Chinese (zh)
Other versions
CN116204445B (en
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202310473155.6A priority Critical patent/CN116204445B/en
Publication of CN116204445A publication Critical patent/CN116204445A/en
Application granted granted Critical
Publication of CN116204445B publication Critical patent/CN116204445B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • 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/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/12Computing arrangements based on biological models using genetic models
    • G06N3/126Evolutionary algorithms, e.g. genetic algorithms or genetic programming
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Biophysics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Computational Linguistics (AREA)
  • Genetics & Genomics (AREA)
  • Artificial Intelligence (AREA)
  • Biomedical Technology (AREA)
  • Physiology (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention relates to the field of software testing, and in particular, to a test case generating method, a device, a code testing method, a device, and a medium. The test case generation method comprises the following steps: the combination logic is used as a target condition to cover test points and a condition tree is generated by using a preset rule; constructing a population of genetic algorithm with each individual as an initial test case; node interception is carried out on the condition tree to obtain effective nodes and an initial weight value is given; taking individuals of the population as input of codes to be tested and running the codes to be tested on a verification platform; updating the weight value of the effective node according to the coverage times and the initial weight value of the effective node collected from the verification platform; calculating the fitness of individuals in the population according to the updated weight value and the coverage state of the effective nodes collected from the verification platform; and adjusting individuals of the population based on the fitness until a preset output condition is met, and outputting. The scheme of the invention greatly reduces the number of redundant test cases, improves the convergence rate and improves the test efficiency.

Description

测试用例生成方法、装置、代码测试方法、设备及介质Test case generation method, device, code test method, equipment and medium

技术领域technical field

本发明涉及软件测试领域,尤其涉及一种测试用例生成方法、装置、代码测试方法、设备及介质。The invention relates to the field of software testing, in particular to a test case generation method, device, code testing method, equipment and media.

背景技术Background technique

代码覆盖率是一种通过计算测试过程中被执行的源代码占全部源代码的比例,进而间接度量软件质量的方法。它在保证测试质量的时候潜在保证实际产品的质量,可以基于此在程序中寻找没有被测试用例测试过的地方,进一步创建新的测试用例来增加覆盖率。理想状态下代码覆盖测试预期达到百分之百的覆盖率,但这通常是难以达到的,尤其对于代码量大、逻辑复杂的大型工程,条件、路径等覆盖率甚至难以达到百分之九十,而对于十分苛刻的触发条件,常规随机测试运行数小时、甚至数天都无法覆盖对应测试点。Code coverage is a method to indirectly measure software quality by calculating the proportion of the source code executed during the test to the total source code. It potentially guarantees the quality of the actual product while ensuring the quality of the test. Based on this, it can find places in the program that have not been tested by the test case, and further create new test cases to increase the coverage. Ideally, the code coverage test is expected to achieve a 100% coverage rate, but this is usually difficult to achieve, especially for large-scale projects with a large amount of code and complex logic, the coverage rate of conditions, paths, etc. is even difficult to reach 90%. Very harsh trigger conditions, conventional random tests run for hours, or even days, cannot cover the corresponding test points.

为了降低代码测试周期、提高代码覆盖率、降低对代码测试人员的技术要求,目前业界引入智能搜索算法来自动化生成代码覆盖测试用例。然而,目前业界常用的测试用例生成方法基于随机算法或约束随机算法,这种开环方法没有基于代码状态对测试用例生成策略进行调整,继而生成大量冗余测试用例,导致测试效率低下,因而亟需改进。In order to reduce the code testing cycle, improve code coverage, and reduce the technical requirements for code testers, the industry currently introduces intelligent search algorithms to automatically generate code coverage test cases. However, the commonly used test case generation method in the industry is based on random algorithm or constrained random algorithm. This open-loop method does not adjust the test case generation strategy based on the code state, and then generates a large number of redundant test cases, resulting in low test efficiency. Therefore, it is urgent needs improvement.

发明内容Contents of the invention

有鉴于此,有必要针对以上技术问题,提供一种测试用例生成方法、装置、代码测试方法、设备及介质。In view of this, it is necessary to provide a test case generation method, device, code testing method, equipment and medium for the above technical problems.

根据本发明的第一方面,提供了一种测试用例生成方法,所述测试用例生成方法包括:According to a first aspect of the present invention, a method for generating a test case is provided, the method for generating a test case includes:

对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Analyzing the code to be tested to use combinational logic as a target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point;

构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;Construct a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Performing node interception on the conditional tree to obtain valid nodes, and assigning initial weight values to the valid nodes;

将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform;

根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The individuals of the population are adjusted based on the fitness until the preset output conditions are met, and the adjusted test cases are output.

在一些实施例中,所述预设规则包括以下至少一种:In some embodiments, the preset rules include at least one of the following:

将所述目标条件覆盖测试点对应的组合逻辑作为根节点;Taking the combined logic corresponding to the target condition coverage test point as the root node;

基于预设子项分割规则处理组合逻辑,将组合逻辑本身作为父节点、将父节点组合逻辑的子项作为子节点;Processing the combination logic based on the preset sub-item segmentation rules, using the combination logic itself as a parent node, and using the child items of the combination logic of the parent node as child nodes;

对于分支条件,将引起本节点变量变化的分支列为子节点;For branch conditions, the branch that causes the variable change of this node is listed as a child node;

当节点为代码输入参数、代码不可见组件的输出或节点变量的值变化与其他变量均不存在逻辑关系时,则节点为叶节点不再分解;When the node is a code input parameter, the output of a code invisible component, or the value change of a node variable has no logical relationship with other variables, the node is a leaf node and will not be decomposed;

将每个节点到达根节点所经过的最少节点数作为节点的层号。The minimum number of nodes passed by each node to reach the root node is taken as the layer number of the node.

在一些实施例中,所述预设子项分割规则包括以下至少一种:In some embodiments, the preset subitem segmentation rules include at least one of the following:

分割规则一、对逻辑运算符进行转换以得到仅包括与关系、或关系的组合逻辑;Segmentation rule 1. Convert logical operators to obtain combinational logic including only AND relation or OR relation;

分割规则二、将与关系、或关系的优先级设定为遵循所述待测试代码的设计语言规则;Segmentation rule 2, setting the priority of the AND relationship, or the relationship, to follow the design language rules of the code to be tested;

分割规则三、子项间仅存在单一形式逻辑关系,每个子项对应一个子节点;Segmentation rule 3. There is only a single form of logical relationship between sub-items, and each sub-item corresponds to a sub-node;

分割规则四、进行子项分解前需要根据逻辑运算规则对组合逻辑进行化简以保证每项内不包含逻辑运算符;Segmentation rule 4. Before decomposing sub-items, it is necessary to simplify the combination logic according to the logical operation rules to ensure that each item does not contain logical operators;

分割规则五、对于根节点逻辑关系式经过分割规则一、分割规则二、分割规则四转换后将或关系均改为与关系;Segmentation rule 5. For the logical relationship of the root node, after conversion by segmentation rule 1, segmentation rule 2, and segmentation rule 4, the OR relationship is changed to an AND relationship;

分割规则六、若化简后的逻辑关系式中既含有或关系又含有与关系,则先分解出低优先级逻辑关系的子节点,再从产生的子节点中分解出高优先级的子节点。Segmentation rule 6. If the simplified logical relation contains both an OR relation and an AND relation, first decompose the sub-nodes of the low-priority logical relation, and then decompose the high-priority sub-nodes from the generated sub-nodes .

在一些实施例中,所述预设输出条件包括当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点、当前种群迭代次数达到预设迭代次数。In some embodiments, the preset output condition includes that there is an individual in the current population whose test can cover the target condition coverage test point, and the number of iterations of the current population reaches the preset number of iterations.

在一些实施例中,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,包括:In some embodiments, the step of outputting the adjusted test case when the individual of the population is adjusted based on the fitness until the preset output condition is met includes:

响应当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点或当前种群迭代次数达到预设迭代次数,则停止迭代并输出所述某个个体对应的测试用例或达到预设迭代次数时种群中个体对应的测试用例。In response to the presence of an individual test in the current population that can cover the target condition coverage test point or the number of iterations in the current population reaches the preset number of iterations, then stop the iteration and output the test case corresponding to the individual or when the preset number of iterations is reached The test cases corresponding to the individuals in the population.

在一些实施例中,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,还包括:In some embodiments, the step of adjusting the individuals of the population based on the fitness until the preset output condition is met, and outputting the adjusted test case further includes:

响应当前种群中的个体测试均不能覆盖所述目标条件覆盖测试点且当前种群迭代次数未达到预设迭代次数,则基于所述适应度对当前种群中的个体进行种群改变操作以生成下代种群。In response to the fact that none of the individual tests in the current population can cover the target condition coverage test point and the number of iterations of the current population does not reach the preset number of iterations, the population change operation is performed on the individuals in the current population based on the fitness to generate the next generation population .

在一些实施例中,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,还包括:In some embodiments, the step of adjusting the individuals of the population based on the fitness until the preset output condition is met, and outputting the adjusted test case further includes:

响应于生成下代种群,则返回执行所述将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码的步骤。In response to generating the next-generation population, return to the step of using the individuals of the population as the input of the code to be tested and running the code to be tested on the verification platform.

在一些实施例中,所述种群改变操作包括选择、交叉和变异操作中的至少一种。In some embodiments, the population changing operation includes at least one of selection, crossover and mutation operations.

在一些实施例中,所述对所述条件树进行节点截取以得到有效节点的步骤,包括:In some embodiments, the step of performing node interception on the conditional tree to obtain valid nodes includes:

从生成的条件树中选择节点层号小于等于预设截取节点层数的所有节点作为有效节点。Select all nodes whose node layer number is less than or equal to the preset intercepted node layer number from the generated condition tree as valid nodes.

在一些实施例中,所述为所述有效节点赋予初始权重值的步骤,包括:In some embodiments, the step of assigning initial weight values to the effective nodes includes:

根据下述公式一为每个有效节点赋予初始权重值:Assign an initial weight value to each valid node according to the following formula 1:

Figure SMS_1
公式一;
Figure SMS_1
formula one;

其中,

Figure SMS_3
表示节点的层号,/>
Figure SMS_7
表示节点在层中的索引号,/>
Figure SMS_9
表示预设截取节点层数,
Figure SMS_4
表示第/>
Figure SMS_6
层中的节点总数,/>
Figure SMS_8
表示逻辑属性系对应的值,/>
Figure SMS_10
表示第/>
Figure SMS_2
层、第/>
Figure SMS_5
个节点的初始权重值。in,
Figure SMS_3
Indicates the layer number of the node, />
Figure SMS_7
Indicates the index number of the node in the layer, />
Figure SMS_9
Indicates the number of preset interception node layers,
Figure SMS_4
Indicates the first />
Figure SMS_6
the total number of nodes in the layer, />
Figure SMS_8
Indicates the value corresponding to the logical attribute system, />
Figure SMS_10
Indicates the first />
Figure SMS_2
Layer, No. />
Figure SMS_5
The initial weight value of each node.

在一些实施例中,逻辑属性系对应的值取值规则如下:In some embodiments, the value selection rules corresponding to logical attributes are as follows:

若节点的逻辑属性为“与”,则

Figure SMS_11
;If the logical attribute of the node is "and", then
Figure SMS_11
;

若节点的逻辑属性为“或”,则

Figure SMS_12
等于此节点对应的父节点所包括的子节点个数。If the logical attribute of the node is "or", then
Figure SMS_12
Equal to the number of child nodes included in the parent node corresponding to this node.

在一些实施例中,所述根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值的步骤,包括:In some embodiments, the step of updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value includes:

根据下述公式二为每个有效节点更新权重值;Update the weight value for each valid node according to the following formula two;

Figure SMS_13
公式二;
Figure SMS_13
formula two;

其中,

Figure SMS_14
表示种群进化的代数且/>
Figure SMS_17
大于等于1,/>
Figure SMS_21
表示第/>
Figure SMS_16
层、第/>
Figure SMS_18
个节点在使用第/>
Figure SMS_22
代种群进行测试时被覆盖的次数,/>
Figure SMS_24
表示种群中个体总数量,/>
Figure SMS_15
表示第/>
Figure SMS_19
次迭代时第/>
Figure SMS_20
层、第/>
Figure SMS_23
个节点的更新权重值。in,
Figure SMS_14
represents the algebra of population evolution and />
Figure SMS_17
greater than or equal to 1, />
Figure SMS_21
Indicates the first />
Figure SMS_16
Layer, No. />
Figure SMS_18
node is using the />
Figure SMS_22
The number of times the generation population is covered when testing, />
Figure SMS_24
Indicates the total number of individuals in the population, />
Figure SMS_15
Indicates the first />
Figure SMS_19
At iteration />
Figure SMS_20
Layer, No. />
Figure SMS_23
The updated weight value of each node.

在一些实施例中,所述根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度的步骤,包括:In some embodiments, the step of calculating the fitness of individuals in the population according to the updated weight value and the coverage status of the valid nodes collected from the verification platform includes:

根据下述公式三计算所述种群中每个个体的适应度;Calculate the fitness of each individual in the population according to the following formula three;

Figure SMS_25
公式三;
Figure SMS_25
formula three;

其中,

Figure SMS_27
表示第/>
Figure SMS_29
代种群中,第/>
Figure SMS_32
个个体的适应度,/>
Figure SMS_28
表示使用第/>
Figure SMS_30
代种群的第/>
Figure SMS_31
个个体测试时,第/>
Figure SMS_33
层的第/>
Figure SMS_26
个节点的覆盖状态对应的值。in,
Figure SMS_27
Indicates the first />
Figure SMS_29
In the generation population, the />
Figure SMS_32
The fitness of an individual, />
Figure SMS_28
Indicates the use of the />
Figure SMS_30
No./> of generation population
Figure SMS_31
When an individual is tested, the first />
Figure SMS_33
Layer />
Figure SMS_26
The value corresponding to the coverage state of a node.

在一些实施例中,节点的覆盖状态对应的值取值规则如下:In some embodiments, the value selection rules corresponding to the coverage state of a node are as follows:

若节点被覆盖则

Figure SMS_34
值为1;If the node is covered then
Figure SMS_34
value is 1;

若节点未被覆盖则

Figure SMS_35
值为0。If the node is not covered then
Figure SMS_35
The value is 0.

在一些实施例中,所述待测试代码用于验证DUT。In some embodiments, the code under test is used to verify the DUT.

在一些实施例中,所述DUT包括内存芯片、处理器、SoC芯片。In some embodiments, the DUT includes memory chips, processors, and SoC chips.

在一些实施例中,所述待测试代码的每个测试用例均包括多个输入参数。In some embodiments, each test case of the code under test includes a plurality of input parameters.

根据本发明的第二方面,提供了一种测试用例生成装置,所述测试用例生成装置包括:According to a second aspect of the present invention, a test case generation device is provided, the test case generation device includes:

生成模块,用于对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;A generating module, which is used to analyze the code to be tested to cover the test point with combinational logic as the target condition, and use preset rules to generate a condition tree for the target condition coverage test point;

构建模块,用于构建遗传算法的种群,其中,种群中的每个个体均为所述待测试代码的初始测试用例;A building block for constructing a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

截取模块,用于对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;An intercepting module, configured to perform node interception on the conditional tree to obtain valid nodes, and assign initial weight values to the valid nodes;

运行模块,用于将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;An operation module, configured to use the individual of the population as the input of the code to be tested, and run the code to be tested on the verification platform;

更新模块,用于根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;An updating module, configured to update the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

计算模块,用于根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;A calculation module, configured to calculate the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

输出模块,用于基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。An output module, configured to adjust the individuals of the population based on the fitness until a preset output condition is met and output an adjusted test case.

根据本发明的第三方面,本发明提供了一种代码测试方法,所述代码测试方法采用以上所述的测试用例生成方法输出的测试用例对代码执行测试。According to the third aspect of the present invention, the present invention provides a code testing method, which uses the test cases output by the test case generation method described above to perform tests on codes.

根据本发明的第四方面,还提供了一种计算设备,该计算设备包括:According to a fourth aspect of the present invention, a computing device is also provided, and the computing device includes:

至少一个处理器;以及at least one processor; and

存储器,存储器存储有可在处理器上运行的计算设备程序,处理器执行程序时执行前述的测试用例生成方法。The memory stores a computing device program that can run on the processor, and the processor executes the aforementioned test case generation method when executing the program.

根据本发明的第五方面,还提供了一种计算设备可读存储介质,计算设备可读存储介质存储有计算设备程序,计算设备程序被处理器执行时执行前述的测试用例生成方法。According to the fifth aspect of the present invention, there is also provided a computing device readable storage medium, the computing device readable storage medium stores a computing device program, and when the computing device program is executed by a processor, the aforementioned test case generation method is executed.

上述一种测试用例生成方法,通过对待测试代码进行分析及使用预设规则为目标条件覆盖测试点生成条件树,从条件树截取所需的有效节点,并为各有效节点生成初始权重值,然后在遗传算法的种群迭代过程中根据有效节点的覆盖次数和初始权重值进行更新,然后在根据更新权重值计算种群个体的适应性从而对种群进行调整,通过不断迭代以产生可以覆盖目标条件覆盖测试点的测试用例,大大降低冗余测试用例数量,根据节点命中概率自动调整适应度可显著加速迭代过程,改善收敛速度,使得测试用例生成不再依赖于代码测试人员的技术水平,降低了测试所需的人工成本,显著的提升了测试效率。The above-mentioned test case generation method generates a condition tree for the target condition coverage test point by analyzing the code to be tested and using preset rules, intercepts the required effective nodes from the condition tree, and generates an initial weight value for each effective node, and then In the population iteration process of the genetic algorithm, it is updated according to the coverage times of effective nodes and the initial weight value, and then the population is adjusted according to the updated weight value to calculate the adaptability of the population individual, and the coverage test can be generated by continuous iteration to cover the target condition The number of redundant test cases is greatly reduced, and the automatic adjustment of fitness according to the node hit probability can significantly speed up the iterative process and improve the convergence speed, so that the generation of test cases no longer depends on the technical level of code testers, reducing the cost of testing. The required labor cost has significantly improved the test efficiency.

此外,本发明还提供了一种测试用例生成装置、一种代码测试方法、一种计算设备和一种计算设备可读存储介质,同样能实现上述技术效果,这里不再赘述。In addition, the present invention also provides a test case generation device, a code testing method, a computing device, and a computing device-readable storage medium, which can also achieve the above technical effects, and will not be repeated here.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention, and those skilled in the art can obtain other embodiments according to these drawings without any creative effort.

图1为本发明一个实施例提供的一种测试用例生成方法的流程图;Fig. 1 is the flowchart of a kind of test case generating method that an embodiment of the present invention provides;

图2为本发明另一个实施例提供的采用本发明方法自动生成测试用例的流程图;Fig. 2 adopts the flow chart that the method of the present invention automatically generates test case that Fig. 2 provides for another embodiment of the present invention;

图3为本发明一个实施例提供的待测试代码中某一组合逻辑对应的条件树例图;Fig. 3 is an example diagram of a conditional tree corresponding to a combination logic in the code to be tested provided by an embodiment of the present invention;

图4为本发明另一个实施例提供的一种测试用例生成装置的结构示意图;4 is a schematic structural diagram of a test case generation device provided by another embodiment of the present invention;

图5为本发明另一个实施例中计算设备的内部结构图。FIG. 5 is an internal structure diagram of a computing device in another embodiment of the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明实施例进一步详细说明。In order to make the object, technical solution and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

需要说明的是,本发明实施例中所有使用“第一”和“第二”的表述均是为了区分两个相同名称非相同的实体或者非相同的参量,可见“第一”“第二”仅为了表述的方便,不应理解为对本发明实施例的限定,后续实施例对此不再一一说明。It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are to distinguish two entities with the same name but different parameters or parameters that are not the same, see "first" and "second" It is only for the convenience of expression, and should not be construed as a limitation on the embodiments of the present invention, which will not be described one by one in the subsequent embodiments.

在一个实施例中,请参照图1所示,本发明提供了一种测试用例生成方法100,具体来说,所述测试用例生成方法包括以下步骤:In one embodiment, please refer to shown in Figure 1, the present invention provides a kind of test case generation method 100, specifically, described test case generation method comprises the following steps:

步骤101,对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Step 101, analyzing the code to be tested to use combinational logic as the target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point;

在本实施例中,对待测试代码进行分析指的是对代码文本的结构和逻辑进行分析,具体来说基于代码程序设计语言语法对程序结构和逻辑进行分析。组合逻辑是至少包括两种及以上的逻辑运算,组合逻辑即可以是相同的逻辑运算组合而成,也可以是多种不同逻辑运算组合而成,例如某个条件覆盖测试点包括三个与运算和两个或运算。预设规则是由测试人员或者用户预先设定的对组合逻辑进行拆分及关联以形成包含一个根节点和若干子节点的节点关系树。In this embodiment, analyzing the code to be tested refers to analyzing the structure and logic of the code text, specifically, analyzing the program structure and logic based on the syntax of the code programming language. Combination logic includes at least two or more logic operations. Combination logic can be a combination of the same logic operations or a combination of different logic operations. For example, a condition coverage test point includes three AND operations and two OR operations. The preset rules are pre-set by testers or users to split and associate combination logic to form a node relationship tree including a root node and several child nodes.

步骤102,构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;Step 102, constructing a genetic algorithm population, wherein each individual in the population is an initial test case of the code to be tested;

在本实施例中,遗传算法是一种进化迭代搜索算法,生成初始种群后,根据种群内个体的性能(也称适应度)对种群个体按照特定规则进行选择、交叉和变异操作来生成新的种群,新的种群在继承原始种群优秀基因的基础上,保持种群多样性和进化可能性,并最终通过不断迭代生成最优种群。为了提高遗传算法的性能,一系列改良算法被提出,如改进遗传算法、自适应遗传算法、模糊遗传算法等。其中自适应遗传算法通过对遗传参数的自适应调整,能够提高算法收敛精度和收敛速度,优选使用自适应遗传算法构建种群。初始测试用例是指本次搜索未进过迭代的无法覆盖目标条件覆盖测试点的测试用例,初始测试用例可以是随机生成的、由测试人员定义的测试用例或者现有约束方法所生成的测试用例,当然初始测试用例也可以前一次遗传算法搜索结束后未能覆盖目标条件覆盖测试点的最终测试用例。In this embodiment, the genetic algorithm is an evolutionary iterative search algorithm. After the initial population is generated, the population individuals are selected, crossed and mutated according to specific rules according to the performance (also called fitness) of the individuals in the population to generate new Population, on the basis of inheriting the excellent genes of the original population, the new population maintains the diversity and evolutionary possibility of the population, and finally generates the optimal population through continuous iteration. In order to improve the performance of genetic algorithm, a series of improved algorithms are proposed, such as improved genetic algorithm, adaptive genetic algorithm, fuzzy genetic algorithm and so on. Among them, the adaptive genetic algorithm can improve the convergence accuracy and convergence speed of the algorithm through the adaptive adjustment of the genetic parameters, and the adaptive genetic algorithm is preferably used to construct the population. The initial test case refers to the test case that cannot cover the target condition coverage test point that has not been iterated in this search. The initial test case can be a randomly generated test case defined by the tester or a test case generated by the existing constraint method , of course, the initial test case can also be the final test case that failed to cover the target condition coverage test point after the previous genetic algorithm search.

步骤103,对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Step 103, performing node interception on the conditional tree to obtain effective nodes, and assigning initial weight values to the effective nodes;

在本实施例中,节点截取是指从条件树中选取部分节点,例如截取条件树中靠近根节点的节点或者截取条件树中特定深度的节点等等。权重值(weight value)是指给定的一组数据在解决某个问题时的重要性或影响力的度量。权重值的计算方式有很多种,具体方法取决于实际情况,例如可以使用现有权重计算方法,例如相对权重法、百分比法、等级法、分值法、线性加权法或者多种方法组合使用。In this embodiment, node interception refers to selecting some nodes from the conditional tree, for example, intercepting nodes close to the root node in the conditional tree, or intercepting nodes at a specific depth in the conditional tree, and so on. Weight value refers to the measure of the importance or influence of a given set of data in solving a certain problem. There are many ways to calculate the weight value, and the specific method depends on the actual situation. For example, existing weight calculation methods can be used, such as relative weight method, percentage method, grade method, score method, linear weighting method or a combination of multiple methods.

步骤104,将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Step 104, using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform;

在本实施例中,验证平台是指能够运行待测试代码并能对代码的运行过程结果进行收集分析和统计的工具,本实例不对验证平台的版本和类型进行限定,只需具有相应分析统计功能即可。In this embodiment, the verification platform refers to a tool that can run the code to be tested and collect, analyze and count the running process results of the code. This example does not limit the version and type of the verification platform, and only needs to have corresponding analysis and statistics functions That's it.

步骤105,根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;Step 105, updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

步骤106,根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;Step 106, calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

步骤107基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。Step 107 adjusts the individuals of the population based on the fitness until the adjusted test case is output when the preset output condition is satisfied.

在本实施例中,对种群个体进行调整是指对种群进行改变形成新个体,进而由各个新个体构成新种群,形成新种群后会再次返回执行步骤104由此实现种群迭代。In this embodiment, adjusting the population individuals refers to changing the population to form new individuals, and then forming a new population from each new individual, and returning to step 104 to implement population iteration after forming the new population.

上述一种测试用例生成方法,通过对待测试代码进行分析及使用预设规则为目标条件覆盖测试点生成条件树,从条件树截取所需的有效节点,并为各有效节点生成初始权重值,然后在遗传算法的种群迭代过程中根据有效节点的覆盖次数和初始权重值进行更新,然后在根据更新权重值计算种群个体的适应性从而对种群进行调整,通过不断迭代以产生可以覆盖目标条件覆盖测试点的测试用例,大大降低冗余测试用例数量,根据节点命中概率自动调整适应度可显著加速迭代过程,改善收敛速度,使得测试用例生成不再依赖于代码测试人员的技术水平,降低了测试所需的人工成本,显著的提升了测试效率。The above-mentioned test case generation method generates a condition tree for the target condition coverage test point by analyzing the code to be tested and using preset rules, intercepts the required effective nodes from the condition tree, and generates an initial weight value for each effective node, and then In the population iteration process of the genetic algorithm, it is updated according to the coverage times of effective nodes and the initial weight value, and then the population is adjusted according to the updated weight value to calculate the adaptability of the population individual, and the coverage test can be generated by continuous iteration to cover the target condition The number of redundant test cases is greatly reduced, and the automatic adjustment of fitness according to the node hit probability can significantly speed up the iterative process and improve the convergence speed, so that the generation of test cases no longer depends on the technical level of code testers, reducing the cost of testing. The required labor cost has significantly improved the test efficiency.

在一些实施例中,所述预设规则包括以下至少一种:In some embodiments, the preset rules include at least one of the following:

将所述目标条件覆盖测试点对应的组合逻辑作为根节点;Taking the combined logic corresponding to the target condition coverage test point as the root node;

基于预设子项分割规则处理组合逻辑,将组合逻辑本身作为父节点、将父节点组合逻辑的子项作为子节点;Processing the combination logic based on the preset sub-item segmentation rules, using the combination logic itself as a parent node, and using the child items of the combination logic of the parent node as child nodes;

对于分支条件,将引起本节点变量变化的分支列为子节点;For branch conditions, the branch that causes the variable change of this node is listed as a child node;

当节点为代码输入参数、代码不可见组件的输出或节点变量的值变化与其他变量均不存在逻辑关系时,则节点为叶节点不再分解;When the node is a code input parameter, the output of a code invisible component, or the value change of a node variable has no logical relationship with other variables, the node is a leaf node and will not be decomposed;

将每个节点到达根节点所经过的最少节点数作为节点的层号。The minimum number of nodes passed by each node to reach the root node is taken as the layer number of the node.

在一些实施例中,所述预设子项分割规则包括以下至少一种:In some embodiments, the preset subitem segmentation rules include at least one of the following:

分割规则一、对逻辑运算符进行转换以得到仅包括与关系、或关系的组合逻辑;Segmentation rule 1. Convert logical operators to obtain combinational logic including only AND relation or OR relation;

分割规则二、将与关系、或关系的优先级设定为遵循所述待测试代码的设计语言规则;Segmentation rule 2, setting the priority of the AND relationship, or the relationship, to follow the design language rules of the code to be tested;

分割规则三、子项间仅存在单一形式逻辑关系,每个子项对应一个子节点;Segmentation rule 3. There is only a single form of logical relationship between sub-items, and each sub-item corresponds to a sub-node;

分割规则四、进行子项分解前需要根据逻辑运算规则对组合逻辑进行化简以保证每项内不包含逻辑运算符;Segmentation rule 4. Before decomposing sub-items, it is necessary to simplify the combination logic according to the logical operation rules to ensure that each item does not contain logical operators;

分割规则五、对于根节点逻辑关系式经过分割规则一、分割规则二、分割规则四转换后将或关系均改为与关系;Segmentation rule 5. For the logical relationship of the root node, after conversion by segmentation rule 1, segmentation rule 2, and segmentation rule 4, the OR relationship is changed to an AND relationship;

分割规则六、若化简后的逻辑关系式中既含有或关系又含有与关系,则先分解出低优先级逻辑关系的子节点,再从产生的子节点中分解出高优先级的子节点。Segmentation rule 6. If the simplified logical relation contains both an OR relation and an AND relation, first decompose the sub-nodes of the low-priority logical relation, and then decompose the high-priority sub-nodes from the generated sub-nodes .

在一些实施例中,所述预设输出条件包括当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点、当前种群迭代次数达到预设迭代次数。In some embodiments, the preset output condition includes that there is an individual in the current population whose test can cover the target condition coverage test point, and the number of iterations of the current population reaches the preset number of iterations.

在本实施例中通过设置两种迭代停止的条件可以有效避免过度无效迭代,保证遗传算法的稳定执行。In this embodiment, by setting two conditions for stopping iterations, excessive invalid iterations can be effectively avoided, and stable execution of the genetic algorithm can be ensured.

在本实施例中,前述步骤107,基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例,包括:In this embodiment, the aforementioned step 107 is to adjust the individuals of the population based on the fitness until the preset output conditions are met, and output the adjusted test cases, including:

响应当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点或当前种群迭代次数达到预设迭代次数,则停止迭代并输出所述某个个体对应的测试用例或达到预设迭代次数时种群中个体对应的测试用例。In response to the presence of an individual test in the current population that can cover the target condition coverage test point or the number of iterations in the current population reaches the preset number of iterations, then stop the iteration and output the test case corresponding to the individual or when the preset number of iterations is reached The test cases corresponding to the individuals in the population.

在一些实施例中,前述步骤107,基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例,还包括:In some embodiments, the aforementioned step 107, adjusting the individuals of the population based on the fitness until the preset output conditions are met, outputting the adjusted test cases further includes:

响应当前种群中的个体测试均不能覆盖所述目标条件覆盖测试点且当前种群迭代次数未达到预设迭代次数,则基于所述适应度对当前种群中的个体进行种群改变操作以生成下代种群。In response to the fact that none of the individual tests in the current population can cover the target condition coverage test point and the number of iterations of the current population does not reach the preset number of iterations, the population change operation is performed on the individuals in the current population based on the fitness to generate the next generation population .

在一些实施例中,前述步骤107,基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例,还包括:In some embodiments, the aforementioned step 107, adjusting the individuals of the population based on the fitness until the preset output conditions are met, outputting the adjusted test cases further includes:

响应于生成下代种群,则返回执行所述将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码的步骤。In response to generating the next-generation population, return to the step of using the individuals of the population as the input of the code to be tested and running the code to be tested on the verification platform.

在一些实施例中,所述种群改变操作包括选择、交叉和变异操作中的至少一种。In some embodiments, the population changing operation includes at least one of selection, crossover and mutation operations.

需要说明的是,在具体实施过程中优选以上三种操作组合使用,例如对种群个体采用进行先选择操作,再交叉操作,最后进行变异操作从而得到新种群。It should be noted that, in the specific implementation process, it is preferable to use the above three operations in combination, for example, the selection operation is performed on the population individuals first, then the crossover operation is performed, and finally the mutation operation is performed to obtain a new population.

在一些实施例中,前述步骤103中对所述条件树进行节点截取以得到有效节点,包括:In some embodiments, performing node interception on the conditional tree in step 103 to obtain valid nodes includes:

从生成的条件树中选择节点层号小于等于预设截取节点层数的所有节点作为有效节点。Select all nodes whose node layer number is less than or equal to the preset intercepted node layer number from the generated condition tree as valid nodes.

在一些实施例中,前述步骤103中的为所述有效节点赋予初始权重值,包括:In some embodiments, assigning initial weight values to the effective nodes in the aforementioned step 103 includes:

根据下述公式一为每个有效节点赋予初始权重值:Assign an initial weight value to each valid node according to the following formula 1:

Figure SMS_36
公式一;
Figure SMS_36
formula one;

其中,

Figure SMS_38
表示节点的层号,/>
Figure SMS_41
表示节点在层中的索引号,/>
Figure SMS_43
表示预设截取节点层数,
Figure SMS_37
表示第/>
Figure SMS_42
层中的节点总数,/>
Figure SMS_44
表示逻辑属性系对应的值,/>
Figure SMS_45
表示第/>
Figure SMS_39
层、第/>
Figure SMS_40
个节点的初始权重值。in,
Figure SMS_38
Indicates the layer number of the node, />
Figure SMS_41
Indicates the index number of the node in the layer, />
Figure SMS_43
Indicates the number of preset interception node layers,
Figure SMS_37
Indicates the first />
Figure SMS_42
the total number of nodes in the layer, />
Figure SMS_44
Indicates the value corresponding to the logical attribute system, />
Figure SMS_45
Indicates the first />
Figure SMS_39
Layer, No. />
Figure SMS_40
The initial weight value of each node.

在一些实施例中,逻辑属性系对应的值取值规则如下:In some embodiments, the value selection rules corresponding to logical attributes are as follows:

若节点的逻辑属性为“与”,则

Figure SMS_46
;If the logical attribute of the node is "and", then
Figure SMS_46
;

若节点的逻辑属性为“或”,则

Figure SMS_47
等于此节点对应的父节点所包括的子节点个数。If the logical attribute of the node is "or", then
Figure SMS_47
Equal to the number of child nodes included in the parent node corresponding to this node.

在一些实施例中,前述步骤105,根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值,包括:In some embodiments, the aforementioned step 105, updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value includes:

根据下述公式二为每个有效节点更新权重值;Update the weight value for each valid node according to the following formula two;

Figure SMS_48
公式二;
Figure SMS_48
formula two;

其中,

Figure SMS_49
表示种群进化的代数且/>
Figure SMS_52
大于等于1,/>
Figure SMS_57
表示第/>
Figure SMS_51
层、第/>
Figure SMS_54
个节点在使用第/>
Figure SMS_55
代种群进行测试时被覆盖的次数,/>
Figure SMS_59
表示种群中个体总数量,/>
Figure SMS_50
表示第/>
Figure SMS_53
次迭代时第/>
Figure SMS_56
层、第/>
Figure SMS_58
个节点的更新权重值。in,
Figure SMS_49
represents the algebra of population evolution and />
Figure SMS_52
greater than or equal to 1, />
Figure SMS_57
Indicates the first />
Figure SMS_51
Layer, No. />
Figure SMS_54
node is using the />
Figure SMS_55
The number of times the generation population is covered when testing, />
Figure SMS_59
Indicates the total number of individuals in the population, />
Figure SMS_50
Indicates the first />
Figure SMS_53
At iteration />
Figure SMS_56
Layer, No. />
Figure SMS_58
The updated weight value of each node.

在一些实施例中,前述步骤106,根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度,包括:In some embodiments, the aforementioned step 106, calculating the fitness of individuals in the population according to the updated weight value and the coverage status of the valid nodes collected from the verification platform, includes:

根据下述公式三计算所述种群中每个个体的适应度;Calculate the fitness of each individual in the population according to the following formula three;

Figure SMS_60
公式三;
Figure SMS_60
formula three;

其中,

Figure SMS_62
表示第/>
Figure SMS_64
代种群中,第/>
Figure SMS_67
个个体的适应度,/>
Figure SMS_63
表示使用第/>
Figure SMS_65
代种群的第/>
Figure SMS_66
个个体测试时,第/>
Figure SMS_68
层的第/>
Figure SMS_61
个节点的覆盖状态对应的值。in,
Figure SMS_62
Indicates the first />
Figure SMS_64
In the generation population, the />
Figure SMS_67
The fitness of an individual, />
Figure SMS_63
Indicates the use of the />
Figure SMS_65
No./> of generation population
Figure SMS_66
When an individual is tested, the first />
Figure SMS_68
Layer />
Figure SMS_61
The value corresponding to the coverage state of a node.

在一些实施例中,节点的覆盖状态对应的值取值规则如下:In some embodiments, the value selection rules corresponding to the coverage state of a node are as follows:

若节点被覆盖则

Figure SMS_69
值为1;If the node is covered then
Figure SMS_69
value is 1;

若节点未被覆盖则

Figure SMS_70
值为0。If the node is not covered then
Figure SMS_70
The value is 0.

在一些实施例中,所述待测试代码用于验证DUT。其中,DUT是Design under Test的简称,优选地,按功能划分DUT可以是内存芯片、处理器、SoC芯片等。In some embodiments, the code under test is used to verify the DUT. Wherein, DUT is the abbreviation of Design under Test. Preferably, the DUT can be a memory chip, a processor, a SoC chip, etc. according to functions.

在一些实施例中,所述待测试代码的每个测试用例均包括多个输入参数。In some embodiments, each test case of the code under test includes a plurality of input parameters.

在又一个实施例中,为了便于理解本发明的方案,针对各类软件测试应用场景下面请结合图2所示,本实施例以测试用例中的一个具体组合逻辑为例,详细说明本发明面向代码条件覆盖测试提供了又一种测试用例生成方法,具体而言,通过代码文本分析及一定规则生成对于目标覆盖测试点的条件树,截取所需层数的节点,根据算法生成各个节点的适应度系数,然后根据自适应遗传算法以及设计的适应度函数,通过不断迭代以产生可以覆盖目标条件覆盖测试点的测试用例,在此过程中,根据节点命中概率自动调整适应度函数,以加速迭代过程。具体实施过程如下:In yet another embodiment, in order to facilitate the understanding of the solution of the present invention, please refer to the following for various software test application scenarios as shown in Figure 2. This embodiment takes a specific combination logic in a test case as an example to describe in detail the present invention for Code conditional coverage testing provides another test case generation method. Specifically, the conditional tree for the target coverage test point is generated through code text analysis and certain rules, and the nodes with the required number of layers are intercepted, and the adaptation of each node is generated according to the algorithm. degree coefficient, and then according to the adaptive genetic algorithm and the designed fitness function, through continuous iteration to generate test cases that can cover the target condition coverage test points, in the process, the fitness function is automatically adjusted according to the node hit probability to speed up the iteration process. The specific implementation process is as follows:

步骤一,对代码进行分析生成条件树;根据代码程序设计语言语法对程序结构和逻辑进行分析,使用特定规则生成条件树,生成条件树的规则如下:Step 1: Analyze the code to generate a conditional tree; analyze the program structure and logic according to the syntax of the code programming language, and use specific rules to generate a conditional tree. The rules for generating a conditional tree are as follows:

(1)、根节点为目标条件覆盖测试点、根节点为组合逻辑。(1) The root node is the target condition coverage test point, and the root node is the combination logic.

(2)、对于组合逻辑,父节点为组合逻辑本身,子节点为父节点组合逻辑的子项,子项分割规则如下:(2) For combinatorial logic, the parent node is the combinatorial logic itself, and the child node is the child of the parent node's combinatorial logic. The sub-item division rules are as follows:

分割规则一,逻辑运算符包括:与(&&)、或(||)、非(!),仅处理&&和||运算符,!运算式进行转换,如!(a==1)转为(a!=1);Segmentation rule 1, logical operators include: and (&&), or (||), not (!), only processing && and || operators, ! Expressions are converted, such as !(a==1) into (a!=1);

分割规则二,&&和||的优先级遵循对应程序设计语言规则;Segmentation rule 2, the priority of && and || follows the corresponding programming language rules;

分割规则三,子项间仅存在单一形式逻辑关系,每个子项对应一个子节点,子节点除包含子项外,还包括逻辑关系属性,若本层子项间逻辑关系为||,则逻辑关系属性为“或”,若本层子项间逻辑关系为&&,则逻辑关系属性为“与”;Segmentation rule 3. There is only a single form of logical relationship between sub-items. Each sub-item corresponds to a sub-node. In addition to sub-items, sub-nodes also include logical relationship attributes. If the logical relationship between sub-items in this layer is ||, the logic The relationship attribute is "or", if the logical relationship between sub-items in this layer is &&, then the logical relationship attribute is "and";

分割规则四,进行子项分解前需要根据逻辑运算规则对组合逻辑进行化简,保证每项内不包含逻辑运算符;Segmentation rule 4. Before decomposing sub-items, the combination logic needs to be simplified according to the logical operation rules to ensure that each item does not contain logical operators;

分割规则五,对于根节点,逻辑关系式经过分割规则一、分割规则二、分割规则四转换后,将||符号均改为&&符号,即无论子项间原逻辑关系为何,均转为与关系;Segmentation rule 5, for the root node, after the logic relation expression is converted by segmentation rule 1, segmentation rule 2, and segmentation rule 4, the || relation;

分割规则六,若化简后的逻辑关系式中既含有||又含有&&,先分解出低优先级逻辑关系子节点,再从产生的子节点中分解出高优先级子节点;Segmentation rule six, if the simplified logical relation contains both || and &&, decompose the low-priority logical relation sub-nodes first, and then decompose the high-priority sub-nodes from the generated sub-nodes;

例如,对于父节点组合逻辑(a>1)&&((b==5)&&(c!=7))||((d<7)&&(!(e!=1))),根据分割规则一首先转为(a>1)&&((b==5)&&(c!=7))||((d<7)&&(e==1));For example, for the parent node combination logic (a>1)&&((b==5)&&(c!=7))||((d<7)&&(!(e!=1))), according to the split Rule 1 first turns into (a>1)&&((b==5)&&(c!=7))||((d<7)&&(e==1));

若当前节点不是根节点,根据分割规则四转为(a>1)&&(b==5)&&(c!=7)||(d<7)&&(e==1);根据分割规则三,||运算符优先级低,可分解为两层子式,第一层为(a>1)&&(b==5)&&(c!=7)和(d<7)&&(e==1),逻辑关系属性均为“或”,第二层为(a>1)、(b==5)、(c!=7)、(d<7)、(e==1),逻辑关系属性均为“与”。If the current node is not the root node, turn it into (a>1)&&(b==5)&&(c!=7)||(d<7)&&(e==1) according to the splitting rule; according to the splitting rule Third, the || operator has low priority and can be decomposed into two layers of sub-formulas. The first layer is (a>1)&&(b==5)&&(c!=7) and (d<7)&&(e ==1), the logical relationship attributes are all "or", the second layer is (a>1), (b==5), (c!=7), (d<7), (e==1) , the logical relationship attributes are all "and".

若当前节点是根节点,根据分割规则五转为(a>1)&&(b==5)&&(c!=7)&&(d<7)&&(e==1),则子节点仅有一层为(a>1)、(b==5)、(c!=7)、(d<7)、(e==1),逻辑关系属性均为“与”。If the current node is the root node, according to the splitting rule five turns into (a>1)&&(b==5)&&(c!=7)&&(d<7)&&(e==1), then the child node only There is a layer (a>1), (b==5), (c!=7), (d<7), (e==1), and the logical relationship attribute is "and".

(3),对于分支条件,将引起本节点变量变化的分支列为子节点,逻辑关系属性均为“或”;(3) For the branch condition, the branch that causes the variable change of this node is listed as a child node, and the logical relationship attributes are all "or";

例如,对于节点(a>1),节点变量为a,假如状态变量state,当state==1和state==3时会引起a变化,则(a>1)的子节点为(state==1)和(state==3),逻辑关系属性均为“或”。For example, for a node (a>1), the node variable is a, if the state variable state, when state==1 and state==3 will cause a to change, then the child node of (a>1) is (state== 1) and (state==3), the logical relationship attributes are both "or".

(4)、当节点为代码输入参数、代码不可见组件的输出或节点变量的值变化与其他变量均不存在逻辑关系时,此节点为叶节点,不再分解。(4) When a node is a code input parameter, an output of an invisible component of code, or a value change of a node variable has no logical relationship with other variables, the node is a leaf node and will not be decomposed.

(5)、每个子节点根据到达根节点所经过的最少节点数定为本节点的层号。(5) Each child node is set as the layer number of the node according to the minimum number of nodes passed by to reach the root node.

基于以上规则生成的条件树如图3所示,每个椭圆代表一个节点,内部标有目标关系式(条件关系式或条件、逻辑混合关系式),始于当前节点、终于父节点的带箭头线段上标有当前节点的逻辑关系属性。The conditional tree generated based on the above rules is shown in Figure 3. Each ellipse represents a node, and the target relational expression (conditional relational expression or conditional, logical mixed relational expression) is marked inside, starting from the current node and ending at the parent node with an arrow The logical relationship attributes of the current node are marked on the line segment.

步骤二,根据截取层数配置从条件树截取对应节点。配置参数为所需截取的节点层数,用于确定哪些节点可用于计算适应度,被选中节点称为有效节点。有效节点选择规则为:当节点层号小于等于配置层数时,此节点为有效节点Step 2, intercept corresponding nodes from the conditional tree according to the configuration of interception layers. The configuration parameter is the number of node layers to be intercepted, which is used to determine which nodes can be used to calculate the fitness, and the selected nodes are called effective nodes. The effective node selection rule is: when the node layer number is less than or equal to the configured layer number, the node is a valid node

步骤三,根据算法对各个有效节点赋予初始权重值。有效节点初始权重值按如下规则设置:Step 3: Assign initial weight values to each valid node according to the algorithm. The initial weight value of a valid node is set according to the following rules:

Figure SMS_71
公式一;
Figure SMS_71
formula one;

公式一中参数含义解释如下:The meaning of the parameters in formula 1 is explained as follows:

Figure SMS_72
表示节点的层号;
Figure SMS_72
Indicates the layer number of the node;

Figure SMS_73
表示节点在层中的索引号,不妨以图3中第一层节点为例,该层包括四个节点,从左到右的四个节点其索引号可以分别记作1至4;
Figure SMS_73
Indicates the index number of the node in the layer. Take the first layer node in Figure 3 as an example. This layer includes four nodes. The index numbers of the four nodes from left to right can be recorded as 1 to 4 respectively;

Figure SMS_74
表示预设截取节点层数;
Figure SMS_74
Indicates the number of preset interception node layers;

Figure SMS_75
表示第/>
Figure SMS_76
层中的节点总数;
Figure SMS_75
Indicates the first />
Figure SMS_76
the total number of nodes in the layer;

Figure SMS_77
表示逻辑属性系对应的值,若节点的逻辑属性为“与”,则/>
Figure SMS_78
;若节点的逻辑属性为“或”,则/>
Figure SMS_79
等于此节点对应的父节点所包括的子节点个数;
Figure SMS_77
Indicates the value corresponding to the logical attribute. If the logical attribute of the node is "and", then />
Figure SMS_78
; If the logical attribute of the node is "or", then />
Figure SMS_79
Equal to the number of child nodes included in the parent node corresponding to this node;

Figure SMS_80
表示第/>
Figure SMS_81
层、第/>
Figure SMS_82
个节点的初始权重值。
Figure SMS_80
Indicates the first />
Figure SMS_81
Layer, No. />
Figure SMS_82
The initial weight value of each node.

步骤四,刷新节点权重。节点权重用于计算遗传算法中个体的适应度,每个有效节点的权重随着种群进化而不断优化,以削弱非关键节点对个体适应度的影响,继而使种群向增加关键节点覆盖率的方向进化。节点权重更新按下式进行:Step 4, refresh the node weight. The node weight is used to calculate the fitness of the individual in the genetic algorithm. The weight of each effective node is continuously optimized as the population evolves to weaken the influence of non-key nodes on the fitness of the individual, and then make the population increase the coverage of key nodes. evolution. Node weights are updated as follows:

Figure SMS_83
公式二;
Figure SMS_83
formula two;

公式二中参数含义解释如下:The meaning of the parameters in formula 2 is explained as follows:

Figure SMS_84
表示种群进化的代数且/>
Figure SMS_85
大于等于1;
Figure SMS_84
represents the algebra of population evolution and />
Figure SMS_85
greater than or equal to 1;

Figure SMS_86
表示第/>
Figure SMS_87
层、第/>
Figure SMS_88
个节点在使用第/>
Figure SMS_89
代种群进行测试时被覆盖的次数;
Figure SMS_86
Indicates the first />
Figure SMS_87
Layer, No. />
Figure SMS_88
node is using the />
Figure SMS_89
The number of times covered when testing on behalf of the population;

Figure SMS_90
表示种群中个体总数量;
Figure SMS_90
Indicates the total number of individuals in the population;

Figure SMS_91
表示第/>
Figure SMS_92
次迭代时第/>
Figure SMS_93
层、第/>
Figure SMS_94
个节点的更新权重值。
Figure SMS_91
Indicates the first />
Figure SMS_92
At iteration />
Figure SMS_93
Layer, No. />
Figure SMS_94
The updated weight value of each node.

步骤五,遗传参数设置。对遗传算法的交叉率、变异率等参数进行设置。Step five, genetic parameter setting. Set parameters such as the crossover rate and mutation rate of the genetic algorithm.

步骤六,种群初始化。遗传算法染色体由对输入参数进行二进制编码产生,种群通过约束随机算法产生。Step six, population initialization. Genetic algorithm chromosomes are generated by binary encoding of input parameters, and populations are generated by constrained random algorithms.

步骤七,运行验证平台和待测代码。对个体染色体进行解码以生成测试用例中的输入参数,将这些参数输入到验证平台,并运行验证平台和待测代码。Step seven, run the verification platform and the code to be tested. Decode individual chromosomes to generate input parameters in test cases, input these parameters to the verification platform, and run the verification platform and the code under test.

步骤八,收集节点覆盖信息。测试完种群内所有个体对应的测试用例后,统计每个有效节点覆盖情况,包括在每个测试用例中是否被覆盖以及本代种群中被覆盖的次数。Step eight, collecting node coverage information. After testing the test cases corresponding to all individuals in the population, count the coverage of each effective node, including whether it is covered in each test case and the number of times it is covered in the current generation population.

步骤九,计算种群个体适应度。个体适应度按下式计算:Step 9, calculate the individual fitness of the population. The individual fitness is calculated according to the following formula:

Figure SMS_95
公式三;
Figure SMS_95
formula three;

公式三中参数含义解释如下:The meaning of the parameters in Formula 3 is explained as follows:

Figure SMS_96
表示第/>
Figure SMS_97
代种群中,第/>
Figure SMS_98
个个体的适应度
Figure SMS_96
Indicates the first />
Figure SMS_97
In the generation population, the />
Figure SMS_98
individual fitness

Figure SMS_99
表示使用第/>
Figure SMS_100
代种群的第/>
Figure SMS_101
个个体测试时,第/>
Figure SMS_102
层的第/>
Figure SMS_103
个节点的覆盖状态对应的值,若节点被覆盖则/>
Figure SMS_104
值为1,若节点未被覆盖则/>
Figure SMS_105
值为0。
Figure SMS_99
Indicates the use of the />
Figure SMS_100
No./> of generation population
Figure SMS_101
When an individual is tested, the first />
Figure SMS_102
Layer />
Figure SMS_103
The value corresponding to the coverage state of a node, if the node is covered then />
Figure SMS_104
The value is 1, if the node is not covered then />
Figure SMS_105
The value is 0.

步骤十,种群个体分析。主要分析条件覆盖测试点是否达到,若达到目标条件覆盖测试点或到达允许的最大进化代数,则停止搜索过程,达到目标条件覆盖测试点则输出测试用例,未达到则搜索失败,需调整运行参数,再次进行搜索;若未达到目标条件覆盖测试点且未到达允许的最大进化代数,则进行传统遗传算法的选择、交叉和变异操作,以产生新的种群,并重复步骤四到步骤十的流程。Step ten, population individual analysis. Mainly analyze whether the condition coverage test point is reached. If the target condition coverage test point is reached or the maximum allowed evolution algebra is reached, the search process will be stopped. If the target condition coverage test point is reached, the test case will be output. If the target condition coverage test point is not reached, the search will fail and the operating parameters need to be adjusted. , search again; if the target condition coverage test point is not reached and the maximum allowable evolution algebra is not reached, the selection, crossover and mutation operations of the traditional genetic algorithm are performed to generate a new population, and the process from step 4 to step 10 is repeated .

本实施例的一种测试用例生成方法至少具备以下有益技术效果:A method for generating test cases in this embodiment has at least the following beneficial technical effects:

(1)提出条件树的构建策略,设计基于条件树和节点覆盖信息的自适应权重生成和调整规则,继而确定相应适应度函数,以优化算法收敛速度。(1) Propose the construction strategy of the conditional tree, design the adaptive weight generation and adjustment rules based on the conditional tree and node coverage information, and then determine the corresponding fitness function to optimize the convergence speed of the algorithm.

(2)基于自适应遗传算法,采用约束随机方式生成初始种群,根据运行信息对由种群个体解码生成的测试用例进行适应度评价,基于评价结果,通过选择、交叉、变异操作生成优化的新种群。(2) Based on the adaptive genetic algorithm, the initial population is generated in a constrained random manner, and the fitness evaluation of the test cases generated by decoding the individual population is performed according to the operating information. Based on the evaluation results, an optimized new population is generated through selection, crossover, and mutation operations .

(3)根据代码的覆盖信息不断优化适应度计算参数,增加关键(瓶颈)条件的权重,加速算法收敛。(3) Continuously optimize fitness calculation parameters according to code coverage information, increase the weight of key (bottleneck) conditions, and accelerate algorithm convergence.

(4)在新测试用例生成过程中考虑了代码测试过程信息,大大降低了冗余测试用例比例,而采用自适应的适应度函数,这个比例进一步降低。(4) The code test process information is considered in the process of generating new test cases, which greatly reduces the proportion of redundant test cases, and the adaptive fitness function is used to further reduce this proportion.

(5)仅需人工配置运行参数,测试用例生成过程无需人工干预,且条件节点未触及代码不可见组件的内部,也不受其影响,显著降低了测试用例生成难度和复杂度,降低人工成本。(5) It only needs to manually configure the running parameters, and the test case generation process does not require manual intervention, and the conditional node does not touch the interior of the invisible component of the code, and is not affected by it, which significantly reduces the difficulty and complexity of test case generation and reduces labor costs .

在一些实施例中,请参照图4所示,本发明还提供了一种测试用例生成装置200,所述测试用例生成装置包括:In some embodiments, as shown in FIG. 4, the present invention also provides a test case generation device 200, the test case generation device includes:

生成模块201,用于对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;The generation module 201 is used to analyze the code to be tested to cover the test point with the combinational logic as the target condition, and use preset rules to generate a condition tree for the target condition coverage test point;

构建模块202,用于构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;A construction module 202, configured to construct a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

截取模块203,用于对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;An intercepting module 203, configured to perform node interception on the conditional tree to obtain valid nodes, and assign initial weight values to the valid nodes;

运行模块204,用于将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;The running module 204 is used to use the individuals of the population as the input of the code to be tested, and run the code to be tested on the verification platform;

更新模块205,用于根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;An update module 205, configured to update the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

计算模块206,用于根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;A calculation module 206, configured to calculate the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

输出模块207,用于基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The output module 207 is configured to adjust the individuals of the population based on the fitness until the preset output condition is met and output the adjusted test cases.

上述一种测试用例生成装置,通过对待测试代码进行分析及使用预设规则为目标条件覆盖测试点生成条件树,从条件树截取所需的有效节点,并为各有效节点生成初始权重值,然后在遗传算法的种群迭代过程中根据有效节点的覆盖次数和初始权重值进行更新,然后在根据更新权重值计算种群个体的适应性从而对种群进行调整,通过不断迭代以产生可以覆盖目标条件覆盖测试点的测试用例,大大降低冗余测试用例数量,根据节点命中概率自动调整适应度可显著加速迭代过程,改善收敛速度,使得测试用例生成不再依赖于代码测试人员的技术水平,降低了测试所需的人工成本,显著的提升了测试效率。The above-mentioned test case generation device generates a condition tree for the target condition coverage test point by analyzing the code to be tested and using preset rules, intercepts the required effective nodes from the condition tree, and generates an initial weight value for each effective node, and then In the population iteration process of the genetic algorithm, it is updated according to the coverage times of effective nodes and the initial weight value, and then the population is adjusted according to the updated weight value to calculate the adaptability of the population individual, and the coverage test can be generated by continuous iteration to cover the target condition The number of redundant test cases is greatly reduced, and the automatic adjustment of fitness according to the node hit probability can significantly speed up the iterative process and improve the convergence speed, so that the generation of test cases no longer depends on the technical level of code testers, reducing the cost of testing. The required labor cost has significantly improved the test efficiency.

需要说明的是,关于测试用例生成装置的具体限定可以参见上文中对测试用例生成方法的限定,在此不再赘述。上述测试用例生成装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算设备中的处理器中,也可以以软件形式存储于计算设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。It should be noted that, for specific limitations on the test case generation device, reference may be made to the above-mentioned limitations on the test case generation method, which will not be repeated here. Each module in the above-mentioned test case generation device can be fully or partially realized by software, hardware and combinations thereof. The above-mentioned modules can be embedded in or independent of the processor in the computing device in the form of hardware, and can also be stored in the memory of the computing device in the form of software, so that the processor can call and execute the corresponding operations of the above-mentioned modules.

根据本发明的另一方面,提供了一种代码测试方法,所述代码测试方法采用以上实施例所述的测试用例生成方法输出的测试用例对代码执行测试,所述的测试用例生成方法包括:According to another aspect of the present invention, a kind of code test method is provided, described code test method adopts the test case output of test case generation method described in the above embodiment to code execution test, and described test case generation method comprises:

对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Analyzing the code to be tested to use combinational logic as a target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point;

构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;Construct a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Performing node interception on the conditional tree to obtain valid nodes, and assigning initial weight values to the valid nodes;

将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform;

根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The individuals of the population are adjusted based on the fitness until the preset output conditions are met, and the adjusted test cases are output.

根据本发明的另一方面,提供了一种计算设备,该计算设备可以是服务器,其内部结构图请参照图5所示。该计算设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算设备的处理器用于提供计算和控制能力。该计算设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算设备程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算设备程序的运行提供环境。该计算设备的数据库用于存储数据。该计算设备的网络接口用于与外部的终端通过网络连接通信。该计算设备程序被处理器执行时实现以上所述的测试用例生成方法,具体来说,所述测试用例生成方法包括以下步骤:According to another aspect of the present invention, a computing device is provided, which may be a server, and its internal structure diagram is shown in FIG. 5 . The computing device includes a processor, memory, network interface, and database connected by a system bus. Wherein, the processor of the computing device is used to provide computing and control capabilities. The memory of the computing device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computing device program, and a database. The internal memory provides an environment for the operation of the operating system and computing device programs in the non-volatile storage medium. The computing device's database is used to store data. The network interface of the computing device is used to communicate with external terminals via a network connection. When the computing device program is executed by the processor, the test case generation method described above is realized. Specifically, the test case generation method includes the following steps:

对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Analyzing the code to be tested to use combinational logic as a target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point;

构建遗传算法的种群,其中,种群中的每个个体均为所述待测试代码的初始测试用例;Constructing a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Performing node interception on the conditional tree to obtain valid nodes, and assigning initial weight values to the valid nodes;

将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform;

根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The individuals of the population are adjusted based on the fitness until the preset output conditions are met, and the adjusted test cases are output.

根据本发明的又一方面,提供了一种计算设备可读存储介质,其上存储有计算设备程序,计算设备程序被处理器执行时实现以上所述的测试用例生成方法,具体来说,包括执行以下步骤:According to yet another aspect of the present invention, a computing device readable storage medium is provided, on which a computing device program is stored, and when the computing device program is executed by a processor, the method for generating test cases described above is implemented, specifically, including Perform the following steps:

对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Analyzing the code to be tested to use combinational logic as a target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point;

构建遗传算法的种群,其中,种群中的每个个体均为所述待测试代码的初始测试用例;Constructing a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested;

对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Performing node interception on the conditional tree to obtain valid nodes, and assigning initial weight values to the valid nodes;

将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform;

根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value;

根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform;

基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The individuals of the population are adjusted based on the fitness until the preset output conditions are met, and the adjusted test cases are output.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算设备程序来指令相关的硬件来完成,所述的计算设备程序可存储于一非易失性计算设备可读取存储介质中,该计算设备程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink) DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be realized by instructing related hardware through a computing device program, and the computing device program can be stored in a non-volatile computing device. When the program of the computing device is read from the storage medium, it may include the processes of the embodiments of the above-mentioned methods when executed. Wherein, any references to memory, storage, database or other media used in the various embodiments provided in the present application may include non-volatile and/or volatile memory. Nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. To make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be It is considered to be within the range described in this specification.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several implementation modes of the present application, and the description thereof is relatively specific and detailed, but it should not be construed as limiting the scope of the patent for the invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the scope of protection of the patent application should be based on the appended claims.

Claims (21)

1.一种测试用例生成方法,其特征在于,所述测试用例生成方法包括:1. A test case generation method is characterized in that, the test case generation method comprises: 对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;Analyzing the code to be tested to use combinational logic as a target condition coverage test point, and using preset rules to generate a condition tree for the target condition coverage test point; 构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;Construct a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested; 对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;Performing node interception on the conditional tree to obtain valid nodes, and assigning initial weight values to the valid nodes; 将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;Using the individuals of the population as the input of the code to be tested, and running the code to be tested on the verification platform; 根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;updating the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value; 根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;calculating the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform; 基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。The individuals of the population are adjusted based on the fitness until the preset output conditions are met, and the adjusted test cases are output. 2.根据权利要求1所述的测试用例生成方法,其特征在于,所述预设规则包括以下至少一种:2. The test case generation method according to claim 1, wherein the preset rules include at least one of the following: 将所述目标条件覆盖测试点对应的组合逻辑作为根节点;Taking the combined logic corresponding to the target condition coverage test point as the root node; 基于预设子项分割规则对组合逻辑进行子项分割,以将组合逻辑本身作为父节点、将父节点组合逻辑的子项作为子节点;Carry out sub-item segmentation for the combination logic based on preset sub-item segmentation rules, so that the combination logic itself is used as a parent node, and the sub-items of the combination logic of the parent node are used as child nodes; 对于分支条件,将引起本节点变量变化的分支列为子节点;For branch conditions, the branch that causes the variable change of this node is listed as a child node; 当节点为代码输入参数、代码不可见组件的输出或节点变量的值变化与其他变量均不存在逻辑关系时,则节点为叶节点不再分解;When the node is a code input parameter, the output of a code invisible component, or the value change of a node variable has no logical relationship with other variables, the node is a leaf node and will not be decomposed; 将每个节点到达根节点所经过的最少节点数作为节点的层号。The minimum number of nodes passed by each node to reach the root node is taken as the layer number of the node. 3.根据权利要求2所述的测试用例生成方法,其特征在于,所述预设子项分割规则包括以下至少一种:3. The test case generation method according to claim 2, wherein the preset sub-item segmentation rules include at least one of the following: 分割规则一、对逻辑运算符进行转换以得到仅包括与关系、或关系的组合逻辑;Segmentation rule 1. Convert logical operators to obtain combinational logic including only AND relation or OR relation; 分割规则二、将与关系、或关系的优先级设定为遵循所述待测试代码的设计语言规则;Segmentation rule 2, setting the priority of the AND relationship, or the relationship, to follow the design language rules of the code to be tested; 分割规则三、子项间仅存在单一形式逻辑关系,每个子项对应一个子节点;Segmentation rule 3. There is only a single form of logical relationship between sub-items, and each sub-item corresponds to a sub-node; 分割规则四、进行子项分解前需要根据逻辑运算规则对组合逻辑进行化简以保证每项内不包含逻辑运算符;Segmentation rule 4. Before decomposing sub-items, it is necessary to simplify the combination logic according to the logical operation rules to ensure that each item does not contain logical operators; 分割规则五、对于根节点逻辑关系式经过分割规则一、分割规则二、分割规则四转换后将或关系均改为与关系;Segmentation rule 5. For the logical relationship of the root node, after conversion by segmentation rule 1, segmentation rule 2, and segmentation rule 4, the OR relationship is changed to an AND relationship; 分割规则六、若化简后的逻辑关系式中既含有或关系又含有与关系,则先分解出低优先级逻辑关系的子节点,再从产生的子节点中分解出高优先级的子节点。Segmentation rule 6. If the simplified logical relation contains both an OR relation and an AND relation, first decompose the sub-nodes of the low-priority logical relation, and then decompose the high-priority sub-nodes from the generated sub-nodes . 4.根据权利要求3所述的测试用例生成方法,其特征在于,所述预设输出条件包括当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点、当前种群迭代次数达到预设迭代次数。4. The test case generation method according to claim 3, wherein the preset output conditions include that there is a certain individual test in the current population that can cover the target condition coverage test point, and the number of iterations of the current population reaches the preset number of iterations. 5.根据权利要求4所述的测试用例生成方法,其特征在于,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,包括:5. The test case generation method according to claim 4, wherein the step of adjusting the individual of the population based on the fitness until the preset output condition is met, the step of outputting the adjusted test case includes : 响应当前种群中存在某个个体测试能够覆盖所述目标条件覆盖测试点或当前种群迭代次数达到预设迭代次数,则停止迭代并输出所述某个个体对应的测试用例或达到预设迭代次数时种群中个体对应的测试用例。In response to the presence of an individual test in the current population that can cover the target condition coverage test point or the number of iterations in the current population reaches the preset number of iterations, then stop the iteration and output the test case corresponding to the individual or when the preset number of iterations is reached The test cases corresponding to the individuals in the population. 6.根据权利要求4所述的测试用例生成方法,其特征在于,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,还包括:6. test case generating method according to claim 4, is characterized in that, described based on described fitness, the step of outputting the adjusted test case when the individual of described population is adjusted until satisfying preset output condition, also include: 响应当前种群中的个体测试均不能覆盖所述目标条件覆盖测试点且当前种群迭代次数未达到预设迭代次数,则基于所述适应度对当前种群中的个体进行种群改变操作以生成下代种群。In response to the fact that none of the individual tests in the current population can cover the target condition coverage test point and the number of iterations of the current population does not reach the preset number of iterations, the population change operation is performed on the individuals in the current population based on the fitness to generate the next generation population . 7.根据权利要求6所述的测试用例生成方法,其特征在于,所述基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例的步骤,还包括:7. test case generating method according to claim 6, is characterized in that, the step of outputting the adjusted test case when the individual of described population is adjusted until satisfying preset output condition based on described fitness, also include: 响应于生成下代种群,则返回执行所述将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码的步骤。In response to generating the next-generation population, return to the step of using the individuals of the population as the input of the code to be tested and running the code to be tested on the verification platform. 8.根据权利要求7所述的测试用例生成方法,其特征在于,所述种群改变操作包括选择、交叉和变异操作中的至少一种。8. The test case generation method according to claim 7, wherein the population change operation includes at least one of selection, crossover and mutation operations. 9.根据权利要求7所述的测试用例生成方法,其特征在于,所述对所述条件树进行节点截取以得到有效节点的步骤,包括:9. test case generation method according to claim 7, is characterized in that, described conditional tree is carried out node interception to obtain the step of valid node, comprising: 从生成的条件树中选择节点层号小于等于预设截取节点层数的所有节点作为有效节点。Select all nodes whose node layer number is less than or equal to the preset intercepted node layer number from the generated condition tree as valid nodes. 10.根据权利要求7所述的测试用例生成方法,其特征在于,所述为所述有效节点赋予初始权重值的步骤,包括:10. test case generating method according to claim 7, is characterized in that, described step of giving initial weight value for described effective node, comprises: 根据下述公式一为每个有效节点赋予初始权重值:Assign an initial weight value to each valid node according to the following formula 1:
Figure QLYQS_1
公式一;
Figure QLYQS_1
formula one;
其中,
Figure QLYQS_3
表示节点的层号,/>
Figure QLYQS_5
表示节点在层中的索引号,/>
Figure QLYQS_7
表示预设截取节点层数,/>
Figure QLYQS_2
表示第/>
Figure QLYQS_6
层中的节点总数,/>
Figure QLYQS_8
表示逻辑属性系对应的值,/>
Figure QLYQS_10
表示第/>
Figure QLYQS_4
层、第/>
Figure QLYQS_9
个节点的初始权重值。
in,
Figure QLYQS_3
Indicates the layer number of the node, />
Figure QLYQS_5
Indicates the index number of the node in the layer, />
Figure QLYQS_7
Indicates the number of preset interception node layers, />
Figure QLYQS_2
Indicates the first />
Figure QLYQS_6
the total number of nodes in the layer, />
Figure QLYQS_8
Indicates the value corresponding to the logical attribute system, />
Figure QLYQS_10
Indicates the first />
Figure QLYQS_4
Layer, No. />
Figure QLYQS_9
The initial weight value of each node.
11.根据权利要求10所述的测试用例生成方法,其特征在于,逻辑属性系对应的值取值规则如下:11. The test case generation method according to claim 10, characterized in that, the value rules corresponding to the logic attribute are as follows: 若节点的逻辑属性为“与”,则
Figure QLYQS_11
If the logical attribute of the node is "and", then
Figure QLYQS_11
;
若节点的逻辑属性为“或”,则
Figure QLYQS_12
等于此节点对应的父节点所包括的子节点个数。
If the logical attribute of the node is "or", then
Figure QLYQS_12
Equal to the number of child nodes included in the parent node corresponding to this node.
12.根据权利要求11所述的测试用例生成方法,其特征在于,所述根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值的步骤,包括:12. test case generation method according to claim 11, is characterized in that, described according to the coverage number of times and described initial weight value of the described valid node that collects from described verification platform to the weight value of described valid node Steps for updating to obtain updated weight values include: 根据下述公式二为每个有效节点更新权重值;Update the weight value for each valid node according to the following formula two;
Figure QLYQS_13
公式二;
Figure QLYQS_13
formula two;
其中,
Figure QLYQS_14
表示种群进化的代数且/>
Figure QLYQS_19
大于等于1,/>
Figure QLYQS_21
表示第/>
Figure QLYQS_15
层、第/>
Figure QLYQS_17
个节点在使用第/>
Figure QLYQS_23
代种群进行测试时被覆盖的次数,/>
Figure QLYQS_24
表示种群中个体总数量,/>
Figure QLYQS_16
表示第/>
Figure QLYQS_18
次迭代时第/>
Figure QLYQS_20
层、第/>
Figure QLYQS_22
个节点的更新权重值。
in,
Figure QLYQS_14
represents the algebra of population evolution and />
Figure QLYQS_19
greater than or equal to 1, />
Figure QLYQS_21
Indicates the first />
Figure QLYQS_15
Layer, No. />
Figure QLYQS_17
node is using the />
Figure QLYQS_23
The number of times the generation population is covered when testing, />
Figure QLYQS_24
Indicates the total number of individuals in the population, />
Figure QLYQS_16
Indicates the first />
Figure QLYQS_18
At iteration />
Figure QLYQS_20
Layer, No. />
Figure QLYQS_22
The updated weight value of each node.
13.根据权利要求12所述的测试用例生成方法,其特征在于,所述根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度的步骤,包括:13. test case generation method according to claim 12, is characterized in that, described according to described update weight value and the coverage status of the described effective node that collects from described verification platform, calculate the fitness of individual in the population steps, including: 根据下述公式三计算所述种群中每个个体的适应度;Calculate the fitness of each individual in the population according to the following formula three;
Figure QLYQS_25
公式三;
Figure QLYQS_25
formula three;
其中,
Figure QLYQS_27
表示第/>
Figure QLYQS_30
代种群中,第/>
Figure QLYQS_32
个个体的适应度,/>
Figure QLYQS_28
表示使用第/>
Figure QLYQS_29
代种群的第
Figure QLYQS_31
个个体测试时,第/>
Figure QLYQS_33
层的第/>
Figure QLYQS_26
个节点的覆盖状态对应的值。
in,
Figure QLYQS_27
Indicates the first />
Figure QLYQS_30
In the generation population, the />
Figure QLYQS_32
The fitness of an individual, />
Figure QLYQS_28
Indicates the use of the />
Figure QLYQS_29
generation population
Figure QLYQS_31
When an individual is tested, the first />
Figure QLYQS_33
Layer />
Figure QLYQS_26
The value corresponding to the coverage state of a node.
14.根据权利要求13所述的测试用例生成方法,其特征在于,节点的覆盖状态对应的值取值规则如下:14. The test case generation method according to claim 13, characterized in that, the value value rules corresponding to the coverage state of the node are as follows: 若节点被覆盖则
Figure QLYQS_34
值为1;
If the node is covered then
Figure QLYQS_34
value is 1;
若节点未被覆盖则
Figure QLYQS_35
值为0。
If the node is not covered then
Figure QLYQS_35
The value is 0.
15.根据权利要求1所述的测试用例生成方法,其特征在于,所述待测试代码用于验证DUT。15. The test case generation method according to claim 1, wherein the code to be tested is used to verify the DUT. 16.根据权利要求15所述的测试用例生成方法,其特征在于,所述DUT包括内存芯片、处理器、SoC芯片。16. The test case generation method according to claim 15, wherein the DUT comprises a memory chip, a processor, and a SoC chip. 17.根据权利要求1所述的测试用例生成方法,其特征在于,所述待测试代码的每个测试用例均包括多个输入参数。17. The test case generation method according to claim 1, wherein each test case of the code to be tested includes a plurality of input parameters. 18.一种测试用例生成装置,其特征在于,所述测试用例生成装置包括:18. A test case generating device, characterized in that, the test case generating device comprises: 生成模块,用于对待测试代码进行分析以将组合逻辑作为目标条件覆盖测试点,并使用预设规则为所述目标条件覆盖测试点生成条件树;A generating module, which is used to analyze the code to be tested to cover the test point with combinational logic as the target condition, and use preset rules to generate a condition tree for the target condition coverage test point; 构建模块,用于构建遗传算法的种群,其中,所述种群中的每个个体均为所述待测试代码的初始测试用例;A building block for constructing a population of genetic algorithms, wherein each individual in the population is an initial test case of the code to be tested; 截取模块,用于对所述条件树进行节点截取以得到有效节点,并为所述有效节点赋予初始权重值;An intercepting module, configured to perform node interception on the conditional tree to obtain valid nodes, and assign initial weight values to the valid nodes; 运行模块,用于将所述种群的个体作为待测试代码的输入,并在验证平台运行所述待测试代码;An operation module, configured to use the individual of the population as the input of the code to be tested, and run the code to be tested on the verification platform; 更新模块,用于根据从所述验证平台收集的所述有效节点的覆盖次数和所述初始权重值对所述有效节点的权重值进行更新以得到更新权重值;An update module, configured to update the weight value of the valid node according to the coverage times of the valid node collected from the verification platform and the initial weight value to obtain an updated weight value; 计算模块,用于根据所述更新权重值和从所述验证平台收集的所述有效节点的覆盖状态计算所述种群中个体的适应度;A calculation module, configured to calculate the fitness of individuals in the population according to the update weight value and the coverage status of the valid nodes collected from the verification platform; 输出模块,用于基于所述适应度对所述种群的个体进行调整直至满足预设输出条件时输出调整后的测试用例。An output module, configured to adjust the individuals of the population based on the fitness until a preset output condition is met and output an adjusted test case. 19.一种代码测试方法,其特征在于,所述代码测试方法采用权利要求1-17任意一项所述的测试用例生成方法输出的测试用例对代码执行测试。19. A code testing method, characterized in that the code testing method uses the test case output by the test case generation method according to any one of claims 1-17 to execute the test on the code. 20. 一种计算设备,其特征在于,包括:20. A computing device, comprising: 至少一个处理器;以及at least one processor; and 存储器,所述存储器存储有可在所述处理器中运行的计算设备程序,所述处理器执行所述程序时执行权利要求1-17任意一项所述测试用例生成方法。A memory, the memory stores a computing device program that can run in the processor, and the processor executes the test case generation method described in any one of claims 1-17 when executing the program. 21.一种计算设备可读存储介质,所述计算设备可读存储介质存储有计算设备程序,其特征在于,所述计算设备程序被处理器执行时执行权利要求1-17任意一项所述测试用例生成方法。21. A computing device-readable storage medium, the computing device-readable storage medium stores a computing device program, characterized in that, when the computing device program is executed by a processor, it executes any one of claims 1-17. Test case generation method.
CN202310473155.6A 2023-04-27 2023-04-27 Test case generation method, device, code test method, equipment and medium Active CN116204445B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310473155.6A CN116204445B (en) 2023-04-27 2023-04-27 Test case generation method, device, code test method, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310473155.6A CN116204445B (en) 2023-04-27 2023-04-27 Test case generation method, device, code test method, equipment and medium

Publications (2)

Publication Number Publication Date
CN116204445A true CN116204445A (en) 2023-06-02
CN116204445B CN116204445B (en) 2023-07-21

Family

ID=86507978

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310473155.6A Active CN116204445B (en) 2023-04-27 2023-04-27 Test case generation method, device, code test method, equipment and medium

Country Status (1)

Country Link
CN (1) CN116204445B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909934A (en) * 2023-09-13 2023-10-20 深圳鸿芯微纳技术有限公司 Command test method, device, equipment and medium of electronic automation design software
CN117194275A (en) * 2023-11-03 2023-12-08 吉贝克信息技术(北京)有限公司 Automatic software automatic test plan generation method and system based on intelligent algorithm
CN117632770A (en) * 2024-01-25 2024-03-01 江西财经大学 A multi-path coverage test case generation method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5805795A (en) * 1996-01-05 1998-09-08 Sun Microsystems, Inc. Method and computer program product for generating a computer program product test that includes an optimized set of computer program product test cases, and method for selecting same
CN112769654A (en) * 2021-01-21 2021-05-07 国网河南省电力公司电力科学研究院 Modbus TCP protocol fuzzy test method based on genetic algorithm
CN115248769A (en) * 2021-04-27 2022-10-28 中移(苏州)软件技术有限公司 A test case optimization method, device, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5805795A (en) * 1996-01-05 1998-09-08 Sun Microsystems, Inc. Method and computer program product for generating a computer program product test that includes an optimized set of computer program product test cases, and method for selecting same
CN112769654A (en) * 2021-01-21 2021-05-07 国网河南省电力公司电力科学研究院 Modbus TCP protocol fuzzy test method based on genetic algorithm
CN115248769A (en) * 2021-04-27 2022-10-28 中移(苏州)软件技术有限公司 A test case optimization method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LUCENT TECHNOLOGIES: "N3-050069 \"IMS SIP profile for ISUP transparency\"", 3GPP TSG_CN\\WG3_INTERWORKING, no. 3 *
李忍;黄树成;祁云嵩;: "用于测试用例最小化的遗传算法", 信息技术, no. 09 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909934A (en) * 2023-09-13 2023-10-20 深圳鸿芯微纳技术有限公司 Command test method, device, equipment and medium of electronic automation design software
CN116909934B (en) * 2023-09-13 2024-01-19 深圳鸿芯微纳技术有限公司 Command test method, device, equipment and medium of electronic automation design software
CN117194275A (en) * 2023-11-03 2023-12-08 吉贝克信息技术(北京)有限公司 Automatic software automatic test plan generation method and system based on intelligent algorithm
CN117194275B (en) * 2023-11-03 2024-01-26 吉贝克信息技术(北京)有限公司 Automatic software automatic test plan generation method and system based on intelligent algorithm
CN117632770A (en) * 2024-01-25 2024-03-01 江西财经大学 A multi-path coverage test case generation method and system
CN117632770B (en) * 2024-01-25 2024-04-19 江西财经大学 A multi-path coverage test case generation method and system

Also Published As

Publication number Publication date
CN116204445B (en) 2023-07-21

Similar Documents

Publication Publication Date Title
CN116204445A (en) Test case generation method, device, code testing method, equipment and medium
CN113609210B (en) Big data visualization processing method based on artificial intelligence and visualization service system
Lam et al. Automated generation of independent paths and test suite optimization using artificial bee colony
CN113285831B (en) Network behavior knowledge intelligent learning method and device, computer equipment and storage medium
CN112540849A (en) Parameter configuration optimization method and system for distributed computing operation
CN110059015A (en) Evolution of Population multiple target priorities of test cases sort method
CN113221500B (en) Automatic chip routing layout design method based on artificial intelligence algorithm
CN107423217B (en) Black box fuzzy test method and system based on variation tree
US20240249008A1 (en) Policy consistency verification apparatus, policy consistency verification method, and policy consistency verification program
Kuang et al. HGBO-DSE: Hierarchical GNN and Bayesian optimization based HLS design space exploration
CN114448911B (en) Multi-objective-based industrial communication protocol test case priority ordering method
Zhang et al. Machine Learning-Based Fuzz Testing Techniques: A Survey
CN116956991A (en) Multilayer perceptron model generation method, device, computer equipment and storage medium
Bouchekir et al. Learning-based symbolic assume-guarantee reasoning for Markov decision process by using interval Markov process
CN117560162A (en) Network security protection method, device, storage medium and apparatus
Pagnozzi et al. Evaluating the impact of grammar complexity in automatic algorithm design
Guerrero et al. On the use of fuzzy preorders and asymmetric distances for multi-robot communication
Makkar et al. Optimization of software quality attributes using evolutionary algorithm
Yan et al. Research on Intelligent Scheduling Algorithm Based on Cloud Computing
CN112380771A (en) Soil erosion assessment method and device and server
CN118316753B (en) Method for testing wireless performance of smart home under real electromagnetic environment
CN118170691A (en) A software regression testing method and device based on finite state machine model
Millard et al. Searching for pareto-optimal randomised algorithms
Hardegen Improving Network Management Tasks using Machine Learning-Assisted Traffic Engineering in Programmable Network Architectures
Jiang et al. AL-SMC: Optimizing Statistical Model Checking by Automatic Abstraction and Learning.

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