CN111723008A - Test path generation method based on state transition diagram - Google Patents

Test path generation method based on state transition diagram Download PDF

Info

Publication number
CN111723008A
CN111723008A CN202010471820.4A CN202010471820A CN111723008A CN 111723008 A CN111723008 A CN 111723008A CN 202010471820 A CN202010471820 A CN 202010471820A CN 111723008 A CN111723008 A CN 111723008A
Authority
CN
China
Prior art keywords
path
state
test
test path
state transition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010471820.4A
Other languages
Chinese (zh)
Inventor
董冬梅
方蕴宇
康凯
贾金艳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Research Institute of Mechanical and Electrical Technology
Original Assignee
Beijing Research Institute of Mechanical and Electrical Technology
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 Beijing Research Institute of Mechanical and Electrical Technology filed Critical Beijing Research Institute of Mechanical and Electrical Technology
Priority to CN202010471820.4A priority Critical patent/CN111723008A/en
Publication of CN111723008A publication Critical patent/CN111723008A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Abstract

The invention provides a test path generation method based on a state transition diagram, which comprises the following steps: judging whether a coverage state transfer pair is needed; generating a first set of test paths covering each intermediate state without covering state transition pairs; generating a test path covering each transfer and obtaining a second test path set by taking a union set with the first test path set; determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set; under the condition that the state transition pairs need to be covered, generating a fourth test path set covering each state transition pair; and determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set. The invention can solve the technical problems of low efficiency and insufficient coverage of the method for generating the test path in the prior art.

Description

