The high cost of the test can be dramatically reduced, provided that the coverability as an inherent feature of the code under test is predictable. This article offers a machine learning model to predict the extent to which the test could cover a class in terms of a new metric called Coverageability. The prediction model consists of an ensemble of four regression models. The learning samples consist of feature vectors, where features are source code metrics computed for a class. The samples are labeled by the Coverageability values computed for their corresponding classes. We offer a mathematical model to evaluate test effectiveness in terms of size and coverage of the test suite generated automatically for each class. We extend the size of the feature space by introducing a new approach to defining sub-metrics in terms of existing source code metrics. Using feature importance analysis on the learned prediction models, we sort source code metrics in the order of their impact on the test effectiveness. As a result of which, we found the class strict cyclomatic complexity as the most influential source code metric. Our experiments with the prediction models on a large corpus of Java projects containing about 23,000 classes demonstrate the Mean Absolute Error (MAE) of 0.032, Mean Squared Error (MSE) of 0.004, and an R2-score of 0.855. Compared with the state-of-the-art coverage prediction models, our models improve MAE, MSE, and an R2-score by 5.78%, 2.84%, and 20.71%, respectively.
翻译:测试的高成本可以大幅降低, 只要测试中代码的内在特征的可覆盖性是可以预测的。 文章提供了一个机器学习模型, 以预测测试能够涵盖一个类别的程度, 即所谓的“ 可覆盖性”的新度量值。 预测模型由四个回归模型的组合组成。 学习样本由特性矢量组成, 其特征是为某个类别计算的源代码度量值。 样本用为相应类别计算的可覆盖性值标出标签。 我们提供了一个数学模型, 以评价每个类别自动生成的测试套件的规模和覆盖范围的测试效力。 我们通过采用新方法, 确定现有源代码的可覆盖度值, 从而扩大功能空间的大小。 利用对四个已学回归模型的特征重要性分析, 我们根据对测试有效性的影响来排序源代码度指标。 结果, 我们发现分类的严格周期复杂性是最有影响的源代码度度量度值。 我们与包含大约23 000个类的Java项目预测模型进行了实验, 展示了我们当前源代码值为 2. 0- E 模型的绝对误差值, R. 0- 和 R. 0- m. 0- m.