{"id":{"repo_id":"calgary","oai_identifier":"oai:ucalgary.scholaris.ca:1880/116140"},"canonical_url":"https://search.ndltd.org/etd/calgary/oai:ucalgary.scholaris.ca:1880/116140","repository":{"repo_id":"calgary","name":"University of Calgary","base_url":"https://ucalgary.scholaris.ca/server/oai/request"},"display":{"title":"Automated Test Case Generation Using Transformers and Domain Adaptation","abstract":"Software testing is an important part of the software development cycle. It helps prevent future potential defects in the system and reduce maintenance cost. However, it is often neglected by developers like other tasks such as documentation, code review, etc. Automated unit test generation is the process of generating unit tests for a method or a class for a given project. It helps developers to detect some of the potential defects automatically. Existing approaches usually use heuristic methods such as random data generation (fuzzing) or genetic algorithms (search-based testing) to generate tests, which are based on optimizing a cost function such as code coverage. Some of the main downsides of these methods are (a) the synthetic nature of the tests that are generated based on predefined templates and (b) targeting surrogate measures such as coverage, which might not always detect existing defects. In this study, we leverage novel machine translation models, i.e., transformers to generate unit tests for a given program. Specifically, we use CodeT5, i.e., a state-of-the-art large code model, and fine-tune it on the test generation downstream task. We use the Methods2test dataset for fine-tuning CodeT5. We also use Defects4j for project-level domain adaptation and evaluation. The main contribution of this study is proposing a fully automated testing framework that leverages developer-written tests and available code models to generate compilable unit tests. Results show that using domain adaptation, we can increase line coverage of the model-generated unit tests by 49.9% and 54% in terms of mean and median (compared to the model without domain adaptation). We can also use our framework as a complementary solution alongside common search-based methods to increase the overall coverage with mean and median of 25.3% and 6.3%. It can also increase the mutation score of search-based methods with mean and median of 8.6% and 1%.","abstract_html":"Software testing is an important part of the software development cycle. It helps prevent future potential defects in the system and reduce maintenance cost. However, it is often neglected by developers like other tasks such as documentation, code review, etc. Automated unit test generation is the process of generating unit tests for a method or a class for a given project. It helps developers to detect some of the potential defects automatically. Existing approaches usually use heuristic methods such as random data generation (fuzzing) or genetic algorithms (search-based testing) to generate tests, which are based on optimizing a cost function such as code coverage. Some of the main downsides of these methods are (a) the synthetic nature of the tests that are generated based on predefined templates and (b) targeting surrogate measures such as coverage, which might not always detect existing defects. In this study, we leverage novel machine translation models, i.e., transformers to generate unit tests for a given program. Specifically, we use CodeT5, i.e., a state-of-the-art large code model, and fine-tune it on the test generation downstream task. We use the Methods2test dataset for fine-tuning CodeT5. We also use Defects4j for project-level domain adaptation and evaluation. The main contribution of this study is proposing a fully automated testing framework that leverages developer-written tests and available code models to generate compilable unit tests. Results show that using domain adaptation, we can increase line coverage of the model-generated unit tests by 49.9% and 54% in terms of mean and median (compared to the model without domain adaptation). We can also use our framework as a complementary solution alongside common search-based methods to increase the overall coverage with mean and median of 25.3% and 6.3%. It can also increase the mutation score of search-based methods with mean and median of 8.6% and 1%.","abstract_has_math":false,"creators":["Hashtroudi, Sepehr Pourabolfath"],"institution":"Schulich School of Engineering","degree_name":"Master of Science (MSc)","degree_level":null,"degree_discipline":"Engineering – Electrical & Computer","degree_department":null,"school":null,"contributors":[],"advisors":["Hemmati Hadi"],"committee_chairs":[],"committee_members":["Ioannou Yani","Karimipour Hadis"],"year":2023,"date_issued":"2023-04-28","date_published":"2023-04-28","updated_at":"2026-11-19T07:30:49Z","subjects":["automated testing","transformers","domain adaptation","machine learning"],"languages":["en"],"rights":["University of Calgary graduate students retain copyright ownership and moral rights for their thesis. You may use this material in any way that is permitted by the Copyright Act or through licensing that has been assigned to the document. For uses that are not allowable under copyright legislation or licensing, you are required to seek permission."],"rights_urls":[],"identifier_entries":[{"key":"dc:identifier.doi","label":"DOI","values":["https://dx.doi.org/10.11575/PRISM/dspace/40985"],"render_values":[{"text":"https://dx.doi.org/10.11575/PRISM/dspace/40985","href":"https://dx.doi.org/10.11575/PRISM/dspace/40985","code":true}]},{"key":"dc:identifier.citation","label":"Dc Identifier Citation","values":["Hashtroudi, S. P. (2023). Automated test case generation using transformers and domain adaptation (Master's thesis, University of Calgary, Calgary, Canada). Retrieved from https://prism.ucalgary.ca."],"render_values":[{"text":"Hashtroudi, S. P. (2023). Automated test case generation using transformers and domain adaptation (Master's thesis, University of Calgary, Calgary, Canada). Retrieved from https://prism.ucalgary.ca.","href":null,"code":true}]}],"person_identifier_entries":[]},"links":{"outbound_url":"http://hdl.handle.net/1880/116140","outbound_label":"Handle","outbound_source":"dc:identifier.uri","record_url":"http://hdl.handle.net/1880/116140","record_label":"Repository record","record_kind":"handle","record_source":"dc:identifier.uri","download_url":null,"download_label":null,"download_source":null,"access_status":null,"embargo_until":null,"access_note":null},"source_record":{"url":"https://ucalgary.scholaris.ca/server/oai/request?verb=GetRecord&metadataPrefix=dim&identifier=oai%3Aucalgary.scholaris.ca%3A1880%2F116140","prefix":"dim"},"metadata_groups":[{"id":"people","label":"People","entries":[{"key":"dc:contributor.advisor","label":"Advisor","values":["Hemmati Hadi"]},{"key":"dc:contributor.committeemember","label":"Committee Member","values":["Ioannou Yani","Karimipour Hadis"]},{"key":"dc:creator","label":"Author","values":["Hashtroudi, Sepehr Pourabolfath"]}]},{"id":"academic_context","label":"Academic Context","entries":[{"key":"dc:date","label":"Dc Date","values":["2023-06"]},{"key":"dc:date.accessioned","label":"Dc Date Accessioned","values":["2023-05-02T14:45:12Z"]},{"key":"dc:date.available","label":"Dc Date Available","values":["2023-05-02T14:45:12Z"]},{"key":"dc:date.issued","label":"Date","values":["2023-04-28"]},{"key":"dc:publisher.faculty","label":"Dc Publisher Faculty","values":["Schulich School of Engineering"]},{"key":"dc:publisher.institution","label":"Dc Publisher Institution","values":["University of Calgary"]},{"key":"dc:type","label":"Dc Type","values":["master thesis"]},{"key":"thesis:degree_discipline","label":"Discipline","values":["Engineering – Electrical & Computer"]},{"key":"thesis:degree_name","label":"Degree Name","values":["Master of Science (MSc)"]},{"key":"thesis:institution_name","label":"Thesis Institution Name","values":["University of Calgary"]},{"key":"thesis:release_request","label":"Thesis Release Request","values":["I do not require a thesis withhold – my thesis will have open access and can be viewed and downloaded publicly as soon as possible."]}]},{"id":"subjects_keywords","label":"Subjects and Keywords","entries":[{"key":"dc:subject","label":"Dc Subject","values":["automated testing","transformers","domain adaptation","machine learning"]},{"key":"dc:subject.classification","label":"Dc Subject Classification","values":["Engineering--Electronics and Electrical"]}]},{"id":"language_rights","label":"Language and Rights","entries":[{"key":"dc:language.iso","label":"Language (ISO)","values":["en"]},{"key":"dc:rights","label":"Dc Rights","values":["University of Calgary graduate students retain copyright ownership and moral rights for their thesis. You may use this material in any way that is permitted by the Copyright Act or through licensing that has been assigned to the document. For uses that are not allowable under copyright legislation or licensing, you are required to seek permission."]}]},{"id":"identifiers","label":"Identifiers","entries":[{"key":"dc:identifier.citation","label":"Dc Identifier Citation","values":["Hashtroudi, S. P. (2023). Automated test case generation using transformers and domain adaptation (Master's thesis, University of Calgary, Calgary, Canada). Retrieved from https://prism.ucalgary.ca."]},{"key":"dc:identifier.doi","label":"DOI","values":["https://dx.doi.org/10.11575/PRISM/dspace/40985"]},{"key":"dc:identifier.uri","label":"Identifier URI","values":["http://hdl.handle.net/1880/116140"]}]},{"id":"additional","label":"Additional Metadata","entries":[{"key":"dc:description.abstract","label":"Abstract","values":["Software testing is an important part of the software development cycle. It helps prevent future potential defects in the system and reduce maintenance cost. However, it is often neglected by developers like other tasks such as documentation, code review, etc. Automated unit test generation is the process of generating unit tests for a method or a class for a given project. It helps developers to detect some of the potential defects automatically. Existing approaches usually use heuristic methods such as random data generation (fuzzing) or genetic algorithms (search-based testing) to generate tests, which are based on optimizing a cost function such as code coverage. Some of the main downsides of these methods are (a) the synthetic nature of the tests that are generated based on predefined templates and (b) targeting surrogate measures such as coverage, which might not always detect existing defects. In this study, we leverage novel machine translation models, i.e., transformers to generate unit tests for a given program. Specifically, we use CodeT5, i.e., a state-of-the-art large code model, and fine-tune it on the test generation downstream task. We use the Methods2test dataset for fine-tuning CodeT5. We also use Defects4j for project-level domain adaptation and evaluation. The main contribution of this study is proposing a fully automated testing framework that leverages developer-written tests and available code models to generate compilable unit tests. Results show that using domain adaptation, we can increase line coverage of the model-generated unit tests by 49.9% and 54% in terms of mean and median (compared to the model without domain adaptation). We can also use our framework as a complementary solution alongside common search-based methods to increase the overall coverage with mean and median of 25.3% and 6.3%. It can also increase the mutation score of search-based methods with mean and median of 8.6% and 1%."]},{"key":"dc:title","label":"Title","values":["Automated Test Case Generation Using Transformers and Domain Adaptation"]},{"key":"dspace:entity.type","label":"Dspace Entity Type","values":["Publication"]},{"key":"others:access_status","label":"Others Access Status","values":["open.access"]}]}],"canonical_facts":{"dc:contributor.advisor":["Hemmati Hadi"],"dc:contributor.committeemember":["Ioannou Yani","Karimipour Hadis"],"dc:creator":["Hashtroudi, Sepehr Pourabolfath"],"dc:date":["2023-06"],"dc:date.accessioned":["2023-05-02T14:45:12Z"],"dc:date.available":["2023-05-02T14:45:12Z"],"dc:date.issued":["2023-04-28"],"dc:description.abstract":["Software testing is an important part of the software development cycle. It helps prevent future potential defects in the system and reduce maintenance cost. However, it is often neglected by developers like other tasks such as documentation, code review, etc. Automated unit test generation is the process of generating unit tests for a method or a class for a given project. It helps developers to detect some of the potential defects automatically. Existing approaches usually use heuristic methods such as random data generation (fuzzing) or genetic algorithms (search-based testing) to generate tests, which are based on optimizing a cost function such as code coverage. Some of the main downsides of these methods are (a) the synthetic nature of the tests that are generated based on predefined templates and (b) targeting surrogate measures such as coverage, which might not always detect existing defects. In this study, we leverage novel machine translation models, i.e., transformers to generate unit tests for a given program. Specifically, we use CodeT5, i.e., a state-of-the-art large code model, and fine-tune it on the test generation downstream task. We use the Methods2test dataset for fine-tuning CodeT5. We also use Defects4j for project-level domain adaptation and evaluation. The main contribution of this study is proposing a fully automated testing framework that leverages developer-written tests and available code models to generate compilable unit tests. Results show that using domain adaptation, we can increase line coverage of the model-generated unit tests by 49.9% and 54% in terms of mean and median (compared to the model without domain adaptation). We can also use our framework as a complementary solution alongside common search-based methods to increase the overall coverage with mean and median of 25.3% and 6.3%. It can also increase the mutation score of search-based methods with mean and median of 8.6% and 1%."],"dc:identifier.citation":["Hashtroudi, S. P. (2023). Automated test case generation using transformers and domain adaptation (Master's thesis, University of Calgary, Calgary, Canada). Retrieved from https://prism.ucalgary.ca."],"dc:identifier.doi":["https://dx.doi.org/10.11575/PRISM/dspace/40985"],"dc:identifier.uri":["http://hdl.handle.net/1880/116140"],"dc:language.iso":["en"],"dc:publisher.faculty":["Schulich School of Engineering"],"dc:publisher.institution":["University of Calgary"],"dc:rights":["University of Calgary graduate students retain copyright ownership and moral rights for their thesis. You may use this material in any way that is permitted by the Copyright Act or through licensing that has been assigned to the document. For uses that are not allowable under copyright legislation or licensing, you are required to seek permission."],"dc:subject":["automated testing","transformers","domain adaptation","machine learning"],"dc:subject.classification":["Engineering--Electronics and Electrical"],"dc:title":["Automated Test Case Generation Using Transformers and Domain Adaptation"],"dc:type":["master thesis"],"dspace:entity.type":["Publication"],"others:access_status":["open.access"],"thesis:degree_discipline":["Engineering – Electrical & Computer"],"thesis:degree_name":["Master of Science (MSc)"],"thesis:institution_name":["University of Calgary"],"thesis:release_request":["I do not require a thesis withhold – my thesis will have open access and can be viewed and downloaded publicly as soon as possible."]},"updated_at":"2026-11-19T07:30:49Z"}