Test Architecture Generation by Leveraging BERT and Control and Data Flows
摘要
In practices, test cases are often designed by test engineers based on the functionalities of the System under Test (SUT) in parallel and independently. This can lead to a lack of a comprehensive overview of the test architecture, hampering the reuse of test functions when implementing new test cases. To address this challenge, we propose ATAG, an automated test architecture generation approach, which employs an optimization algorithm to retrieve highly cohesive and loosely coupled test functions based on control flows and data flows of test cases. We also equip ATAG with a newly proposed BERT-based model, i.e., FunBERT, for generating test function names. We conducted an empirical study with three industrial datasets to evaluate the effectiveness of ATAG and FunBERT. Results show that test architectures generated with ATAG (benefiting from both control and data flows) improved, on average, \(\approx \) 26–35% coupling and \(\approx \) 28–50% cohesion of the original test architectures manually constructed by test engineers from our industrial partner. FunBERT achieves 97.9%, 98.3%, and 98.1% in Precision, Recall, and F1-score, and significantly outperforms the best baseline method BERT.