Test path generation method based on state transition diagram
Technical Field
The invention relates to the technical field of software testing, in particular to a test path generation method based on a state transition diagram.
Background
The flight control software runs on the missile-borne computer, mainly completes control on aspects such as guidance, attitude, time sequence and the like of the missile, and is a neural center of a missile-borne flight control system. The safety and reliability requirements of missile-borne flight control software are high, and if the software fails, catastrophic losses can result. As real-time embedded multi-task scheduling management software, the software is large in scale and complex in operating environment, and has the characteristics of strong inter-task coupling, strict time sequence control, time constraint, random event driving and the like. In the test process, a method for forming a state transition diagram by performing state modeling on the flight task state is generally performed, so that the generation of a test case is guided.
At present, in engineering, a testing person generally derives a testing path according to self understanding and experience, and the method is not only tedious and low in efficiency, but also difficult to ensure effective and sufficient coverage of states and paths.
Disclosure of Invention
The invention provides a test path generation method based on a state transition diagram, which can solve the technical problems of low efficiency and insufficient coverage of a test path generation method in the prior art.
According to an aspect of the present invention, a method for generating a test path based on a state transition diagram is provided, the method including:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each intermediate state without covering state transition pairs in the state transition graph;
generating a test path covering each transfer and obtaining a second test path set by taking a union set with the first test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
Preferably, generating the first set of test paths covering each intermediate state comprises:
s11, selecting the intermediate state S to be covered in the state transition diagrama
S12, acquiring the state from the initial state to the intermediate state SaFirst shortest path Pa′;
S13, acquiring the intermediate state SaSecond shortest path to termination statea″;
S14 based on the first shortest path Pa' and second shortest path Pa"obtaining intermediate State SaTest path Pa
S15, judging the intermediate state SaTest path PaRepeating the existing intermediate state test path, if yes, turning to S16, otherwise, turning to S17;
s16, deleting the intermediate state SaTest path PaAnd go to S18;
s17, keeping intermediate state SaTest path PaAnd go to S18;
s18, judging whether all the intermediate states in the state transition diagram are completely covered, if so, turning to S19, otherwise, returning to S11;
s19, the generated test paths covering all intermediate states are used as a first test path set.
Preferably, generating the test path covering each transition and merging the test path with the first test path set to obtain the second test path set includes:
s21, selecting the transition C needing to be covered in the state transition diagrambTransfer of CbFrom the c-th intermediate state ScTo d-th intermediate state SdThe transfer of (2);
s22, obtainingThe initial state reaches the c-th intermediate state ScFirst shortest path Pb′;
S23, acquiring the d-th intermediate state SdSecond shortest path to termination stateb″;
S24 based on the first shortest path Pb' and second shortest path Pb"obtaining transfer CbTest path Pb
S25, judging transition CbTest path PbRepeating with the first set of test paths, if yes, proceeding to S26, otherwise, proceeding to S27;
s26, delete transition CbTest path PbAnd go to S28;
s27, transfer CbTest path PbUpdating the first test path set to obtain an updated first test path set, and turning to S28;
s28, judging whether all transitions in the state transition diagram are covered completely, if so, turning to S29, otherwise, returning to S21;
and S29, collecting and collecting the generated test paths covering all the transitions and the first test path set to obtain a second test path set.
Preferably, determining the number of cycles of the first cycle sub-path, generating a test path covering each first cycle sub-path, and obtaining a third test path set by taking a union of the test path and the second test path set includes:
s31, selecting the first circulation sub-path to be covered in the state transition diagram (S)k,...,Sl) And determining the preset cycle times;
s32, acquiring the state from the initial state to the k intermediate state SkFirst shortest path Pk
S33, acquiring the I intermediate state SlSecond shortest path to termination statel
S34 based on the first shortest path PkAnd the second shortest path PlAcquiring a first cyclic sub-path (S)k,...,Sl) Test path Pk+l
S35, judging the first circulation sub-path (S)k,...,Sl) Test path Pk+lRepeating with the second set of test paths, if yes, proceeding to S36, otherwise, proceeding to S37;
s36, deleting the first circulation sub path (S)k,...,Sl) Test path Pk+lAnd go to S38;
s37, using the first circulation sub-path (S)k,...,Sl) Test path Pk+lUpdating the second test path set to obtain an updated second test path set, and turning to S38;
s38, judging whether all the first circulation sub paths in the state transition diagram are completely covered, if so, turning to S39, otherwise, returning to S31;
and S39, collecting and collecting the generated test paths covering all the first circulation sub-paths and the second test path set to obtain a third test path set.
Preferably, generating the fourth set of test paths covering each state transition pair comprises:
s41, determining the highest order number N of the state transition pair to be covered in the state transition diagram;
s42, setting the order n of the state transition pair as 1;
s43, selecting the state transition pair to be covered in the state transition diagram (S)i,...,Sj);
S44, acquiring the state from the initial state to the ith intermediate state SiFirst shortest path Pi
S45, acquiring the j intermediate state SjSecond shortest path to termination statej
S46 based on the first shortest path PiAnd the second shortest path PjObtaining a state transition pair (S)i,...,Sj) Test path Pi+j
S47, judging the state transition pair (S)i,...,Sj) Test path Pi+jRepeating the test path with the existing state transition, if yes, going to S48, otherwise, going to S49;
s48, delete state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s49, reserving state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s410, judging whether the coverage of the n-order state transfer pair is finished, if so, turning to S411, otherwise, returning to S43;
s411, adding 1 to the order n of the state transition pair;
s412, judging whether the order N of the current state switching pair is greater than the highest order N, if so, switching to S413, otherwise, returning to S43;
s413, taking all generated test paths covering the first order to the N order as a fourth test path set;
wherein N is more than or equal to 1 and is an integer, and the N-order state switching pair consists of N +1 intermediate states and N transitions.
Preferably, determining the number of times of the second cyclic sub-paths, generating a test path covering each second cyclic sub-path, and obtaining a fifth test path set by taking a union set of the test paths and the fourth test path set includes:
s51, selecting a second circulation sub-path to be covered in the state transition diagram (S)s,...,St) And determining the preset cycle times;
s52, acquiring the state from the initial state to the S intermediate state SsFirst shortest path Ps
S53, acquiring the t intermediate state StSecond shortest path to termination statet
S54 based on the first shortest path PsAnd the second shortest path PtAcquiring a second cyclic sub-path (S)s,...,St) Test path Ps+t
S55, judging the second circulation sub path (S)s,...,St) Test path Ps+tRepeating with the fourth set of test paths, if yes, proceeding to S56, otherwise, proceeding to S57;
s56, deleting the second circulation sub path (S)s,...,St) Test path Ps+tAnd go to S58;
s57, using the second circulation sub-path (S)s,...,St) Test path Ps+tUpdating the fourth test path set to obtain an updated fourth test path set, and turning to S58;
s58, judging whether all the second circulation sub paths in the state transition diagram are completely covered, if so, turning to S59, otherwise, returning to S51;
and S59, collecting and collecting the generated test paths covering all the second circulation sub-paths and the fourth test path set to obtain a fifth test path set.
According to another aspect of the present invention, there is provided a test path generation method based on a state transition diagram, the method including:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each transition without covering the state transition pairs in the state transition graph;
generating a test path covering each intermediate state and taking a union set with the first test path set to obtain a second test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
By applying the technical scheme of the invention, under the condition that the state transition pair in the state transition diagram is not required to be covered, all the test path sets are generated through the intermediate state covering, the transition covering and the circulation sub-path covering, and under the condition that the state transition pair in the state transition diagram is required to be covered, all the test path sets are generated through the state transition pair covering and the circulation sub-path covering, so that the requirement of the sufficiency coverage of the test requirement of the flight control software is met, and the effectiveness of the software test is improved. The invention can help the tester to generate an effective test path in the test process, thereby guiding the high-efficiency generation of the test case.
Drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a flowchart illustrating a test path generation method based on a state transition diagram according to an embodiment of the present invention;
FIG. 2 illustrates a flow diagram for overlaying an intermediate state provided in accordance with a specific embodiment of the present invention;
FIG. 3 illustrates a flow diagram of an overlay transfer provided in accordance with a specific embodiment of the present invention;
FIG. 4 illustrates a flow diagram provided in accordance with a specific embodiment of the present invention covering a first loop sub-path;
FIG. 5 illustrates a flow diagram of an overlay state transition pair provided in accordance with a specific embodiment of the present invention;
FIG. 6 illustrates a flow diagram provided in accordance with a specific embodiment of the present invention covering a second loop sub-path;
fig. 7 illustrates an airplane control software state transition diagram provided according to a specific embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments according to the present application. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, and it should be understood that when the terms "comprises" and/or "comprising" are used in this specification, they specify the presence of stated features, steps, operations, devices, components, and/or combinations thereof, unless the context clearly indicates otherwise.
The relative arrangement of the components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise. Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description. Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate. In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
Fig. 1 is a flowchart illustrating a test path generation method based on a state transition diagram according to an embodiment of the present invention. As shown in fig. 1, the present invention provides a test path generating method based on a state transition diagram, including:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each intermediate state without covering state transition pairs in the state transition graph;
generating a test path covering each transfer and obtaining a second test path set by taking a union set with the first test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
By applying the technical scheme of the invention, under the condition that the state transition pair in the state transition diagram is not required to be covered, all the test path sets are generated through the intermediate state covering, the transition covering and the circulation sub-path covering, and under the condition that the state transition pair in the state transition diagram is required to be covered, all the test path sets are generated through the state transition pair covering and the circulation sub-path covering, so that the requirement of the sufficiency coverage of the test requirement of the flight control software is met, and the effectiveness of the software test is improved. The invention can help the tester to generate an effective test path in the test process, thereby guiding the high-efficiency generation of the test case.
To facilitate understanding of the present invention, the state transition diagram, the n-order state transition pairs and the test paths are now represented in a set form, as follows:
a state transition diagram is denoted by SD (S, Λ, E), where S is the set of start states, E is the set of end states, Λ is ∑Λi=∑(Si,Ci,Si+1) Is a collection of intermediate states and transitions, SiIs an intermediate state, Si+1Is another intermediate state, CiIs a condition for making a transition between two adjacent intermediate states, i.e. a transition.
By Tn=((Sm,Cm,Sm+1),...,(Sm+i,Cm+i,Sm+i+1),...,(Sm+n,Cm+n,Sm+n+1) Represents an n-order state transition pair, wherein Sm、Sm+1、Sm+i、Sm+i+1、Sm+n、Sm+n+1Are all in an intermediate state, Cm、Cm+i、Cm+nAre all transitions, the n-order state transition pair TnThe n +1 intermediate states and n transitions involved are taken as a whole.
With P being ∑Λi=((Sp,Cp,Sp+1),…,(Si,Ci,Si+1),…,(Sq-1,Cq-1,Sq) From an initial state S)pTo a termination state SqOne path of (2), Num (Λ)i) Is the length of path P. Wherein, if satisfy
Figure BDA0002514522080000101
Has Sr1≠Sr2If yes, the path P is said to be a path not including the cyclic sub-path; if it satisfies
Figure BDA0002514522080000102
Sr1=Sr2If so, the path P is called a test path including a cyclic sub-path; if Pr=((Sr1,Cr1,Sr1+1),…,(Si,Ci,Si+1),…,(Sr2-1,Cr2,Sr2) ∈ P, with and only with Sr1=Sr2Then P isrIs a cyclic sub-path.
FIG. 2 illustrates a flow diagram for overlaying intermediate states provided in accordance with a specific embodiment of the present invention. According to an embodiment of the invention, as shown in FIG. 2, generating the first set of test paths to cover each of the intermediate states comprises:
s11, selecting the intermediate state S to be covered in the state transition diagrama
S12, acquiring the state from the initial state to the intermediate state SaFirst shortest path Pa′;
S13, acquiring the intermediate state SaSecond shortest path to termination statea″;
S14 based on the first shortest path Pa' and second shortest path Pa"obtaining intermediate State SaTest path Pa
S15, judging the intermediate state SaTest path PaRepeating the existing intermediate state test path, if yes, turning to S16, otherwise, turning to S17;
s16, deleting the intermediate state SaTest path PaAnd go to S18;
s17, keeping intermediate state SaTest path PaAnd go to S18;
s18, judging whether all the intermediate states in the state transition diagram are completely covered, if so, turning to S19, otherwise, returning to S11;
s19, the generated test paths covering all intermediate states are used as a first test path set.
One or more termination states may be provided, and a case where there are a plurality of termination states will be described below.
For example, in the case of two end states, if the intermediate state S is presentaThe path lengths to the first and second end states are the same, the intermediate state SaThe paths reaching the first termination state and the second termination state are both the second shortest path, and at the moment, two intermediate states S are obtainedaTest path Pa(ii) a If the intermediate state SaIf the path lengths to the first end state and the second end state are different, the intermediate state S is obtainedaThe shorter of the paths to the first end state or the second end state is taken as the second shortest path, and an intermediate state S is obtainedaTest path Pa
In addition, the intermediate state overrides in the manner described above ensure that each state in the state transition diagram is accessed at least once.
FIG. 3 illustrates a flow diagram of an overlay transfer provided in accordance with a specific embodiment of the present invention. According to an embodiment of the present invention, as shown in fig. 3, generating a test path covering each transition and merging with the first test path set to obtain a second test path set includes:
s21, selecting the transition C needing to be covered in the state transition diagrambTransfer of CbFrom the c-th intermediate state ScTo d-th intermediate state SdThe transfer of (2);
s22, acquiring the state from the initial state to the c intermediate state ScFirst shortest path Pb′;
S23, acquiring the d-th intermediate state SdSecond shortest path to termination stateb″;
S24 based on the first shortest path Pb' and second shortest path Pb"obtaining transfer CbTest path Pb
S25, judging transition CbTest path PbRepeating with the first set of test paths, if yes, proceeding to S26, otherwise, proceeding to S27;
s26, delete transition CbTest path PbAnd go to S28;
s27, transfer CbTest path PbUpdating the first test path set to obtain an updated first test path set, and turning to S28;
s28, judging whether all transitions in the state transition diagram are covered completely, if so, turning to S29, otherwise, returning to S21;
and S29, collecting and collecting the generated test paths covering all the transitions and the first test path set to obtain a second test path set.
The transition coverage is carried out in the above mode, and each transition in the state transition diagram can be ensured to be activated at least once.
Fig. 4 illustrates a flow diagram of an overlay loop sub-path provided in accordance with a specific embodiment of the present invention. According to an embodiment of the present invention, as shown in fig. 4, determining the number of cycles of the first cycle sub-path, generating a test path covering each first cycle sub-path, and merging the test path with the second test path set to obtain a third test path set includes:
s31, selecting the first circulation sub-path to be covered in the state transition diagram (S)k,...,Sl) And determining the preset cycle times;
s32, acquiring the state from the initial state to the k intermediate state SkFirst shortest path Pk
S33, acquiring the I intermediate state SlSecond shortest path to termination statel
S34 based on the first shortest path PkAnd the second shortest path PlAcquiring a first cyclic sub-path (S)k,...,Sl) Test path Pk+l
S35, judging the first circulation sub-path (S)k,...,Sl) Test path Pk+lRepeating with the second set of test paths, if yes, proceeding to S36, otherwise, proceeding to S37;
s36, deleting the first circulation sub path (S)k,...,Sl) Test path Pk+lAnd go to S38;
s37, using the first circulation sub-path (S)k,...,Sl) Test path Pk+lUpdating the second test path set to obtain an updated second test path set, and turning to S38;
s38, judging whether all the first circulation sub paths in the state transition diagram are completely covered, if so, turning to S39, otherwise, returning to S31;
and S39, collecting and collecting the generated test paths covering all the first circulation sub-paths and the second test path set to obtain a third test path set.
The method is adopted for covering the circulation sub-paths, so that each circulation sub-path in the state transition diagram can be repeatedly executed for M times, and the value of M is determined according to the measured object.
Fig. 5 illustrates a flow diagram of an overlay state transition pair provided in accordance with a specific embodiment of the present invention. According to an embodiment of the invention, as shown in FIG. 5, generating a fourth set of test paths covering each state transition pair comprises:
s41, determining the highest order number N of the state transition pair to be covered in the state transition diagram;
s42, setting the order n of the state transition pair as 1;
s43, selecting the state transition pair to be covered in the state transition diagram (S)i,...,Sj);
S44, acquiring the state from the initial state to the ith intermediate state SiFirst shortest path Pi
S45, acquiring the j intermediate state SjSecond shortest path to termination statej
S46 based on the first shortest path PiAnd the second shortest path PjObtaining a state transition pair (S)i,...,Sj) Test path Pi+j
S47, judging the state transition pair (S)i,...,Sj) Test path Pi+jRepeating the test path with the existing state transition, if yes, going to S48, otherwise, going to S49;
S48、delete state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s49, reserving state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s410, judging whether the coverage of the n-order state transfer pair is finished, if so, turning to S411, otherwise, returning to S43;
s411, adding 1 to the order n of the state transition pair;
s412, judging whether the order N of the current state switching pair is greater than the highest order N, if so, switching to S413, otherwise, returning to S43;
s413, taking all generated test paths covering the first order to the N order as a fourth test path set;
wherein N is more than or equal to 1 and is an integer, and the N-order state switching pair consists of N +1 intermediate states and N transitions.
The state transition pair covering is carried out in the mode, each state transition pair of the previous N orders in the state transition diagram can be ensured to pass through once, and the value of N is determined according to the measured object. A value of 2 will generally suffice for the coverage requirement.
Fig. 6 illustrates a flow chart for covering the second loop sub-path provided in accordance with a specific embodiment of the present invention. According to an embodiment of the present invention, as shown in fig. 6, determining the number of times of the second loop sub-path is looped, generating a test path covering each second loop sub-path, and merging the test path with the fourth test path set to obtain a fifth test path set includes:
s51, selecting a second circulation sub-path to be covered in the state transition diagram (S)s,...,St) And determining the preset cycle times;
s52, acquiring the state from the initial state to the S intermediate state SsFirst shortest path Ps
S53, acquiring the t intermediate state StSecond shortest path to termination statet
S54 based on the first shortest path PsAnd the second shortest path PtObtainingSecond cyclic sub-path (S)s,...,St) Test path Ps+t
S55, judging the second circulation sub path (S)s,...,St) Test path Ps+tRepeating with the fourth set of test paths, if yes, proceeding to S56, otherwise, proceeding to S57;
s56, deleting the second circulation sub path (S)s,...,St) Test path Ps+tAnd go to S58;
s57, using the second circulation sub-path (S)s,...,St) Test path Ps+tUpdating the fourth test path set to obtain an updated fourth test path set, and turning to S58;
s58, judging whether all the second circulation sub paths in the state transition diagram are completely covered, if so, turning to S59, otherwise, returning to S51;
and S59, collecting and collecting the generated test paths covering all the second circulation sub-paths and the fourth test path set to obtain a fifth test path set.
The method is adopted for covering the circulation sub-paths, so that each circulation sub-path in the state transition diagram can be repeatedly executed for M times, and the value of M is determined according to the measured object.
In the present invention, in the case that the state transition pair in the overlay state transition diagram is not required, the above embodiment provides an example of overlay first intermediate state and overlay second transition, and the following provides an embodiment of overlay first intermediate state and overlay second intermediate state, and the method is specifically as follows:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each transition without covering the state transition pairs in the state transition graph;
generating a test path covering each intermediate state and taking a union set with the first test path set to obtain a second test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
In the present invention, when the state transition pair in the state transition diagram is not required to be covered, the intermediate state may be covered after the coverage transition, or the intermediate state may be covered before the coverage transition. When the state transition pair in the overlay state transition diagram is needed, the overlay transition and the overlay intermediate state operation are already included in the process of performing the overlay state transition pair, so that only the overlay state transition pair is required.
Fig. 7 illustrates an airplane control software state transition diagram provided according to a specific embodiment of the present invention.
The present invention will be described in detail below by taking a certain type of flight control software as an example. In the embodiment, 13 states (a0, a1, a2, a., a12) and 24 transitions (1,2,3, a., 24) are defined, it is set that the flight control software state transition diagram needs to cover a state transition pair, the highest order N of the covered state transition pair is 2-order, and the preset number of loop times of the loop sub-path is 1, where a0 is a start state, A3 and a9 are end states, and the rest are intermediate states, the defined 13 states are function states of the flight control software, and the defined 24 transitions are state transitions of the flight control software.
The method of the present invention is adopted to generate the test paths for the flight control software state transition diagram in fig. 7, and 32 test paths are generated in total, as shown in table 1.
TABLE 1 test Path
Figure BDA0002514522080000171
Spatially relative terms, such as "above … …," "above … …," "above … …," "above," and the like, may be used herein for ease of description to describe one device or feature's spatial relationship to another device or feature as illustrated in the figures. It will be understood that the spatially relative terms are intended to encompass different orientations of the device in use or operation in addition to the orientation depicted in the figures. For example, if a device in the figures is turned over, devices described as "above" or "on" other devices or configurations would then be oriented "below" or "under" the other devices or configurations. Thus, the exemplary term "above … …" can include both an orientation of "above … …" and "below … …". The device may be otherwise variously oriented (rotated 90 degrees or at other orientations) and the spatially relative descriptors used herein interpreted accordingly.
It should be noted that the terms "first", "second", and the like are used to define the components, and are only used for convenience of distinguishing the corresponding components, and the terms have no special meanings unless otherwise stated, and therefore, the scope of the present invention should not be construed as being limited.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (7)

