LLM4UnitTests-SC is a Visual Studio Code extension designed to streamline the process of writing, validating, and testing JavaScript-based unit tests for smart contracts configured with Hardhat. With built-in LLM-assisted correction and execution features, it enhances the testing workflow by providing syntax validation, intelligent correction, code coverage analysis, and downloadable test reports—all in a unified webview interface.
Features
🚦 Syntax Validation & Correction
Line-by-Line Error Detection: Accurately identifies syntax errors in JavaScript test files with detailed line numbers.
Automatic Correction: Utilizes AI to suggest and apply corrections to invalid code segments.
Re-validation Loop: Re-checks code after applying corrections to ensure it's clean and ready for execution.
🧪 Test Execution & Code Coverage
Seamless Execution: Runs Hardhat test suites directly from the extension.
Coverage Reports: Measures and visualizes code coverage to help improve test quality and completeness.
📄 PDF Report Generation
Exportable Reports: Allows users to generate and download a comprehensive PDF report of test results and code coverage metrics.
Search for LLM4UnitTests-SC in the VS Code Extension Marketplace.
Click Install.
Once installed, open your smart contract project folder.
How to Use
Open a JavaScript test file inside your Hardhat project.
Launch the extension by clicking the LLM4UnitTests-SC icon in the sidebar or from the Command Palette (Ctrl+Shift+P → LLM4UnitTests-SC: Start).
A webview panel will appear with the following tabs:
Syntax Validator
Correct & Revalidate
Execute Tests
Generate PDF Report
Review any detected syntax issues and apply corrections.
Execute the validated test suite and inspect code coverage.
Click Download Report to export your test summary as a PDF.
Use Case
This extension is ideal for developers working on Ethereum smart contracts using Hardhat. It simplifies unit testing by automating the detection and correction of errors, ensuring your contracts are thoroughly tested with minimal friction.