Evaluasi Teknik Prompting pada Large Language Model untuk Otomatisasi Penyusunan Skenario Unit Testing Smart Contract
DOI:
https://doi.org/10.35746/jtim.v8i1.912Kata Kunci:
Coverage Metrics, Large Language Models, Prompt Engineering, Smart Contract, Unit TestingAbstrak
Automated unit testing is essential for ensuring the security and reliability of smart contracts, particularly because their immutable nature prevents post-deployment modifications. However, manually creating test scenarios remains time-consuming, costly, and highly dependent on expert knowledge. A potential solution is to utilize AI technology, particularly Large Language Models (LLMs), to automatically generate test scenarios. This study fills the research gap in leveraging LLM technology in the software testing space by proposing a workflow for automatically gener-ating unit test scenarios for blockchain smart contract code using Large Language Models (LLMs). The proposed workflow consists of two stages: converting Solidity smart contracts into structured Gherkin scenarios and translating those scenarios into executable Hardhat unit test scripts. This study proposes an automated workflow using Large Language Models (LLMs) to address these challenges. The workflow consists of two stages: con-verting Solidity smart con-tracts into structured Gherkin scenarios and trans-lating those scenarios into executable Hardhat unit test scripts. Using the Gemini 2.5 Pro model, the research evaluates three prompting tech-niques such as Chain-of-Thought, Few-Shot, and Role-Based through quantitative analysis based on code coverage metrics, including Statements, Branches, Functions, and Lines. The experimental results show that Role-Based Prompting achieves the highest average coverage (92.02%), fol-lowed by Few-Shot Prompting (89.52%), while Chain-of-Thought produces the lowest coverage (78.79%). Role-Based Prompting also attains the highest Branch coverage, demonstrating superi-or capability in capturing conditional logic within smart contracts.
Unduhan
Referensi
L. Hertati and O. Safkaur, “Dampak Revolusi Industri 4.0 Era Covid-19 pada Sistem Informasi Akuntansi Terhadap Struktur Modal Perusahaan,” J. Ris. Akunt. dan Keuang., vol. 8, no. 3, pp. 503–518, 2020, https://doi.org/10.17509/jrak.v8i3.23557.
DeFiLlama, “DefiLlama - DeFi Dashboard,” 2024. [Online]. Available: https://defillama.com/. [Accessed: Oct. 2, 2025]
E. Barceló, K. Dimić-Mišić, M. Imani, V. Spasojević Brkić, M. Hummel, and P. Gane, “Regulatory Paradigm and Chal-lenge for Blockchain Integration of Decentralized Systems: Example—Renewable Energy Grids,” Sustain., vol. 15, no. 3, 2023, https://doi.org/10.3390/su15032571
A. Mattew and M. Anno Suwarno, “Rancang Bangun Aplikasi Donasi Terdesentralisasi Berbasis Blockchain,” Ikraith-Informatika, vol. 7, no. 2, pp. 23–32, 2022, https://doi.org/10.37817/ikraith-informatika.v7i2.2247.
I. Qasse, I. M. Ali, N. Ahmed, M. Hamdaqa, and B. Þ. Jónsson, “The Myth of Immutability: A Multivocal Review on Smart Contract Upgradeability,” 2025, https://doi.org/10.48550/arXiv.2504.02719
S. A. Latifa Albshaier and M. M. H. Rahman, “A_Review_of_Blockchains_Role_in_E-Commerce_Transa.pdf,” Mdpi, 2024, https://doi.org/10.3390/computers13010027.
“Reference | Cucumber.” [Online]. Available: https://cucumber.io/docs/gherkin/reference/. [Accessed: Oct. 25, 2025]
C. Zhang, Q. Wei, and X. Li, “Security Analysis of Ponzi Schemes in Ethereum Smart Contracts,” pp. 1–31, 2025, https://doi.org/10.48550/arXiv.2510.03819
D. Siegel, “Understanding The DAO Attack,” 2016. http://coindesk.com/learn/understanding-the-dao-attack [Accessed: Oct. 10, 2025].
Merkle Science, "Hack Track: Analysis of Wormhole Token Bridge Exploit," Merkle Science, Feb. 4, 2022. https://www.merklescience.com/blog/hack-track-analysis-of-wormhole token-bridge-exploit. [Accessed: Oct. 25, 2025]
M. G. Alkhairi, S. P. A. Alkadri, and P. Y. Utami, “Implementasi Unit Testing Dan End-To-End Testing Pada Sistem In-formasi Akademik Teknik Informatika,” JIPI (Jurnal Ilm. Penelit. dan Pembelajaran Inform., vol. 9, no. 4, pp. 2208–2219, 2024, https://doi.org/10.29100/jipi.v9i4.5626.
L. Naimi, E. M. Bouziane, M. Manaouch, and A. Jakimi, “A new approach for automatic test case generation from use case diagram using LLMs and prompt engineering,” 2024 Int. Conf. Circuit, Syst. Commun. ICCSC 2024, 2024, https://doi.org/10.1109/ICCSC62074.2024.10616548.
A. M. Rincon, A. M. R. Vincenzi, and J. P. Faria, “LLM Prompt Engineering for Automated White-Box Integration Test Generation in REST APIs,” 2025 IEEE Int. Conf. Softw. Testing, Verif. Valid. Work. ICSTW 2025, pp. 21–28, 2025, https://doi.org/10.1109/ICSTW64639.2025.10962507.
White, J., Fu, Q., Hays, S., Sandborn, M., Olea, C., Gilbert, H., Elnashar, A., Spencer-Smith, J. & Schmidt, D. C., “A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT,” arXiv preprint arXiv:2302.11382, Feb. 2023. https://doi.org/10.48550/arXiv.2302.11382.
A. Aqsa, A. Aslam, and M. Saeed, “Efficient Prompt Engineering: Techniques and Trends for Maximizing LLM Output,” no. May, 2025, https://doi.org/10.5281/zenodo.15186123.
J. Almeida, “Prompt Engineering: A Comparative Study of Prompting Techniques in AI Language Models,” 2025 15th IEEE Integr. STEM Educ. Conf. ISEC 2025, pp. 1–4, 2025, https://doi.org/10.1109/ISEC64801.2025.11147384.
A. Njifenjou, V. Sucal, B. Jabaian, and F. Lefèvre, “Role-Play Zero-Shot Prompting with Large Language Models for Open-Domain Human-Machine Conversation,” arXiv preprint arXiv:2406.18460, 2024, https://doi.org/10.48550/arXiv.2406.18460.
L. Mitchell, "Prompt engineering for LLMs," Gravitee, Jun. 16, 2023. https://www.gravitee.io/blog/prompt-engineering-for llms. [Accessed: Nov. 4, 2025]
M. Ferreira, L. Viegas, J. P. Faria, and B. Lima, “Acceptance Test Generation with Large Language Models: An Industri-al Case Study,” pp. 1–11, 2025, https://doi.org/10.1109/ast66626.2025.00007.
Z. Ul Abideen and G. Junxia, “Intent Based E2E Automated Test Case Generation for Web Applications Using LLM,” Proc. - 2025 IEEE 49th Annu. Comput. Software, Appl. Conf. COMPSAC 2025, vol. 2, pp. 1281–1290, 2025, https://doi.org/10.1109/COMPSAC65507.2025.00161.
Unduhan
Diterbitkan
Terbitan
Bagian
Lisensi
Hak Cipta (c) 2026 Salman El Farisi, Fahlia Athiyya Marva

Artikel ini berlisensiCreative Commons Attribution-ShareAlike 4.0 International License.