1. A test path generation method based on a state transition diagram is characterized by comprising the following steps:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each intermediate state without covering state transition pairs in the state transition graph;
generating a test path covering each transfer and obtaining a second test path set by taking a union set with the first test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
2. The method of claim 1, wherein generating the first set of test paths to cover each intermediate state comprises:
s11, selecting the intermediate state S to be covered in the state transition diagrama
S12, acquiring the state from the initial state to the intermediate state SaFirst shortest path Pa′;
S13, acquiring the intermediate state SaSecond shortest path to termination statea″;
S14 based on the first shortest path Pa' and second shortest path Pa"obtaining intermediate State SaTest path Pa
S15, judging the intermediate state SaTest path PaRepeating the existing intermediate state test path, if yes, turning to S16, otherwise, turning to S17;
s16, deleting the intermediate state SaTest path PaAnd go to S18;
s17, keeping intermediate state SaTest path PaAnd go to S18;
s18, judging whether all the intermediate states in the state transition diagram are completely covered, if so, turning to S19, otherwise, returning to S11;
s19, the generated test paths covering all intermediate states are used as a first test path set.
3. The method of claim 1, wherein generating a test path that covers each transition and merging with the first set of test paths to obtain a second set of test paths comprises:
s21, selecting the transition C needing to be covered in the state transition diagrambTransfer of CbFrom the c-th intermediate state ScTo d-th intermediate state SdThe transfer of (2);
s22, acquiring the state from the initial state to the c intermediate state ScFirst shortest path Pb′;
S23, acquiring the d-th intermediate state SdSecond shortest path to termination stateb″;
S24 based on the first shortest path Pb' and second shortest path Pb"obtaining transfer CbTest path Pb
S25, judging transition CbTest path PbRepeating with the first set of test paths, if yes, proceeding to S26, otherwise, proceeding to S27;
s26, delete transition CbTest path PbAnd go to S28;
s27, transfer CbTest path PbUpdating the first test path set to obtain an updated first test path set, and turning to S28;
s28, judging whether all transitions in the state transition diagram are covered completely, if so, turning to S29, otherwise, returning to S21;
and S29, collecting and collecting the generated test paths covering all the transitions and the first test path set to obtain a second test path set.
4. The method of claim 1, wherein determining a number of cycles for a first cycle sub-path, generating a test path that covers each first cycle sub-path and pooling the test path with a second set of test paths to obtain a third set of test paths comprises:
s31, selecting the first circulation sub-path to be covered in the state transition diagram (S)k,...,Sl) And determining the preset cycle times;
s32, acquiring the state from the initial state to the k intermediate state SkFirst shortest path Pk
S33, acquiring the I intermediate state SlSecond shortest path to termination statel
S34 based on the first shortest path PkAnd the second shortest path PlAcquiring a first cyclic sub-path (S)k,...,Sl) Test path Pk+l
S35, judging the first circulation sub-path (S)k,...,Sl) Test path Pk+lRepeating with the second set of test paths, if yes, proceeding to S36, otherwise, proceeding to S37;
s36, deleting the first circulation sub path (S)k,...,Sl) Test path Pk+lAnd go to S38;
s37, using the first circulation sub-path (S)k,...,Sl) Test path Pk+lUpdating the second test path set to obtain an updated second test path set, and turning to S38;
s38, judging whether all the first circulation sub paths in the state transition diagram are completely covered, if so, turning to S39, otherwise, returning to S31;
and S39, collecting and collecting the generated test paths covering all the first circulation sub-paths and the second test path set to obtain a third test path set.
5. The method of claim 1, wherein generating a fourth set of test paths covering each state transition pair comprises:
s41, determining the highest order number N of the state transition pair to be covered in the state transition diagram;
s42, setting the order n of the state transition pair as 1;
s43, selecting the state transition pair to be covered in the state transition diagram (S)i,...,Sj);
S44, acquiring the state from the initial state to the ith intermediate state SiFirst shortest path Pi
S45, acquiring the j intermediate state SjSecond shortest path to termination statej
S46 based on the first shortest path PiAnd the second shortest path PjObtaining a state transition pair (S)i,...,Sj) Test path Pi+j
S47, judging the state transition pair (S)i,...,Sj) Test path Pi+jRepeating the test path with the existing state transition, if yes, going to S48, otherwise, going to S49;
s48, delete state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s49, reserving state transition pair (S)i,...,Sj) Test path Pi+jAnd go to S410;
s410, judging whether the coverage of the n-order state transfer pair is finished, if so, turning to S411, otherwise, returning to S43;
s411, adding 1 to the order n of the state transition pair;
s412, judging whether the order N of the current state switching pair is greater than the highest order N, if so, switching to S413, otherwise, returning to S43;
s413, taking all generated test paths covering the first order to the N order as a fourth test path set;
wherein N is more than or equal to 1 and is an integer, and the N-order state switching pair consists of N +1 intermediate states and N transitions.
6. The method of claim 1, wherein determining a number of cycles of the second-cycle sub-paths, generating a test path that covers each of the second-cycle sub-paths and merging with the fourth set of test paths to obtain a fifth set of test paths comprises:
s51, selecting a second circulation sub-path to be covered in the state transition diagram (S)s,...,St) And determining the preset cycle times;
s52, acquiring the state from the initial state to the S intermediate state SsFirst shortest path Ps
S53, acquiring the t intermediate state StSecond shortest path to termination statet
S54 based on the first shortest path PsAnd the second shortest path PtAcquiring a second cyclic sub-path (S)s,...,St) Test path Ps+t
S55, judging the second circulation sub path (S)s,...,St) Test path Ps+tRepeating with the fourth set of test paths, if yes, proceeding to S56, otherwise, proceeding to S57;
s56, deleting the second circulation sub path (S)s,...,St) Test path Ps+tAnd go to S58;
s57, using the second circulation sub-path (S)s,...,St) Test path Ps+tUpdating the fourth test path set to obtain an updated fourth test path set, and turning to S58;
s58, judging whether all the second circulation sub paths in the state transition diagram are completely covered, if so, turning to S59, otherwise, returning to S51;
and S59, collecting and collecting the generated test paths covering all the second circulation sub-paths and the fourth test path set to obtain a fifth test path set.
7. A test path generation method based on a state transition diagram is characterized by comprising the following steps:
judging whether a state transition pair in a state transition diagram needs to be covered or not;
generating a first set of test paths covering each transition without covering the state transition pairs in the state transition graph;
generating a test path covering each intermediate state and taking a union set with the first test path set to obtain a second test path set;
determining the cycle times of the first cycle sub-paths, generating a test path covering each first cycle sub-path, and collecting and combining the test path with the second test path to obtain a third test path set;
under the condition that the state transition pairs in the state transition diagram need to be covered, generating a fourth test path set covering each state transition pair;
determining the cycle times of the second cycle sub-paths, generating a test path covering each second cycle sub-path, and collecting and combining the test path with the fourth test path to obtain a fifth test path set;
wherein the state transition diagram comprises a start state, at least one intermediate state and at least one end state, the start state and each intermediate state having a transition to a certain end state, the state transition pair consisting of any two or more transferable intermediate states and transitions between transferable intermediate states.
CN202010471820.4A 2020-05-29 2020-05-29 Test path generation method based on state transition diagram Pending CN111723008A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010471820.4A CN111723008A (en) 2020-05-29 2020-05-29 Test path generation method based on state transition diagram

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010471820.4A CN111723008A (en) 2020-05-29 2020-05-29 Test path generation method based on state transition diagram

