Minimock Helper is an extension for Visual Studio Code that adds the ability to quickly generate mocks using minimock from the context menu of .go files.
Features
Generate mocks for specified interface from selected file via the context menu.
Seamless integration with minimock for Go projects.
Save time when writing tests.
How to Use
Option 1: Context Menu
Right-click on the desired .go file in your project.
In the context menu, select "minimock: Generate mock file".
The extension will generate mocks for the specified interface from the selected file.
Option 2: Command Palette (Cmd+P)
Open the .go file you want to generate mocks for in the editor.
Select the interface name in the editor (or place the cursor on it).
Press Cmd+P (or Ctrl+P on Windows/Linux), then type and select "Minimock: Generate mock file".
By default, the extension will use the selected text in the editor as the interface name for mock generation.
The extension will generate mocks for the interface in the currently open file.
Requirements
minimock installed on your system (go install github.com/gojuno/minimock/v3/cmd/minimock@latest).
Go project.
Installation
Open Visual Studio Code.
Go to the Extensions section.
Find "Minimock Helper" and install it.
Settings
The extension supports a single setting for configuring the output folder for generated mocks:
mockFolder
Specifies the relative path (from the folder containing the Go file) where generated mocks will be placed.
Example:
{
"minimock-helper.mockFolder": "test/mocks"
}
You can configure this option in your VS Code settings.json.