Towards Generating Executable Metamorphic Relations Using Large Language Models

Seung Yeob Shin,Fabrizio Pastore,Domenico Bianculli,Alexandra Baicoianu
2024-10-11
Abstract:Metamorphic testing (MT) has proven to be a successful solution to automating testing and addressing the oracle problem. However, it entails manually deriving metamorphic relations (MRs) and converting them into an executable form; these steps are time-consuming and may prevent the adoption of MT. In this paper, we propose an approach for automatically deriving executable MRs (EMRs) from requirements using large language models (LLMs). Instead of merely asking the LLM to produce EMRs, our approach relies on a few-shot prompting strategy to instruct the LLM to perform activities in the MT process, by providing requirements and API specifications, as one would do with software engineers. To assess the feasibility of our approach, we conducted a questionnaire-based survey in collaboration with Siemens Industry Software, a worldwide leader in providing industry software and services, focusing on four of their software applications. Additionally, we evaluated the accuracy of the generated EMRs for a Web application. The outcomes of our study are highly promising, as they demonstrate the capability of our approach to generate MRs and EMRs that are both comprehensible and pertinent for testing purposes.
Software Engineering
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to automatically generate Executable Metamorphic Relations (EMRs) in software testing. Specifically, the paper proposes a method that utilizes Large Language Models (LLMs) to automatically derive EMRs from software requirement specifications, in order to reduce the time and effort required for manually defining and transforming Metamorphic Relations (MRs), thereby reducing the cost of Metamorphic Testing (MT) and promoting its practical application. The paper mentions that although Metamorphic Testing has been proven to be an effective automated testing solution that can solve the "oracle problem" in testing, its wide application is limited mainly because the process of manually deriving MRs and transforming them into executable forms is time - consuming and complex. Therefore, this research aims to improve efficiency and feasibility by automating this process, especially when dealing with new and unseen systems. In addition, the research also explores how to use Domain - Specific Languages (DSL) such as SMRL to specify EMRs to ensure that these relations can be effectively executed to verify whether the software meets the expected properties.