Publications (1)

Publication Number Publication Date
CN111723008A true CN111723008A (en) 2020-09-29

Family

ID=72565314

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010471820.4A Pending CN111723008A (en) 2020-05-29 2020-05-29 Test path generation method based on state transition diagram

Country Status (1)

Country Link
CN (1) CN111723008A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010218152A (en) * 2009-03-16 2010-09-30 Toshiba Corp Apparatus and method for generating test case
CN103678138A (en) * 2014-01-03 2014-03-26 北京经纬恒润科技有限公司 Method and device for generating state conversion test samples
US20150205707A1 (en) * 2014-01-23 2015-07-23 Accenture Global Services Limited Test paths generation for a physical system
CN106547695A (en) * 2016-10-26 2017-03-29 中广核工程有限公司 A kind of test system and method for scale software
CN106814730A (en) * 2016-12-14 2017-06-09 中国铁路总公司 Train operation control system security critical software method for generating test case
CN109582558A (en) * 2018-09-06 2019-04-05 杭州电子科技大学 A kind of minimum cost method for generating test case based on EFSM model
CN109919345A (en) * 2017-12-12 2019-06-21 北京京东尚科信息技术有限公司 Picking paths planning method and device
CN110389894A (en) * 2019-05-27 2019-10-29 南京祖母绿智能科技有限公司 The method and apparatus of Test cases technology

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010218152A (en) * 2009-03-16 2010-09-30 Toshiba Corp Apparatus and method for generating test case
CN103678138A (en) * 2014-01-03 2014-03-26 北京经纬恒润科技有限公司 Method and device for generating state conversion test samples
US20150205707A1 (en) * 2014-01-23 2015-07-23 Accenture Global Services Limited Test paths generation for a physical system
CN106547695A (en) * 2016-10-26 2017-03-29 中广核工程有限公司 A kind of test system and method for scale software
CN106814730A (en) * 2016-12-14 2017-06-09 中国铁路总公司 Train operation control system security critical software method for generating test case
CN109919345A (en) * 2017-12-12 2019-06-21 北京京东尚科信息技术有限公司 Picking paths planning method and device
CN109582558A (en) * 2018-09-06 2019-04-05 杭州电子科技大学 A kind of minimum cost method for generating test case based on EFSM model
CN110389894A (en) * 2019-05-27 2019-10-29 南京祖母绿智能科技有限公司 The method and apparatus of Test cases technology

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
ADEPU SRIDHAR: "Model-based test-case generation for Simulink/Stateflow using dependency graph approach", 《2013 3RD IEEE INTERNATIONAL ADVANCE COMPUTING CONFERENCE (IACC)》, 13 March 2013 (2013-03-13), pages 1 - 6 *
SWTBOK: "4.2.4 状态转换测试", pages 1 - 7, Retrieved from the Internet <URL:《https://zhuanlan.zhihu.com/p/61723268 》> *
周薇: "基于状态的类测试研究", 《电脑知识与技术》, 31 December 2014 (2014-12-31), pages 2765 - 2767 *
李莉: "基于状态转换图的测试用例设计方法", 《软件产业与工程》, 29 September 2012 (2012-09-29), pages 45 - 48 *

