Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>TNG Test GeneratorNew to Visual Studio Code? Get it now.
TNG Test Generator

TNG Test Generator

Binary Dreams LLC

|
1 install
| (0) | Free
Generate tests for Ruby, Go, and Python projects
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

TNG VSCode Plugin

A Visual Studio Code extension for generating tests using TNG. Supports Ruby (Rails), Go, and Python projects. Generate tests directly from your editor with intelligent method detection and one-click test generation.

✨ Features

  • Multi-Language Support - Generate tests for Ruby, Go, and Python methods
  • Method-Level Testing - Generate tests for specific methods/functions with cursor detection
  • Status Bar Integration - Current method displayed with click-to-run functionality
  • Intelligent Context Detection - Command appears only when cursor is inside methods
  • Automatic Project Detection - Finds nearest Gemfile (Ruby), go.mod (Go), or pyproject.toml (Python)
  • Terminal Integration - Runs appropriate TNG command based on language
  • Enhanced Error Handling - Clear, actionable error messages with troubleshooting guidance
  • Smart Path Resolution - Handles Rails paths, Go modules, and Python packages correctly

Prerequisites

For Ruby Projects

  1. Install TNG gem: Add gem 'tng' to your Gemfile and run bundle install
  2. Get API key: Sign up at https://app.tng.sh/
  3. Configure: Run rails generate tng:install and set TNG_API_KEY environment variable

For Go Projects

  1. Install tng-go: Download from releases
  2. Get API key: Sign up at https://app.tng.sh/
  3. Configure: Run tng-go init to generate tng_config.yml and set your API key
  4. Place binary: Put tng-go binary in your project root or ensure it's in PATH

For Python Projects

  1. Install tng: pip install tng-python or download from releases
  2. Get API key: Sign up at https://app.tng.sh/
  3. Configure: Run tng init to generate tng_config.py and set your API key

Please reach out to support@tng.sh for help regarding installation and configuration, or for any other questions you may have.

Usage

Method-Level Test Generation

The extension works with Ruby, Go, and Python files:

  1. Open a file in your project (.rb, .go, or .py)
  2. Position cursor inside any method/function definition
  3. Status Bar shows current method name: $(symbol-method) create
  4. Generate test using any of these:
    • Click the status bar item
    • Right-click → "TNG: Generate Test"
    • Keyboard: Cmd+Shift+T (Mac) or Ctrl+Shift+T (Windows/Linux)
    • Command Palette: TNG: Generate Test

Commands generated:

Ruby:

bundle exec tng "app/controllers/users_controller.rb" "create"

Go:

./tng-go -f "internal/service/user.go" -m "CreateUser"

Python:

tng -f "app/services/user_service.py" -m "create_user"

How It Works

  1. Language Detection - Automatically detects Ruby (.rb), Go (.go), or Python (.py)
  2. Cursor Detection - Detects which method/function your cursor is inside
  3. Path Resolution - Finds the correct file path relative to project root
  4. Command Execution - Runs the appropriate TNG tool for your language
  5. Test Generation - Generates focused tests for the specific method

Command Availability

The "Generate Test" command only appears when:

  • ✅ File is Ruby (.rb), Go (.go), or Python (.py)
  • ✅ Cursor is positioned inside a method/function definition
  • ✅ Project root can be detected (Gemfile, go.mod, or Python config files)

Command Palette

Access via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):

  • TNG: Generate Test - Generate test for method under cursor

Configuration

The extension provides the following settings:

  • tng.showMethodStatus (default: true) - Show current method in status bar with click-to-run functionality

Examples

Ruby (Rails)

File + Method Command Generated
app/controllers/users_controller.rb → def create bundle exec tng "app/controllers/users_controller.rb" "create"
app/models/user.rb → def valid? bundle exec tng "app/models/user.rb" "valid?"
app/services/payment_service.rb → def process bundle exec tng "app/services/payment_service.rb" "process"

Go

File + Method Command Generated
internal/service/user.go → func CreateUser ./tng-go -f "internal/service/user.go" -m "CreateUser"
pkg/handler/auth.go → func (h *Handler) Login ./tng-go -f "pkg/handler/auth.go" -m "Login"
cmd/server/main.go → func startServer ./tng-go -f "cmd/server/main.go" -m "startServer"

Python

File + Method Command Generated
app/services/user_service.py → def create_user tng -f "app/services/user_service.py" -m "create_user"
src/models/user.py → async def validate tng -f "src/models/user.py" -m "validate"
tests/helpers.py → def setup_database tng -f "tests/helpers.py" -m "setup_database"

How It Works

The extension uses a clean, modular architecture with language-specific detection:

Project Detection

  • Ruby: Finds nearest Gemfile, falls back to workspace root
  • Go: Finds nearest go.mod, falls back to workspace root
  • Python: Finds pyproject.toml, setup.py, requirements.txt, or other Python config files

Method Detection

  • Language Server Protocol (LSP): Primary method using VS Code's built-in DocumentSymbol provider
    • Ruby LSP, Go LSP, Python LSP (Pylance)
  • Regex Fallback: If LSP unavailable, uses pattern matching
    • Ruby: Handles def, operators, class methods (self.method)
    • Go: Handles func, methods with receivers func (r *Type) Method
    • Python: Handles def and async def

Command Execution

  1. Detects language from file extension
  2. Finds method name at cursor position
  3. Resolves project root and relative file path
  4. Builds appropriate command for the language
  5. Executes in terminal with proper working directory

Requirements

  • VS Code 1.80.0+ (desktop only)
  • Language-specific tools:
    • Ruby: TNG gem with API key configured
    • Go: tng-go binary in project root or PATH
    • Python: tng command available (via pip or binary)

Troubleshooting

  • Command not showing: Ensure cursor is inside a method/function definition
  • "Place cursor inside a method": Extension requires cursor to be inside a method body
  • Command not found:
    • Ruby: Verify in terminal with bundle exec tng --help
    • Go: Check ./tng-go --help or ensure binary is in PATH
    • Python: Verify in terminal with tng --help
  • Project root not found: Open the project folder (containing Gemfile/go.mod/pyproject.toml) as workspace
  • API key issues: Set API key in respective config files
  • Method not detected: Install appropriate LSP extension (Ruby LSP, Go, Pylance)
  • Status bar not showing: Enable tng.showMethodStatus in VS Code settings

Support

  • TNG platform support: Contact us at app.tng.sh/contact

Happy testing! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft