A method and system for automatically generating interlocking test cases
Through UML state machine diagrams and mutation algorithms, interlocking test cases are generated, which solves the problem of test cases being unable to be reused in traditional interlocking simulation tests, improves test efficiency and quality, and realizes the automation and manageability of interlocking tests.
Patent Information
- Application Number
- CN202111506904.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-10
AI Technical Summary
Test cases in traditional interlocking simulation tests cannot be reused, resulting in heavy workload, low efficiency, and high management difficulty. Moreover, test quality depends on personnel experience, and the consistency of test results cannot be guaranteed.
UML state machine diagram is used to establish the characteristic model of the interlocking system, generate a parametric test model, generate test suites through the depth-first algorithm and white-box test logic coverage method, and use the mutation algorithm to calculate the mutation score, and improve the test model to improve test quality.
It realizes the automatic generation of interlocking test cases, reduces test costs, improves test efficiency, solves the problem of difficult management of test quality, and ensures the repeatability and consistency of test results.
Smart Images

Figure CN114153740B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interlocking simulation test, and in particular to an interlocking test case automatic generation method and system. Background Art
[0002] Due to the customized characteristics of interlocking, the interlocking of each station is different, which makes the interlocking test cases unable to be reused. Therefore, the interlocking simulation test faces problems such as large workload, low efficiency, high management difficulty, many unknown safety risks, excessive reliance on personnel experience, and inability to ensure that each interlocking simulation test can achieve the desired effect. Therefore, it is of great significance to develop new interlocking safety verification methods to improve the test efficiency and automation of interlocking.
[0003] At present, interlocking simulation tests are mainly carried out manually, by executing a series of test cases in the interlocking system to check whether the interlocking system operates as expected, so as to find potential defects in the interlocking system. This method currently has the following problems:
[0004] 1. In the interlocking simulation test, the preparation and implementation of test cases are completely completed manually by the test personnel. The preparation of test cases is difficult, and the test workload will increase rapidly with the increase of station scale.
[0005] 2. In the manual test method, the construction of test cases cannot be reproduced, the test case selection criteria of testers are difficult to accurately describe, and the correspondence between test cases and interlocking test specifications cannot be fully reflected. The test quality depends on the skills and level of the testers.
[0006] 3. When problems are found and corrected during testing, regression testing needs to be implemented. At this time, all simulation tests need to be carried out again, which is a huge workload.
[0007] Although the industry is also researching methods for automated interlocking simulation testing, it can currently only automate some simple and repetitive test items and cannot meet the requirements of truly automated testing. Summary of the invention
[0008] One purpose of the present invention is to provide a method and system for automatically generating interlocking test cases, which solves the problem that traditional interlocking tests are not reusable, reduces test costs, and improves test efficiency.
[0009] Another object of the present invention is to provide a method and system for automatically generating interlocking test cases, which solves the problem that test quality is difficult to manage in traditional interlocking simulation tests.
[0010] To achieve the above object, the present invention provides the following solutions:
[0011] A method for automatically generating interlocking test cases, comprising:
[0012] Establish the characteristic model corresponding to each basic functional unit in the interlocking system;
[0013] According to the information of the station to be tested, all the characteristic models are processed by using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each characteristic model;
[0014] Generate a test suite corresponding to each of the parameterized interlocking test models; the test suite includes a plurality of test cases;
[0015] A mutation algorithm is used to calculate the mutation score of each test suite, and the parameterized interlocking test model corresponding to the marked test suite is improved; the marked test suite is a test suite with a mutation score lower than a set threshold.
[0016] Optionally, the establishing of a characteristic model corresponding to each basic functional unit in the interlocking system specifically includes:
[0017] According to the overall function of the interlocking system, the interlocking system is divided to obtain a basic functional unit set; the basic functional unit set includes a plurality of basic functional units, namely, a route selection functional unit, a turnout control functional unit, an interlocking relationship checking functional unit and a route unlocking functional unit;
[0018] According to the interlocking check logic of the basic functional unit, combined with all possible sub-functions involved in the basic functional unit and the logical relationship between the sub-functions, a feature model corresponding to each basic functional unit is established.
[0019] Optionally, the method of processing all the feature models according to the tested station information using a UML state machine diagram to obtain a parameterized interlocking test model corresponding to each feature model specifically includes:
[0020] According to the information of the tested station and the information in the interlocking table, the required functional features are selected from the feature models to construct a functional subset corresponding to each of the feature models;
[0021] Based on the functional subset, a parameterized interlocking test model corresponding to each of the feature models is established using the UML state machine diagram as a modeling language.
[0022] Optionally, generating a test suite corresponding to each parameterized interlocking test model specifically includes:
[0023] A depth-first algorithm and a white-box test logic coverage method are used to process all the parameterized interlocking test models, and a test suite corresponding to each parameterized interlocking test model is generated.
[0024] Optionally, the adopting of a mutation algorithm to calculate a mutation score of each test suite specifically includes:
[0025] Based on the operator set, in combination with the interlocking relationship, interlocking execution and operation elements, a mutation model set is constructed; the operator set includes multiple basic operators, namely, adding state, deleting state, adding migration, deleting migration, changing migration source, changing migration target and changing migration condition; the mutation model set includes adding state mutation model, deleting state mutation model, adding migration mutation model, deleting migration mutation model, changing migration source mutation model, changing migration target mutation model and changing migration condition mutation model;
[0026] Substitute the test suite into the variation model set, and calculate the variation score of each test suite.
[0027] Optionally, substituting the test suite into the variation model set and calculating the variation score of each test suite specifically includes:
[0028] The mutation score of each test case is calculated according to the formula: mutation score S = (number of mutation models found) / (total number of mutation models);
[0029] The sum of the mutation scores of all the test cases in each test suite is calculated to obtain the mutation score of each test suite.
[0030] An interlocking test case automatic generation system, comprising:
[0031] A feature model building module is used to build a feature model corresponding to each basic functional unit in the interlocking system;
[0032] A parameterized interlocking test model determination module is used to process all the feature models according to the tested station information using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each feature model;
[0033] A test suite generation module, used to generate a test suite corresponding to each of the parameterized interlocking test models; the test suite includes a plurality of test cases;
[0034] The evaluation and improvement module is used to use a mutation algorithm to calculate the mutation score of each test suite and improve the parameterized interlocking test model corresponding to the marked test suite; the marked test suite is a test suite with a mutation score lower than a set threshold.
[0035] Optionally, the feature model building module specifically includes:
[0036] A basic function unit establishing unit is used to divide the interlocking system according to the overall function of the interlocking system to obtain a basic function unit set; the basic function unit set includes a plurality of basic function units, namely, an approach selection function unit, a turnout control function unit, an interlocking relationship checking function unit and an approach unlocking function unit;
[0037] The feature model establishment unit is used to establish a feature model corresponding to each basic functional unit according to the interlocking check logic of the basic functional unit, combined with all possible sub-functions involved in the basic functional unit and the logical relationship between the sub-functions.
[0038] Optionally, the parameterized interlocking test model determination module specifically includes:
[0039] A function subset building unit, used to select required function features from the feature model according to the information of the tested station and the information in the interlocking table, so as to build a function subset corresponding to each of the feature models;
[0040] The parameterized interlocking test model establishing unit is used to establish a parameterized interlocking test model corresponding to each of the feature models based on the functional subset and using the UML state machine diagram as a modeling language.
[0041] Optionally, in the aspect of using the mutation algorithm to calculate the mutation score of each test suite, the evaluation improvement module specifically includes:
[0042] A mutation model set construction unit is used to construct a mutation model set based on an operator set in combination with interlocking relationships, interlocking executions and operation elements; the operator set includes a plurality of basic operators, namely, adding a state, deleting a state, adding a migration, deleting a migration, changing a migration source, changing a migration target and changing a migration condition; the mutation model set includes an adding a state mutation model, a deleting a state mutation model, an adding a migration mutation model, a deleting a migration mutation model, a changing a migration source mutation model, a changing a migration target mutation model and a changing a migration condition mutation model;
[0043] The variation score calculation unit is used to substitute the test suite into the variation model set and calculate the variation score of each test suite.
[0044] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0045] The present invention first establishes a feature model corresponding to each basic functional unit in the interlocking system; secondly, according to the information of the station under test, all the feature models are processed using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each feature model; then a test suite corresponding to each parameterized interlocking test model is generated; the test suite includes multiple test cases; the problem that traditional interlocking tests are not reusable is solved, the test cost is reduced, and the test efficiency is improved. Finally, a mutation algorithm is used to calculate the mutation score of each test suite, and the parameterized interlocking test model corresponding to the marked test suite is improved; the marked test suite is a test suite with a mutation score lower than a set threshold, which solves the problem that the test quality is difficult to manage in traditional interlocking simulation tests. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0047] Figure 1 A schematic diagram of a flow chart of an interlocking test case automatic generation method of the present invention;
[0048] Figure 2 It is a schematic diagram of the characteristic model of the route selection functional unit of the present invention;
[0049] Figure 3 It is a schematic diagram of the downlink vehicle access route from the greening aspect to the IG of the present invention;
[0050] Figure 4 A schematic diagram of a state model for the basic route and alternative route of the present invention;
[0051] Figure 5 It is a flow chart of the test scheme of the present invention;
[0052] Figure 6 It is a schematic diagram of the parameterized interlocking test model of the present invention;
[0053] Figure 7 This is a station signal plan layout diagram (partial) of the present invention;
[0054] Figure 8 It is a structural schematic diagram of an interlocking test case automatic generation system of the present invention. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] Aiming at interlocking simulation test, the present invention provides an interlocking test case automatic generation method and system. The present invention uses UML state machine diagram as modeling language, relies on interlocking table and interlocking management to establish test model, automatically generates test cases based on white box test logic coverage methods such as condition coverage, multi-condition coverage, and modified condition judgment coverage, and uses mutation test method to evaluate the quality of test cases.
[0057] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0058] Technical terms:
[0059] UML: Unified Modeling Language, unified modeling language.
[0060] Embodiment 1
[0061] See also Figure 1 , this embodiment provides a method for automatically generating interlocking test cases, including:
[0062] Step 101: Establishing a characteristic model corresponding to each basic functional unit in the interlocking system; specifically including:
[0063] According to the overall function of the interlocking system, the interlocking system is divided to obtain a basic functional unit set; the basic functional unit set includes multiple basic functional units, namely, a route selection functional unit, a switch control functional unit, an interlocking relationship checking functional unit, a route unlocking functional unit, etc.
[0064] According to the interlocking check logic of the basic functional unit, combined with all possible sub-functions involved in the basic functional unit and the logical relationships between the sub-functions, a feature model corresponding to each basic functional unit is established.
[0065] The marked feature model describes in detail all possible sub-functions involved in realizing the basic functional unit corresponding to the marked feature model and the logical relationship between these sub-functions for any station and any route type. The marked feature model is an arbitrary feature model.
[0066] Establishing characteristic models of basic functional units can effectively improve the standardization and reusability of test models.
[0067] For example, the route selection function unit has mandatory functional features such as route selection, signal open status check, track section occupancy status check, switch status check, route locking, route cancellation, etc. Mandatory means that for any route at any station, the above features need to be executed when selecting the route.
[0068] The route selection has two XOR-related sub-function features: selecting the basic route and selecting the alternative route. When selecting the basic route, you need to press the route start button and the route end button in sequence to determine the route range, so pressing the route start button (P-RBB) and pressing the route end button (P-REB) are its mandatory sub-features; when selecting an alternative route, you need to press the route start button and the route end button before and after pressing the alternative button as the start and end of the alternative route.
[0069] The signal open state check has two sub-features: the protection signal state check and the hostile signal state check. The protection signal state check is a mandatory sub-feature, and the hostile signal state check is an optional sub-feature.
[0070] The track section occupancy status check includes the track section occupancy status check inside the approach and the anti-side impact condition check at the over-limit insulation outside the approach. Among them, at the over-limit insulation, the approach may conflict in the lateral position, so the occupancy status of the relative track section should be checked.
[0071] The turnout status check can check the turnouts within the route range, as well as the protective turnouts or driving turnouts outside the route. In order to test the turnout status check characteristics, the test cases should include abnormal states of various turnouts, such as fault, four-open and locked. Each turnout can only appear in one of the states, so there is a mutually exclusive relationship between the states.
[0072] The characteristic model of the route selection function unit in the interlocking system is as follows: Figure 2 The abbreviations used in this feature model are shown in Table 1.
[0073] Table 1 Abbreviations used in feature models
[0074]
[0075]
[0076] In such Figure 3 In the downlink vehicle receiving route from the greening to IG shown in the figure, the features involved in selecting the basic route and the alternative route are shown in Table 2 below.
[0077] Table 2 Functional characteristics when selecting basic routes and alternative routes
[0078]
[0079] Step 102: According to the information of the station to be tested, all the characteristic models are processed using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each characteristic model; specifically, the following steps are included:
[0080] According to the information of the station under test (such as the specific characteristics of the station under test and the approach route), the information in the interlocking table is used to select the required functional features from the feature model to form a functional subset. Then, based on the functional subset, the UML state machine diagram is used as the modeling language to establish a parameterized interlocking test model (or UML basic functional model) corresponding to each of the feature models.
[0081] In the parameterized interlocking test model, the initial state, terminal state and intermediate state of the interlocking are described by the state of the UML state machine diagram, the transfer process of the interlocking state is described by the state transfer of the UML state machine diagram, and the interlocking relationship is described by the state transfer condition of the model combined with the guard condition. The guard condition is a Boolean expression, the variable is obtained from the interlocking table, and the Boolean relationship is determined based on the interlocking relationship; all the specific interlocking execution and operation elements involved (including section name, turnout name, signal machine name, button name, etc.) are represented by parameters in the UML state machine diagram. The implementation method of the specific assignment operation may or may not be used. For example, the modeling tool Papyrus can use the Entry element combined with C language or OCL language to implement variable assignment; the modeling method supported by the model-based testing tool PaTeg is to use state self-migration combined with OCL voice to implement assignment.
[0082] An example: Figure 4 The state model for handling basic and alternative approaches is shown.
[0083] Step 103: Generate a test suite corresponding to each of the parameterized interlocking test models; the test suite includes multiple test cases; specifically includes:
[0084] A depth-first algorithm and a white-box test logic coverage method are used to process all the parameterized interlocking test models, and a test suite corresponding to each parameterized interlocking test model is generated.
[0085] An example is:
[0086] Generate test cases based on the binary tree search algorithm. The termination condition of the algorithm is determined by the selected coverage criterion. The detailed process is as follows:
[0087] The white box test logic coverage methods such as condition coverage, multi-condition coverage, and modified condition determination coverage are used as the test target. A binary tree search algorithm is used to generate a sequence containing states and transitions in the parameterized interlocking test model so that the generated sequence meets the test target. Each sequence is a test case. Each sequence starts from the initial state of the parameterized interlocking test model. The last state in the sequence is the expected result of the test. This step generates a collection of test cases, called a test suite.
[0088] Step 104: using a mutation algorithm to calculate the mutation score of each of the test suites, and improving the parameterized interlocking test model corresponding to the marked test suites; the marked test suites are test suites whose mutation scores are lower than a set threshold.
[0089] The mutation operator is used to perform mutation at the UML model level, and the mutated model is converted into an executable program using the code mapping method as the interlocking software with errors.
[0090] Based on the seven basic operators of adding status, deleting status, adding migration, deleting migration, changing migration source, changing migration target, and changing migration conditions, executable mutation operators are further constructed in combination with specific interlocking relationships and interlocking execution and operation elements.
[0091] The executable program is tested using the test suite generated in step 103 to calculate the mutation score. The calculation formula of the mutation score S is as follows:
[0092] S = (number of variant models found) / (total number of variant models) * 100%
[0093] Each mutation operator generates a mutation model, and the number of all mutation models is called the "total number of mutation models". The mutation model is tested using the test suite. If the output of the model does not meet the expected test results, the test fails. If a failed test case occurs, it is considered that the mutation model can be discovered by the generated test suite, that is, the "discovered mutation model" in the formula.
[0094] The step of using a mutation algorithm to calculate the mutation score of each test suite specifically includes:
[0095] Step A: Based on an operator set, combined with interlocking relationships, interlocking executions and operation elements, a mutation model set is constructed; the operator set includes multiple basic operators, namely, adding state, deleting state, adding migration, deleting migration, changing migration source, changing migration target and changing migration conditions; the mutation model set includes adding state mutation model, deleting state mutation model, adding migration mutation model, deleting migration mutation model, changing migration source mutation model, changing migration target mutation model and changing migration condition mutation model.
[0096] Step B: Substitute the test suite into the variation model set, and calculate the variation score of each test suite.
[0097] An example is: according to the formula: mutation score S = (number of mutation models found) / (total number of mutation models) calculate the mutation score of each test case; calculate the sum of the mutation scores of all the test cases in each test suite, and then obtain the mutation score of each test suite.
[0098] The improvement of the parameterized interlocking test model corresponding to the marking test suite specifically includes:
[0099] Test cases are evaluated based on the mutation score. A high mutation score means good test case quality. If the mutation score is too low, the mutation score can be improved by modifying the parameterized interlocking test model to improve the test case quality. The methods for improving the parameterized interlocking test model mainly include refining the state and migration of the model and refining the description formula of the guard condition.
[0100] Embodiment 2
[0101] This embodiment provides a method for automatically generating interlocking test cases. Figure 5 As shown, including:
[0102] The first step: establishing a characteristic model, and establishing a parameterized interlocking test model based on the characteristic model.
[0103] The feature model described in this embodiment is as follows Figure 2 The characteristic model of the route selection functional unit is shown.
[0104] According to the system under test, using the UML state machine diagram, we can get the following Figure 6 The parameterized interlocking test model shown in the figure shows the logical execution process of selecting the route when the turnout is locked individually. The expected test result is that when the turnouts related to the route are locked individually to a position that does not meet the interlocking relationship, the route is processed and the route where the turnout is located should not be locked.
[0105] Table 3 Status description table
[0106]
[0107] Table 4 State transition description table
[0108]
[0109]
[0110] Step 2: Create an instantiated test model.
[0111] Using the interlocking table, the actual basic interlocking contents such as signal machines, track sections, switches, hostile signals and buttons are combined with the parameterized interlocking test model obtained in the previous step, taking the route as a unit, to obtain an instantiated test model of the test route.
[0112] In such Figure 7 In the local station diagram shown, the downlink vehicle receiving route from the greening area to IG is selected as the test route, and an instantiated test model of the route is obtained.
[0113] Table 5 Interlocking table (part)
[0114]
[0115]
[0116] Step 3: Generate test cases.
[0117] With condition coverage as the test goal, a depth-first algorithm is used to generate a sequence containing states and transitions in the instantiated test model, so that the generated sequence meets the test goal; each sequence is a test case, and the collection of test cases is called a test suite. Table 6 shows the execution process of an executable test case in the test suite.
[0118] Table 6 Test case execution steps
[0119]
[0120] Table 6 describes the values of the external and internal variables of this test case. The variables of the operation object and observation object are named starting with "OP_" and "OB_", respectively.
[0121] Table 7 Variable state values and descriptions
[0122]
[0123]
[0124] Step 4: Evaluate test cases based on the mutation model.
[0125] The test model is mutated using mutation operators, and each mutation operator generates a mutation model. Based on the seven basic operators of adding state, deleting state, adding migration, deleting migration, changing migration source, changing migration target, and changing migration condition, the mutation model is constructed in combination with the interlocking relationship of the route and the logical execution process of selecting the route when the turnout is locked separately. Substitute the test case generated in the previous step into the mutation model and calculate the mutation score S.
[0126] Where: mutation score S = (number of mutation models found) / (total number of mutation models)
[0127] Table 8 Comparison of the mutation model before and after
[0128]
[0129]
[0130] By comparing the mutation scores of executable mutations constructed by different mutation operators under different coverage criteria, it can be seen that the four mutations of adding state, adding migration, changing migration source and changing migration target are easier to be discovered, while the mutation methods of deleting state and deleting migration are the least likely to be discovered, and under the coverage criterion of MCC, the mutation scores are the highest.
[0131] Step 5: Improve the model based on the mutation score.
[0132] A high mutation score means good test case quality; if the mutation score is too low, the quality of the test case can be improved by modifying the model. The main ways to improve the model include refining the state and migration of the model, refining the description formula of the guard condition, etc.
[0133] Embodiment 3
[0134] See also Figure 8 , this embodiment provides an interlocking test case automatic generation system, including:
[0135] The feature model building module 801 is used to build a feature model corresponding to each basic functional unit in the interlocking system.
[0136] The parameterized interlocking test model determination module 802 is used to process all the characteristic models according to the tested station information using the UML state machine diagram to obtain the parameterized interlocking test model corresponding to each characteristic model.
[0137] The test suite generation module 803 is used to generate a test suite corresponding to each parameterized interlocking test model; the test suite includes multiple test cases.
[0138] The evaluation and improvement module 804 is used to use a mutation algorithm to calculate the mutation score of each test suite and improve the parameterized interlocking test model corresponding to the marked test suite; the marked test suite is a test suite with a mutation score lower than a set threshold.
[0139] The feature model building module 801 specifically includes:
[0140] The basic function unit establishment unit is used to divide the interlocking system according to the overall function of the interlocking system to obtain a basic function unit set; the basic function unit set includes multiple basic function units, namely, a route selection function unit, a switch control function unit, an interlocking relationship check function unit and a route unlocking function unit.
[0141] The feature model establishment unit is used to establish a feature model corresponding to each basic functional unit according to the interlocking check logic of the basic functional unit, combined with all possible sub-functions involved in the basic functional unit and the logical relationship between the sub-functions.
[0142] The parameterized interlocking test model determination module 802 specifically includes:
[0143] The function subset building unit is used to select required function features from the feature model according to the information of the tested station and the information in the interlocking table, so as to build a function subset corresponding to each of the feature models.
[0144] The parameterized interlocking test model establishing unit is used to establish a parameterized interlocking test model corresponding to each of the feature models based on the functional subset and using the UML state machine diagram as a modeling language.
[0145] In the aspect of using the mutation algorithm to calculate the mutation score of each test suite, the evaluation improvement module 804 specifically includes:
[0146] A mutation model set construction unit is used to construct a mutation model set based on an operator set in combination with interlocking relationships, interlocking executions and operation elements; the operator set includes multiple basic operators, namely, adding state, deleting state, adding migration, deleting migration, changing migration source, changing migration target and changing migration conditions; the mutation model set includes an adding state mutation model, a deleting state mutation model, an adding migration mutation model, a deleting migration mutation model, a changing migration source mutation model, a changing migration target mutation model and a changing migration condition mutation model.
[0147] The variation score calculation unit is used to substitute the test suite into the variation model set and calculate the variation score of each test suite.
[0148] The present invention solves the problem that traditional interlocking tests are not reusable, reduces testing costs, improves testing efficiency, and can easily prove the satisfiability of tests with test requirements and interlocking relationships. Since the establishment of the parameterized interlocking test model is based on test requirements and interlocking relationships, as long as the parameterized interlocking test model, test requirements and interlocking relationships are consistent, it can be proved that the test satisfies the test requirements and interlocking relationships, and the consistency judgment of the two is relatively easy. At the same time, the establishment of the parameterized interlocking test model relies on the interlocking table, and the modeling is based on the route unit, so that the parameterized interlocking test model can be applied to all stations. The problem of non-reusability of tests caused by different station topological structures in different stations is avoided.
[0149] The present invention provides a method for quantifying test quality and a method for improving the quality of test cases, solving the problem of difficult management of test quality in traditional interlocking simulation tests. Through mutation operators, information such as errors that are prone to occur in interlocking, functions related to safety, and problems that have occurred in history can be expressed in the mutation model. The mutation score quantifies the proportion of problems that can be found through the test suite. By improving the model, the mutation score can be improved, thereby improving the test quality.
[0150] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0151] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for automatically generating interlocking test cases, characterized in that: include: Establish the characteristic model corresponding to each basic functional unit in the interlocking system; The establishment of the characteristic model corresponding to each basic functional unit in the interlocking system specifically includes: According to the overall function of the interlocking system, the interlocking system is divided to obtain a basic functional unit set; the basic functional unit set includes multiple basic functional units, namely, a route selection functional unit, a turnout control functional unit, an interlocking relationship check functional unit and a route unlocking functional unit; according to the interlocking check logic of the basic functional unit, combined with all possible sub-functions involved in the basic functional unit and the logical relationship between the sub-functions, a feature model corresponding to each basic functional unit is established; According to the information of the station to be tested, all the characteristic models are processed by using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each characteristic model; Generate a test suite corresponding to each of the parameterized interlocking test models; the test suite includes a plurality of test cases; A mutation algorithm is used to calculate the mutation score of each test suite, and the parameterized interlocking test model corresponding to the marked test suite is improved; the marked test suite is a test suite with a mutation score lower than a set threshold.
2. The method for automatically generating interlocking test cases according to claim 1, characterized in that: According to the tested station information, all the feature models are processed by using the UML state machine diagram to obtain the parameterized interlocking test model corresponding to each feature model, which specifically includes: According to the information of the tested station and the information in the interlocking table, the required functional features are selected from the feature models to construct a functional subset corresponding to each of the feature models; Based on the functional subset, a parameterized interlocking test model corresponding to each of the feature models is established using the UML state machine diagram as a modeling language.
3. The method for automatically generating interlocking test cases according to claim 1, characterized in that: The generating of a test suite corresponding to each parameterized interlocking test model specifically includes: A depth-first algorithm and a white-box test logic coverage method are used to process all the parameterized interlocking test models, and a test suite corresponding to each parameterized interlocking test model is generated.
4. The method for automatically generating interlocking test cases according to claim 1, characterized in that: The adopting of a mutation algorithm to calculate the mutation score of each test suite specifically includes: Based on the operator set, in combination with the interlocking relationship, interlocking execution and operation elements, a mutation model set is constructed; the operator set includes multiple basic operators, namely, adding state, deleting state, adding migration, deleting migration, changing migration source, changing migration target and changing migration condition; the mutation model set includes adding state mutation model, deleting state mutation model, adding migration mutation model, deleting migration mutation model, changing migration source mutation model, changing migration target mutation model and changing migration condition mutation model; Substitute the test suite into the variation model set, and calculate the variation score of each test suite.
5. The method for automatically generating interlocking test cases according to claim 4, characterized in that: Substituting the test suite into the variation model set and calculating the variation score of each test suite specifically includes: The mutation score of each test case is calculated according to the formula: mutation score S = (number of mutation models found) / (total number of mutation models); The sum of the mutation scores of all the test cases in each test suite is calculated to obtain the mutation score of each test suite.
6. An interlocking test case automatic generation system, characterized in that: include: A feature model building module is used to build a feature model corresponding to each basic functional unit in the interlocking system; The feature model building module specifically includes: A basic function unit establishment unit is used to divide the interlocking system according to the overall function of the interlocking system to obtain a basic function unit set; the basic function unit set includes multiple basic function units, namely, a route selection function unit, a turnout control function unit, an interlocking relationship check function unit and a route unlocking function unit; a feature model establishment unit is used to establish a feature model corresponding to each basic function unit according to the interlocking check logic of the basic function unit, combined with all possible sub-functions involved in the basic function unit and the logical relationship between the sub-functions A parameterized interlocking test model determination module is used to process all the feature models according to the tested station information using the UML state machine diagram to obtain a parameterized interlocking test model corresponding to each feature model; A test suite generation module, used to generate a test suite corresponding to each of the parameterized interlocking test models; the test suite includes a plurality of test cases; The evaluation and improvement module is used to use a mutation algorithm to calculate the mutation score of each test suite and improve the parameterized interlocking test model corresponding to the marked test suite; the marked test suite is a test suite with a mutation score lower than a set threshold.
7. The interlocking test case automatic generation system according to claim 6, characterized in that: The parameterized interlocking test model determination module specifically includes: A function subset building unit, used to select required function features from the feature model according to the information of the tested station and the information in the interlocking table, so as to build a function subset corresponding to each of the feature models; The parameterized interlocking test model establishing unit is used to establish a parameterized interlocking test model corresponding to each of the feature models based on the functional subset and using the UML state machine diagram as a modeling language.
8. The interlocking test case automatic generation system according to claim 6, characterized in that: In the aspect of using the mutation algorithm to calculate the mutation score of each test suite, the evaluation improvement module specifically includes: A mutation model set construction unit is used to construct a mutation model set based on an operator set in combination with interlocking relationships, interlocking executions and operation elements; the operator set includes a plurality of basic operators, namely, adding a state, deleting a state, adding a migration, deleting a migration, changing a migration source, changing a migration target and changing a migration condition; the mutation model set includes an adding a state mutation model, a deleting a state mutation model, an adding a migration mutation model, a deleting a migration mutation model, a changing a migration source mutation model, a changing a migration target mutation model and a changing a migration condition mutation model; The variation score calculation unit is used to substitute the test suite into the variation model set and calculate the variation score of each test suite.
