Automated Test Case Generation Using Code Models and Domain Adaptation

08/15/2023
by   Sepehr Hashtroudi, et al.
0

State-of-the-art automated test generation techniques, such as search-based testing, are usually ignorant about what a developer would create as a test case. Therefore, they typically create tests that are not human-readable and may not necessarily detect all types of complex bugs developer-written tests would do. In this study, we leverage Transformer-based code models to generate unit tests that can complement search-based test generation. Specifically, we use CodeT5, i.e., a state-of-the-art large code model, and fine-tune it on the test generation downstream task. For our analysis, we use the Methods2test dataset for fine-tuning CodeT5 and 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, human-readable unit tests. Results show that our approach can generate new test cases that cover lines that were not covered by developer-written tests. Using domain adaptation, we can also increase line coverage of the model-generated unit tests by 49.9 54 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 search-based methods by killing extra mutants (up to 64 new mutants were killed per project in our experiments).

READ FULL TEXT
research
04/30/2023

Exploring the Effectiveness of Large Language Models in Generating Unit Tests

A code generation model generates code by taking a prompt from a code co...
research
04/12/2022

Toward Granular Automatic Unit Test Case Generation

Unit testing verifies the presence of faults in individual software comp...
research
08/16/2021

Systematic Generation of Conformance Tests for JavaScript

JavaScript implementations are tested for conformance to the ECMAScript ...
research
02/23/2023

Sequence-Based Incremental Concolic Testing of RTL Models

Concolic testing is a scalable solution for automated generation of dire...
research
02/20/2023

A3Test: Assertion-Augmented Automated Test Case Generation

Test case generation is an important activity, yet a time-consuming and ...
research
05/08/2023

ChatUniTest: a ChatGPT-based automated unit test generation tool

Unit testing is a crucial, yet often tedious and time-consuming task. To...
research
08/11/2021

Hybrid Multi-level Crossover for Unit Test Case Generation

State-of-the-art search-based approaches for test case generation work a...

Please sign up or login with your details

Forgot password? Click here to reset