Similar Documents

Publication Publication Date Title
CN108122032B (en) Neural network model training method, device, chip and system
KR102158683B1 (en) Augmenting neural networks with external memory
CN111406267A (en) Neural architecture search using performance-predictive neural networks
CN112036577B (en) Method and device for applying machine learning based on data form and electronic equipment
US20220237460A1 (en) Electronic device and operation method thereof
CN108734293A (en) Task management system, method and apparatus
CN107038533A (en) A kind of method and system for realizing configurableization workflow examination and approval
JP2013019910A5 (en)
CN108475214A (en) adaptive artificial neural network selection technique
CN108710949A (en) The method and system of template are modeled for creating machine learning
US11468290B2 (en) Information processing apparatus, information processing method, and non-transitory computer-readable storage medium
CN108845930A (en) Interface operation test method and device, storage medium and electronic device
CN108459792A (en) A kind of flow switching method, device and computer equipment
CN110135582A (en) Neural metwork training, image processing method and device, storage medium
CN110209574A (en) A kind of data mining system based on artificial intelligence
CN104794179B (en) A kind of the video fast indexing method and device of knowledge based tree
CN111723008A (en) Test path generation method based on state transition diagram
CN107632762A (en) Mobile terminal and based on mobile terminal picture system of selection and storage medium
CN115167846B (en) Recommendation method of downstream operator, electronic device and computer-readable storage medium
CN111160562A (en) Continuous learning method and device based on meta-learning optimization method
CN110717537A (en) Method and device for training user classification model and executing user classification prediction
CN110070104A (en) A kind of hyper parameter determines method, apparatus and server
US20230086727A1 (en) Method and information processing apparatus that perform transfer learning while suppressing occurrence of catastrophic forgetting
US11526709B2 (en) Information processing apparatus, information processing method, and storage medium for classifying object of interest
CN107784548A (en) Order processing method and apparatus

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