Tran Nguyen Huong, Le Huu Chung, Lam Nguyen Tung, Hoang-Viet Tran, Pham Ngoc Hung
{"title":"An Automated Stub Method for Unit Testing C/C++ Projects","authors":"Tran Nguyen Huong, Le Huu Chung, Lam Nguyen Tung, Hoang-Viet Tran, Pham Ngoc Hung","doi":"10.1109/KSE56063.2022.9953784","DOIUrl":null,"url":null,"abstract":"Automated stubs generation is an important problem when testing units which contains calls to other uncompleted functions as testing and development phases are normally performed in parallel. This paper presents a fully automated method, named AS4UT, for generating stubs used in unit testing of C/C++ projects. The key idea of AS4UT is to consider each function call a mock variable. The idea is done by adding a Pre-process CFG (control flow graph) phase to concolic testing method. In this phase, all function calls in the CFG of a unit under test are replaced by their corresponding mock variables. Then, the updated CFG is used as an input for concolic testing method to generate the required test data set. We have implemented AS4UT in a tool, named AutoStubTesing, and performed experiments with some common functions which calls other units. Experimental results show that AS4UT can increase the code coverage of the generated test data set whilst reducing the number of test data and keeping the required time acceptable.","PeriodicalId":330865,"journal":{"name":"2022 14th International Conference on Knowledge and Systems Engineering (KSE)","volume":"146 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2022-10-19","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2022 14th International Conference on Knowledge and Systems Engineering (KSE)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/KSE56063.2022.9953784","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
Abstract
Automated stubs generation is an important problem when testing units which contains calls to other uncompleted functions as testing and development phases are normally performed in parallel. This paper presents a fully automated method, named AS4UT, for generating stubs used in unit testing of C/C++ projects. The key idea of AS4UT is to consider each function call a mock variable. The idea is done by adding a Pre-process CFG (control flow graph) phase to concolic testing method. In this phase, all function calls in the CFG of a unit under test are replaced by their corresponding mock variables. Then, the updated CFG is used as an input for concolic testing method to generate the required test data set. We have implemented AS4UT in a tool, named AutoStubTesing, and performed experiments with some common functions which calls other units. Experimental results show that AS4UT can increase the code coverage of the generated test data set whilst reducing the number of test data and keeping the required time acceptable.