Run Grails/Spock tests directly from your editor with CodeLens integration.
- CodeLens Integration - See "Run Test" buttons directly above your test methods and classes
- Run Individual Tests - Execute a single test method with one click
- Run All Tests in Class - Run all tests in a Spec file at once
- Rerun Tests - Force re-execution with
--rerun-tasks, bypassing Gradle's up-to-date checks - Automatic Test Type Detection - Distinguishes between unit tests and integration tests
- Terminal Output - See test results directly in the integrated terminal
- Open VS Code or Cursor
- Go to Extensions (
Ctrl+Shift+X/Cmd+Shift+X) - Search for
Grails Test Runner - Click Install
# For VS Code
code --install-extension alejmendez.grails-test-runner
# For Cursor
cursor --install-extension alejmendez.grails-test-runnerIf you want to install the extension from source code:
git clone https://github.com/alejmendez/grails-test-runner.git
cd grails-test-runner
npm install
npx @vscode/vsce packageThis generates a .vsix file. Then install it with:
code --install-extension *.vsix- Open any
*Spec.groovy,*Test.groovy, or*Tests.groovyfile in your Grails project - You'll see CodeLens buttons above your code:
- ▶ Run All Tests - Above the class declaration, runs all tests in the file
- ↺ Rerun All Tests - Same as above but with
--rerun-tasksto bypass Gradle cache - ▶ Run Test - Above each test method, runs only that specific test
- ↺ Rerun Test - Same as above but with
--rerun-tasksto bypass Gradle cache
- Click the button to execute the test in the integrated terminal
| Location | Gradle Command |
|---|---|
src/test/groovy/ |
./gradlew test --tests "..." |
src/integration-test/groovy/ |
./gradlew integrationTest --tests "..." |
- A Grails project with Gradle wrapper (
gradlew) - Groovy Language Support extension installed
- Spock/Grails test files following the
*Spec.groovy,*Test.groovy, or*Tests.groovynaming convention
| Command | Description |
|---|---|
Grails Test Runner: Run Test |
Run the test method at cursor position |
Grails Test Runner: Run Test Class |
Run all tests in the current file |
Grails Test Runner: Rerun Test |
Rerun the test method with --rerun-tasks |
Grails Test Runner: Rerun Test Class |
Rerun all tests in the current file with --rerun-tasks |
To contribute or modify the extension:
git clone https://github.com/alejmendez/grails-test-runner.git
cd grails-test-runner
npm install
npm run watch # Auto-compiles on savePress F5 in VS Code to launch the Extension Development Host.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Found a bug or have a feature request? Please open an issue on GitHub.
Enjoy testing your Grails applications! 🎉
