Time series-based software testing method, system, storage medium and device
By using time series segmentation clustering algorithm and inverse covariance method to perform multi-level clustering for software testing, the problems of complex clustering algorithms and insufficient automated testing in existing technologies are solved, and more efficient and comprehensive software testing is achieved.
Patent Information
- Application Number
- CN202310881355.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-18
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2043-07-18
AI Technical Summary
Existing software testing methods suffer from problems such as complex clustering algorithm architecture, low proportion of automated testing, small test case coverage, high resource consumption, high time consumption, and many repetitive tests.
A time-series segmentation clustering algorithm is used to perform primary and secondary clustering of software tests. Principal component analysis (PCA) is used to reduce feature dimensionality, and the inverse covariance method is used to select and evaluate cluster centers. A mathematical clustering model is constructed to reduce redundant testing and improve the efficiency of automated testing.
It improves the coverage and efficiency of software testing, reduces resource consumption, reduces redundant testing, enhances the efficiency of automated testing, and shortens the testing cycle.
Smart Images

Figure CN116775495B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing, and more particularly to time-series-based software testing methods, systems, storage media, and devices. Background Technology
[0002] With the rapid development of information technology, more and more software is being widely used in fields such as electronics, public transportation, military technology, and the internet IT, greatly improving our quality of life. However, when the number of these software programs reaches a certain level, their quality becomes difficult to guarantee. Thus, software testing has emerged to serve software developers and users. By acquiring data through testing and analyzing the results, it identifies software defects, helping developers fix bugs, improve software quality, and enhance the user experience.
[0003] Traditional software testing methods execute test cases randomly, which can easily lead to the repeated execution of similar test cases, reducing testing efficiency and the effectiveness of defect discovery. Current technologies use clustering algorithms to assist software testing and reduce the testing of repetitive units, but this approach also has drawbacks: 1. Current clustering algorithm architectures are becoming increasingly complex, and traditional software testing techniques struggle to adapt to new requirements, easily leading to missed or false positives. 2. Automated software testing still constitutes a relatively small proportion of the overall software testing in a project; most testing still relies on manual testing, and current clustering research cannot significantly increase the proportion of automated testing. 3. Current clustering research on software testing does not fully reflect the functional modules of test cases in its methods for handling test modules, failing to comprehensively cover the functional requirements to be tested, thus posing potential risks to product quality and safety.
[0004] To address the aforementioned issues, clustering mathematically processed software functional module data has been applied across various industries. Researchers can extract valuable information from these complex and large-scale datasets using clustering models. Clustering is used for regression analysis of test cases, and deep learning models are employed to sample features from test cases and complete software program module clustering. However, current clustering methods can only extract and select specific code snippets from test cases for software module test analysis. They cannot accurately analyze each stage of software testing effectively, and the analysis methods are too simplistic and have limited coverage, failing to reduce the resource and time consumption of software testing. Summary of the Invention
[0005] The purpose of this invention is to overcome the problems existing in clustering methods in software testing, and to provide a software testing method, system, storage medium and device based on time series segmentation clustering algorithm.
[0006] The objective of this invention is achieved through the following technical solution:
[0007] This paper primarily provides a software testing method based on a time series segmentation and clustering algorithm. The method includes:
[0008] Static analysis is performed on various test project programs to extract the test target code, and module code segments of the prototype project program are inserted into the test target code to obtain the test dataset;
[0009] The dataset to be tested is initially clustered using a time series segmentation clustering algorithm, and the accuracy of the initial clustering is evaluated to obtain the initial clustering results. Among them, the code of the project modules that are clustered in the same way are divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases.
[0010] The initial clustering results are then subjected to a second clustering using a time series segmentation clustering algorithm to obtain the final test case set.
[0011] The test case set is then tested.
[0012] As a preferred option, a software testing method based on a time series segmentation and clustering algorithm, wherein the static analysis of various test project programs and extraction of target code includes:
[0013] The program to be tested is divided into different types of functional code segments, and different types of feature labels are set for different types of functional code segments to obtain different types of functional modules to be tested;
[0014] Principal component analysis (PCA) was used to select features for the functional module under test, and new fields were constructed to describe the original features.
[0015] As a preferred embodiment, a software testing method based on a time series segmentation and clustering algorithm includes inserting module code segments of a prototype project program into the target code to be tested, comprising:
[0016] The module code segments of the prototype project program are tagged to obtain prototype tags, and the prototype tags are inserted into the target code to be tested.
[0017] As a preferred embodiment, a software testing method based on a time series segmentation and clustering algorithm includes the following initial clustering:
[0018] The function module under test is set as a raw signal of a certain length, the raw signal is divided into several possible state segments, and each state segment of the raw signal is marked.
[0019] As a preferred option, a software testing method based on time series segmentation clustering algorithm uses the mean F1-score to evaluate the accuracy of the initial clustering.
[0020] As a preferred embodiment, a software testing method based on a time series segmentation and clustering algorithm includes, wherein the secondary clustering comprises:
[0021] The new test cases are further divided, and the divided test cases are clustered with the module code segments of the prototype project program.
[0022] As a preferred option, a software testing method based on a time series segmentation and clustering algorithm, wherein different types of feature labels are set for different types of functional code fragments, including:
[0023] Feature tags are assigned to code snippets with target functions such as adding, deleting, modifying, and querying, resulting in FP-class feature tags; feature tags are assigned to code snippets with login and registration functions, resulting in LGP-class feature tags; and feature tags are assigned to code snippets with visual displays, resulting in VP-class feature tags.
[0024] This invention also provides a software testing system based on a time series segmentation and clustering algorithm, comprising:
[0025] The test data creation module is used to perform static analysis on various test project programs and extract the test target code, and insert the module code segment of the prototype project program into the test target code to obtain the test dataset;
[0026] The initial clustering module uses a time series segmentation clustering algorithm to perform initial clustering on the dataset to be tested, and evaluates the accuracy of the initial clustering to obtain the initial clustering results; among them, the code of the project modules that are clustered in the same way are divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases;
[0027] The secondary clustering module is used to perform secondary clustering on the initial clustering results using a time series segmentation clustering algorithm to obtain the final test case set.
[0028] The testing module is used to test the set of test cases.
[0029] On the other hand, the present invention also provides a computer-readable storage medium having stored thereon a program for performing the software testing method described above.
[0030] On the other hand, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores at least one piece of program code, the at least one piece of program code being loaded and executed by the processor to enable the electronic device to implement the software testing method described above.
[0031] It should be further noted that the technical features corresponding to the above options can be combined or substituted to form new technical solutions if there is no conflict.
[0032] Compared with the prior art, the beneficial effects of the present invention are:
[0033] (1) This invention uses a time series segmentation clustering algorithm to build an automatic segmentation clustering model based on the inverse covariance of software functional connection groups. Without calibration, it can discover the hidden information in the functional modules to be tested, accurately extract the functional modules of test cases, improve the coverage of each stage of software testing, ensure the diversification of test cases, reduce the processing complexity of test cases, reduce the resource consumption of software testing, and improve testing efficiency.
[0034] The purpose of the initial clustering is to obtain a clustering matrix between the standard test code and the code to be tested. The purpose of the secondary clustering is to be specific to a certain function and to obtain a secondary clustering of the standard test code obtained in the first clustering. This secondary clustering can obtain the cluster groups of the code to be tested and the standard test code. Then, software testers determine whether the code in the same group is safe, standard, or basic standard code based on the cluster grouping and the score given by the clustering model, and therefore does not need to be tested. Through multi-level clustering, the goal of reducing testing costs is ultimately achieved.
[0035] (2) Using PCA (Principal Component Analysis) can effectively reduce the feature dimensionality of the initially obtained test cases. Otherwise, excessively high dataset dimensionality will affect the subsequent clustering results. Only by extracting accurate test code module features can the data input module of the time series clustering algorithm be completed, and only then can good clustering results be obtained.
[0036] (3) This invention reduces repetitive unit testing, greatly enhances the efficiency of automated software testing, and fills the gap in shortening the testing cycle in software testing production.
[0037] (4) This invention uses an improved inverse covariance method to segment and statically analyze the modules that need to be tested in the software testing process, obtain prototype module test code and classified software function module test code and traverse them, calculate the code coupling rate, provide an effective clustering result evaluation method, and realize more intelligent clustering recognition to reduce repetitive software testing. Attached Figure Description
[0038] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, which are used to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to denote the same or similar parts. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application.
[0039] Figure 1 This is a flowchart illustrating a software testing method based on a time series segmentation and clustering algorithm, as shown in this invention. Detailed Implementation
[0040] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] In the description of this invention, it should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0042] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0043] This invention primarily focuses on static analysis of the test project program and the prototype project program to extract target code, resulting in a mapping set of the test project program and a mapping set of the prototype project program. Based on the obtained mapping sets of various software test projects and the prototype project program set, clustering is performed. First, the test project programs are labeled to obtain raw data for data processing. Then, the raw data is classified and labeled to obtain an initial clustering dataset, and a mathematical clustering model is constructed. Finally, the accuracy of the clustering results between various test project programs and the prototype project programs is evaluated to determine the cluster similarity of various test programs. Test programs of the same type can be sampled and tested in real-world production testing, instead of exhaustively testing all test programs, thus improving the efficiency of software testing and saving human and material costs.
[0044] Example 1
[0045] Applying deep learning algorithms to software testing has been a very active research method in the testing field in recent years, with many research studies showing application cases. However, most methods are based on test case sorting and classification, while clustering algorithms are very rare. This method, on the other hand, uses a time series segmentation algorithm to divide the functional sequence of test code in software testing, which can achieve clustering with standard test code, thereby greatly reducing the execution of test code. This method has been virtually unheard of in the current software testing field.
[0046] In this exemplary embodiment, a software testing method based on a time series segmentation and clustering algorithm is provided, such as... Figure 1 As shown, the method includes:
[0047] Static analysis is performed on various test project programs to extract the test target code, and module code segments of the prototype project program are inserted into the test target code to obtain the test dataset;
[0048] The dataset to be tested is initially clustered using a time series segmentation clustering algorithm, and the accuracy of the initial clustering is evaluated to obtain the initial clustering results. Among them, the code of the project modules that are clustered in the same way are divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases.
[0049] The initial clustering results are then subjected to a second clustering using a time series segmentation clustering algorithm to obtain the final test case set.
[0050] The test case set is then tested.
[0051] Specifically, the initial clustering aims to obtain an initial clustering matrix by performing preliminary clustering of functional segments of standard test code obtained from the current software testing field with the software test code to be tested, thereby selecting the target test code. Secondly, secondary clustering of the clustering matrix obtained from the initial clustering further reveals the functionality of each test code segment. For example, if the test matrix contains code for login, registration, and patient information retrieval, each specific functional test segment in the test matrix is clustered again with the standard test code to obtain a second clustering matrix. This second clustering matrix is the clustering result we need to analyze. Software testers use this clustering result to determine which functional test codes need to be tested and which functional test codes, similar to the standard test codes, do not need to be tested. Using time series clustering algorithms can accurately analyze the characteristic relationships between code modules and improve clustering effectiveness, which is a key reason for choosing this method for software testing.
[0052] Furthermore, static analysis methods such as PCA principal component analysis can effectively reduce the feature dimensionality of the initially obtained test cases. Otherwise, excessively high dataset dimensionality will affect the subsequent clustering results. Only by extracting accurate test code module features can the data input module of the time series clustering algorithm be completed, and only then can good clustering results be obtained.
[0053] Furthermore, the purpose of the initial clustering is to obtain a clustering matrix between the standard test code and the code to be tested. The purpose of the secondary clustering is to be specific to a certain function and to obtain a secondary clustering of the standard test code obtained in the first clustering. This second clustering can obtain the cluster groups of the code to be tested and the standard test code. Then, software testers determine whether the code in the same group is safe, standard, or basic standard code based on the cluster grouping and the score given by the clustering model, and therefore do not need to be tested, thus achieving the goal of reducing testing costs.
[0054] Example 2
[0055] Based on Example 1, a software testing method based on a time series segmentation and clustering algorithm is provided. The step of performing static analysis on various test projects and extracting target code includes:
[0056] The program to be tested is divided into different types of functional code segments, and different types of feature labels are set for different types of functional code segments to obtain different types of functional modules to be tested.
[0057] Specifically, the mathematical processing method for the program to be tested includes the following steps:
[0058] S1. Segmentation and Analysis of the Program Under Test: In the process of segmenting the code of the program under test, it is necessary to first determine the target function, establish the target function, and extract accurate and effective code segments. In the actual production process, feature labels are applied to code segments (FP) with target functions such as adding, deleting, modifying, and querying. These codes are represented using regularization when performing mathematical expression transformation, resulting in the first type of feature label, also called FP-type feature label. For code segments with login / registration functions (LGP), partial variance is used for mathematical expression, resulting in the second type of feature label, also called LGP-type feature label. For code segments containing visualization functions (VP), a sine function is used for mathematical expression, resulting in the third type of feature label, also called VP-type feature label. Furthermore, the same method can be used to process the feature labels of functional module codes (OP) in various software projects with different functions, and the code segments of the software program are clustered and labeled.
[0059] S2. Principal Component Analysis (PCA) is used to select features for the functional module under test and construct new fields to describe the original features: Select a subset of useful or valuable features for model training; create new fields to describe the original features. For example, dimensionality reduction is performed on a class of features so that the reduced data can express the original information. The objective is to decentralize the set functional module program under test, transform X linearly through a dot product with V, and calculate the variance S.
[0060] S=(V T X)(V T X)=V T XX T V
[0061] Our goal is to maximize the variance, while also ensuring that V consists of unit vectors, i.e.:
[0062] maxV T XX T V
[0063] stV T V=1
[0064] Where X represents the sample set of the program to be tested, and V represents the sample matrix.
[0065] Solve by differentiation:
[0066] Using the Lagrange multiplier method, we can obtain:
[0067] L(V,λ)=V T XX T V-λ(V T V-1)
[0068] Differentiation yields:
[0069]
[0070] The solution yields:
[0071] XX T ·V=λV
[0072] Here, λ represents the eigenvalue of a software program module, and V is the eigenvector. The largest eigenvalues of the software program modules are selected, and the principal components (λ) corresponding to these eigenvalues are then chosen. i The corresponding v i Principal component analysis was completed, and the initial dataset of the program under test was finally obtained.
[0073] S3. Insert module code segments of the prototype project program into the target code to be tested, including:
[0074] The module code segments of the prototype project program are tagged to obtain prototype tags, which are then inserted into the target code to be tested. Specifically, after performing initial principal component analysis on the code of the functional module to be tested, prototype module code segments need to be set. These prototype module code segments are selected from the codebase and are stable code segments that have been deployed in reality and can be tested by real network users. These are used as prototype module code segments to ensure the validity and correctness of the code to be tested. The prototype module code segments are mathematically transformed to obtain tagged mathematical expressions, and the prototype tags are inserted into the dataset to obtain the Software Test Repetition Rate Detection (STRRD) dataset. This dataset becomes the final dataset to be tested. The dimensions of this dataset can be increased or decreased according to the code of the functional module, with the dimension set to n; the data size can be increased or decreased according to the functional items to be tested in the software project, with the data length set to m.
[0075] S4. After setting the labels for the prototype module code segment and various software function module code segments, use the STRRD dataset for clustering algorithm to begin selecting cluster centers: First, randomly select a cluster sample from the STRRD dataset as the initial cluster center c1; second, first calculate the minimum distance between each sample and the currently selected cluster center (i.e., the closest distance obtained by calculating the distance variance with the cluster center), denoted by D(x); then, calculate the probability that each sample will be selected as the next cluster center. Finally, the next cluster center is selected using the roulette wheel method; this process is repeated until the set k cluster centers are selected.
[0076] Furthermore, the initial clustering includes:
[0077] The functional module under test is set as a raw signal of a certain length, and the raw signal is divided into several possible state segments, with each state segment of the raw signal labeled. Specifically, after obtaining the dataset to be tested and the cluster centers, a clustering model needs to be built. The construction of the clustering model includes:
[0078] S1. An automatic segmentation and clustering model based on inverse covariance is constructed using software functional connectivity groups. Without labeling, the aim is to uncover hidden information within these data, i.e., to divide the signals into several possible states and label each segment of the signal. For example: the initial functional modules of the software under test include login, registration, SMS verification, email verification, etc.; the system functional modules of the software under test include user information creation, deletion, modification, and querying; data graphical display; user data transformation, etc. This requires performing two operations on the data simultaneously: segmenting the initial dataset of the program under test; and using an algorithm that examines the correlation between different dimensions of the signals to determine their similarity.
[0079] S2. Establish a clustering model: Use the initial dataset segment (signals from functional modules such as FP, LGP, VP, OP, etc.) of the program under test as the original signal of length T: X = [x1, x2, x3, x4, ..., x T ], where each type of signal segment x i Given an n-dimensional vector, to facilitate subsequent secondary partitioning to examine the correlation of various signals, a reference segment of width w is extracted from the original signal to construct the signal segment:
[0080] X i =[x i-w+1 ,…,x i-1 ,x i ]
[0081] Where i = 1, 2, 3, ..., T, signal segment X i It is a vector of dimension nw.
[0082] S3. Connect the cluster centers to obtain the joint equation, and divide all signal segments into K classes. The set of program numbers of the signal segments belonging to the j-th class is P. j j = 1, 2, 3, ..., K. Each signal segment follows a zero-mean Gaussian distribution, and its inverse covariance matrix is θ. j Let j = 1, 2, ..., K, forming an nw × nw matrix. θ j It consists of w×w submatrices, each of size n×n. The submatrix at position pq describes the inverse covariance matrix between process signals p and q across n dimensions:
[0083] [0-w+1,…p,…,q,…,0]
[0084] Here, it is assumed that the signal is time-independent, and the relationship between different characteristic function signals is only related by the covariance of the different function signals; by exchanging pq, their covariance inverses are transposes of each other.
[0085] Solution: Given θ j Solve the program signal segment classification Pj Given P j Solve for the inverse covariance matrix θ of various features. j .
[0086] S4, Solving for signal segment classification P j Given θ j , signal segment X i The cost of classifying a character into class j is represented by the negative log-likelihood:
[0087]
[0088] The experiment further incorporates functional signal continuity: a penalty β is applied when connected signal segments are of different classes.
[0089]
[0090] The core idea is that when classifying the i-th signal segment, we only need to consider the cost of classifying the (i-1)-th signal segment into different categories.
[0091] S5. Solving for the inverse covariance matrix θ j Given a set P of all signal segments in a class j By minimizing the sum of its negative log-likelihoods, θ can be solved. j Signals from various functional modules under test can be calculated in parallel:
[0092]
[0093] The first term in the summation expression is independent of j, and || represents the element count within the set:
[0094] E1 = -|P i |·logdet(θ)
[0095] The second term in the summation can be written in trace form:
[0096]
[0097] Where S is P j The current inverse covariance matrix calculated for all signal segments is further modified by adding a regularization term:
[0098] E3=||γ⊙θ||
[0099] Where γ is the weight matrix, and ⊙ represents matrix multiplication by its digits.
[0100] Based on the above experimental procedures, θ is required to be the inverse covariance matrix of the block-based software functional connectivity group. After transforming the problem, a fast solution can be obtained using the ADMM (Alternating Direction Method of Multipliers):
[0101] minimize-logdet(θ)+tr(S·θ)+||γ⊙θ||
[0102] subject to θ = Z, where Z is the block Toeplitz matrix.
[0103] Furthermore, after building the clustering model, the data in the STRRD dataset is applied, with the dimension n including the prototype program module signal and the window width w. The number of clusters K, the selected number of cluster centers, is determined, and clustering of the prototype program samples and the test program samples begins. The initial clustering results are obtained using the software functional connectivity group inverse covariance automatic segmentation clustering algorithm set above.
[0104] Furthermore, the accuracy of the initial clustering is evaluated using the mean F1 score. Specifically, a confusion matrix is used, the general idea of which is to count the number of times instances of category A are predicted (clustered) as category B. Recall and precision are two widely used metrics in statistical classification to evaluate the quality of classification results. The confusion matrix used in this method is as follows:
[0105] Predicted value 0 Predicted value 1 True value TN FP Predicted value FN TP
[0106] in:
[0107] TN indicates that the above-mentioned automatic segmentation and clustering algorithm based on the inverse covariance of software functional connectivity groups is correct. The algorithm predicts negative cases (N), which is actually the number of negative cases (N), that is, the algorithm predicts correctly (True).
[0108] TP represents the number of positive examples (P) predicted by the algorithm but actually negative examples (N), that is, the algorithm made a wrong prediction (False).
[0109] FN represents the number of negative examples (N) predicted by the algorithm, which is actually the number of positive examples (P), meaning the algorithm made a wrong prediction (False).
[0110] FP represents the number of positive examples (P) predicted by the algorithm, which is actually the number of positive examples (P), meaning the algorithm predicted correctly (True).
[0111] Accuracy calculation:
[0112] Recall calculation:
[0113] The F1 score is used to comprehensively evaluate precision and recall. When both precision and recall are high, the F1 score will also be high. This method uses the F1 score to evaluate the clustering performance of the model.
[0114]
[0115] Where P represents accuracy and R represents recall. The accuracy of the automatic segmentation and clustering model is evaluated based on the final F1 score, which serves as the basis for determining the similarity of software project modules and whether the clustering is reasonable.
[0116] Furthermore, the secondary clustering includes:
[0117] The new test cases are further subdivided, and the subdivided test cases are clustered with the module code segments of the prototype project program. Specifically, based on the above-mentioned automatic segmentation clustering algorithm using inverse covariance based on software functional connectivity groups, the clustering conclusions of the software project code under test are obtained. The label results of the same cluster indicate that the project code of this group of test cases has a high coupling degree, and its coupling probability can be judged according to the evaluation criteria. Then, the project module code of the same cluster is further divided into specific functions to obtain a new set of test cases. Based on the test cases, new modules to be tested are divided. The basic functional modules to be tested obtained by the re-division are further clustered using the automatic segmentation model. The final clustering result indicates that the module function of this type of software program is the same as the prototype module function, and sampling testing of the software module can be performed without exhaustive testing.
[0118] Next, the test cases are meticulously divided, including the functional modules of the program under test. The m data points in the automated test dataset are functionally divided as follows: C1, C2, C3…, C… j Where j represents the number of functional divisions of the program under test. Then, a dataset is generated for the newly obtained test cases, and the program under test is associated with the prototype program modules of this type, finally obtaining the test case dataset TCD (Test Case Data).
[0119] Furthermore, the software functional connectivity group clustering model built in the above steps is used to cluster the program under test, and the clustering results are obtained. After evaluation, the accuracy is obtained, and the clustered test case set [t1,t2,…,t] is obtained. K ], where K represents the number of cluster groups obtained by the clustering model.
[0120] Finally, the testers validated the clustered test cases: the testers validated the final t... K For projects in clustered groups, obtain feedback information: whether the test cases in the clustered groups are functional modules of the same type, whether the test cases of the clustered groups can be randomly sampled for system software testing without exhaustive testing, and finally determine whether the clustering method is accurate and whether the method can be used directly.
[0121] Example 3
[0122] Based on Embodiment 2, a method for reducing redundant unit testing based on software functional connectivity group clustering is provided. Taking hospital management assistant testing as an example, the specific functions of the medical assistant system require testing the standard test code of the relevant patient module. The purpose of the first clustering is to obtain a clustering matrix between the standard test code and the code to be tested. This clustering can cluster the code to be tested with the code in the standard test case code library, and filter out a class library matrix related to medical field testing. After obtaining the class library matrix, the purpose of the second clustering is to be specific to a certain function, such as patient information entry or doctor handover information entry, and then perform a second clustering between the code to be tested and the standard test code obtained in the first clustering. This clustering can obtain the cluster groups of the code to be tested and the standard test code. Subsequently, software testers determine whether the code in the same group is safe, standard, or basically standard based on the cluster grouping and the score given by the clustering model, and do not need to be tested, thus achieving the final goal of reducing testing costs.
[0123] Specifically, the dataset extracted through functional extraction and mathematical transformation for the system test contains 60 data entries, each with four functional dimension attributes. The data reading module reads the STRRD dataset S = {S1, S2, ..., S...}. 60}
[0124] The dataset dimensions are adjusted based on the code of the functional modules, with the functional dimension set to 4. The data size is adjusted based on the functions to be tested in the software project, with the data length set to 60. Cluster center selection begins: First, a cluster sample is randomly selected from the STRRD dataset as the initial cluster center c1. Second, the minimum distance between each sample and the currently selected cluster center (i.e., the closest distance obtained by calculating the distance variance with the cluster center) is denoted by D(x). Then, the probability of each sample being selected as the next cluster center is calculated. Finally, the next cluster center is selected using the roulette wheel method; this process is repeated until the set k cluster centers are selected.
[0125] The data in the STRRD dataset is applied as follows: the dimensions of the prototype program module signals are set to 4, and the window width is 5. The number of clusters K is determined by the number of selected cluster centers. Clustering of prototype program samples and test program samples begins, and the final software module clustering results are obtained using the software functional connectivity group inverse covariance automatic segmentation clustering algorithm.
[0126] The groups obtained from the initial clustering are then subjected to secondary clustering. First, a detailed partitioning of the test cases is performed, including the functional modules of the program under test. The 60 data points in the automated test dataset are functionally partitioned as follows: C1, C2, C3…, C… j , where j=4 represents the number of functional divisions of the program under test.
[0127] Example 4
[0128] A software testing system based on a time series segmentation and clustering algorithm is provided, comprising:
[0129] The test data creation module is used to perform static analysis on various test project programs and extract the test target code, and insert the module code segment of the prototype project program into the test target code to obtain the test dataset;
[0130] The initial clustering module uses a time series segmentation clustering algorithm to perform initial clustering on the dataset to be tested, and evaluates the accuracy of the initial clustering to obtain the initial clustering results; among them, the code of the project modules that are clustered in the same way are divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases;
[0131] The secondary clustering module is used to perform secondary clustering on the initial clustering results using a time series segmentation clustering algorithm to obtain the final test case set.
[0132] The testing module is used to test the set of test cases.
[0133] In particular, the test data creation module uses static analysis methods such as PCA principal component analysis to effectively reduce the feature dimensionality of the features in the initially obtained test cases. Otherwise, if the dataset dimensionality is too high, it will affect the subsequent clustering effect. Only by extracting accurate test code module features can the data input module of the time series clustering algorithm be completed and good clustering results be obtained.
[0134] The initial clustering module is used to obtain a clustering matrix between the standard test code and the code to be tested. The secondary clustering module can be specific to a certain function and perform secondary clustering of the standard test code obtained in the initial clustering module. This secondary clustering can obtain the cluster groups of the code to be tested and the standard test code. Then, software testers determine whether the code in the same group is safe, standard, or basic standard code based on the cluster grouping and the score given by the clustering model, and therefore do not need to be tested, thus achieving the goal of reducing testing costs.
[0135] Example 5
[0136] A computer-readable storage medium is provided, on which a program for executing the software testing method described in Embodiment 1 is stored. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0137] Example 6
[0138] An electronic device is provided, including a processor and a memory, wherein the memory stores at least one line of program code, which is loaded and executed by the processor to enable the electronic device to implement the software testing method described above. The processor may be a single-core or multi-core central processing unit, a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.
[0139] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A software testing method based on a time series segmentation and clustering algorithm, characterized in that, The method includes: Static analysis is performed on various test project programs to extract the test target code, and module code segments of the prototype project program are inserted into the test target code to obtain the test dataset; The static analysis and target code extraction for various test projects includes: The program to be tested is divided into different types of functional code segments, and different types of feature labels are set for different types of functional code segments to obtain different types of functional modules to be tested; Principal component analysis (PCA) was used to select features for the functional module under test, and new fields were constructed to describe the original features. The dataset to be tested is initially clustered using a time series segmentation clustering algorithm, and the accuracy of the initial clustering is evaluated to obtain the initial clustering results. Among them, the code of the project modules that are clustered in the same way are divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases. The initial clustering includes: setting the functional modules to be tested in the dataset to be tested as raw signals of a certain length, wherein the raw signals contain multiple signal segments, and each signal segment is an n-dimensional vector; Using the module code segment of the prototype project program as the reference signal, a reference segment of width w is extracted forward to construct an nw-dimensional signal segment vector; In the dataset to be tested, a sample is randomly selected as the initial cluster center. The probability of each sample being selected as the next cluster center is calculated based on the minimum distance between each sample and the current cluster center. K cluster centers are selected by roulette wheel method. All signal segments are divided into K classes. Assuming that each class of signal segments follows a Gaussian distribution with zero mean, the inverse covariance matrix is used to describe the correlation between signal segments within each class. The inverse covariance matrix is solved by the alternating direction multiplier method to complete the initial clustering. The initial clustering results are then subjected to a second clustering using a time series segmentation clustering algorithm to obtain the final test case set. The step of performing secondary clustering on the initial clustering results using a time series segmentation clustering algorithm to obtain the final test case set includes: dividing the project module code that clusters with the same structure in the initial clustering results into specific functions to obtain the re-divided basic functional module test program; and performing secondary clustering on the basic functional module test program and the module code segments of the prototype project program using a time series segmentation clustering algorithm to obtain the final test case set. The test case set is tested; the testing of the test case set includes: verifying the project programs in the final cluster group, obtaining feedback information to determine whether the test cases of the cluster group can be randomly sampled for software testing.
2. The software testing method based on time series segmentation and clustering algorithm according to claim 1, characterized in that, Insert module code segments of the prototype project program into the target code to be tested, including: The module code segments of the prototype project program are tagged to obtain prototype tags, and the prototype tags are inserted into the target code to be tested.
3. The software testing method based on time series segmentation and clustering algorithm according to claim 1, characterized in that, use The mean is used to assess the accuracy of the initial clustering.
4. The software testing method based on time series segmentation and clustering algorithm according to claim 1, characterized in that, The method of setting different types of feature labels for different types of functional code snippets includes: Feature tags are assigned to code snippets with target functions such as adding, deleting, modifying, and querying, resulting in FP-class feature tags; feature tags are assigned to code snippets with login and registration functions, resulting in LGP-class feature tags; and feature tags are assigned to code snippets with visual displays, resulting in VP-class feature tags.
5. A software testing system based on a time series segmentation and clustering algorithm, characterized in that, include: The test data creation module is used to perform static analysis on various test project programs and extract the target code, and insert module code segments of the prototype project program into the target code to obtain the test dataset; the static analysis and target code extraction on various test project programs includes: The program to be tested is divided into different types of functional code segments, and different types of feature labels are set for different types of functional code segments to obtain different types of functional modules to be tested; Principal component analysis (PCA) was used to select features for the functional module under test, and new fields were constructed to describe the original features. The initial clustering module uses a time series segmentation clustering algorithm to perform initial clustering on the dataset to be tested, and evaluates the accuracy of the initial clustering to obtain the initial clustering results. Specifically, the code of a group of project modules that are clustered together is divided into specific functions to obtain a new set of test cases, and new modules to be tested are divided according to the new test cases. The initial clustering includes: setting the functional modules to be tested in the dataset to be tested as raw signals of a certain length, wherein the raw signals contain multiple signal segments, each signal segment being an n-dimensional vector. Using the module code segment of the prototype project program as the reference signal, a reference segment of width w is extracted forward to construct an nw-dimensional signal segment vector; In the dataset to be tested, a sample is randomly selected as the initial cluster center. The probability of each sample being selected as the next cluster center is calculated based on the minimum distance between each sample and the current cluster center. K cluster centers are selected by roulette wheel method. All signal segments are divided into K classes. Assuming that each class of signal segments follows a Gaussian distribution with zero mean, the inverse covariance matrix is used to describe the correlation between signal segments within each class. The inverse covariance matrix is solved by the alternating direction multiplier method to complete the initial clustering. The secondary clustering module is used to perform secondary clustering on the initial clustering results using a time-series segmentation clustering algorithm to obtain the final test case set. The process of performing secondary clustering on the initial clustering results using a time-series segmentation clustering algorithm to obtain the final test case set includes: dividing the project module code that clusters with the same group in the initial clustering results into specific functional groups to obtain redefined basic functional module test programs; and performing secondary clustering on the basic functional module test programs and the module code segments of the prototype project program using a time-series segmentation clustering algorithm to obtain the final test case set. The testing module is used to test the set of test cases; the testing of the set of test cases includes: verifying the project programs in the final cluster group, obtaining feedback information to determine whether the test cases of the cluster group can be randomly sampled for software testing.
6. A computer-readable storage medium, characterized in that, It stores programs for performing the software testing method according to any one of claims 1-4.
7. An electronic device, characterized in that, The device includes a processor and a memory, wherein the memory stores at least one line of program code, which is loaded and executed by the processor to enable the electronic device to implement the software testing method as described in any one of claims 1-4.
Citation Information
Patent Citations
Software multi-fault positioning method and device, electronic equipment and storage medium
CN110362484A
Software multi-fault clustering positioning method and device combined with dynamic slicing
CN115576851A
