Skip to content

Honemo/Tests-vs-ext

Repository files navigation

PHP Test Collections Explorer

A powerful VS Code extension for exploring, organizing, and executing PHP test collections with comprehensive Docker support. โš ๏ธ IMPORTANT: This extension ONLY works with workspace settings. User settings are ignored.

Version VS Code PHP Docker

โœจ Features

  • ๐Ÿ“ Collection Organization - Group your tests by folders (Unit, Feature, Integration...)
  • ๐ŸŽฏ Granular Execution - Run individual tests, entire files, or complete collections
  • ๐Ÿณ Native Docker Support - Seamless execution in containers with automatic command transformation
  • ๐Ÿ“Š Visual Status - Icons for passed/failed/running tests with detailed error information
  • ๐Ÿ” Error Details - Complete visualization of PHP failures and errors
  • โšก Smart Cache - Optimized scanning with automatic updates
  • ๐Ÿ“‹ Complete Logging - All commands tracked in dedicated Output tab
  • ๏ฟฝ๏ธ Terminal Management - Intelligent terminal reuse and cleanup

๐Ÿš€ Quick Start

  1. Install: Download php-test-collections-explorer-0.1.0.vsix
  2. VS Code: Ctrl+Shift+P โ†’ Extensions: Install from VSIX...
  3. Open a PHP project with tests
  4. View: "PHP Test Collections" appears automatically in the Test tab

Install by script

#Run in your terminal
chmod +x install.sh
./install.sh

๐ŸŽฎ Usage

Intuitive Tree View

๐Ÿณ Docker Integration Tests (5 files)
โ”œโ”€โ”€ โœ… AuthTest.php (3 tests)
โ”‚   โ”œโ”€โ”€ โœ… testLogin
โ”‚   โ”œโ”€โ”€ โŒ testFailedLogin  
โ”‚   โ””โ”€โ”€ โšช testLogout
โ””โ”€โ”€ โœ… DatabaseTest.php (2 tests)

๐Ÿ“š Unit Tests (8 files)
โ”œโ”€โ”€ โœ… UserTest.php (4 tests)
โ””โ”€โ”€ ...

Simple Configuration

{
  "phpTestCollections.collections": [
    {
      "name": "Unit Tests",
      "path": "tests/Unit",
      "command": "vendor/bin/phpunit tests/Unit",
      "useDocker": false
    },
    {
      "name": "Docker Integration",
      "path": "tests/Integration",
      "command": "vendor/bin/phpunit tests/Integration", 
      "useDocker": true,
      "dockerImage": "my-app"
    }
  ],
  "phpTestCollections.logLevel": "info"
}

Execution Types

Action Result Generated Command
โ–ถ๏ธ Individual test testLogin only --filter "UserTest::testLogin"
โ–ถ๏ธ Complete file All tests in file --filter "UserTest"
โ–ถ๏ธ Collection Entire test suite Full command

๐Ÿณ Docker Support

Automatic command transformation:

  • Local: vendor/bin/phpunit --filter "UserTest" tests/Unit/UserTest.php
  • Docker: docker exec my-app vendor/bin/phpunit --filter "UserTest" tests/Unit/UserTest.php

๐Ÿ“Š Test Status

Icon Status Description
โœ… Passed Test successful
โŒ Failed Assertion failed
๐Ÿ’ฅ Error PHP error
๐Ÿ”„ Running Executing
โšช Unknown Not tested

๐Ÿ”ง Advanced Configuration

Laravel Project

{
  "phpTestCollections.collections": [
    {
      "name": "Feature Tests",
      "path": "tests/Feature",
      "command": "vendor/bin/phpunit --testsuite=Feature"
    },
    {
      "name": "Unit Tests", 
      "path": "tests/Unit",
      "command": "vendor/bin/phpunit --testsuite=Unit"
    }
  ]
}

Docker Compose

{
  "name": "Tests Container",
  "path": "tests",
  "command": "vendor/bin/phpunit",
  "useDocker": true,
  "dockerImage": "my-project_app"
}

Symfony Project

{
  "phpTestCollections.collections": [
    {
      "name": "Unit Tests",
      "path": "tests/Unit",
      "command": "vendor/bin/phpunit tests/Unit"
    },
    {
      "name": "Integration Tests",
      "path": "tests/Integration", 
      "command": "vendor/bin/phpunit tests/Integration"
    }
  ]
}

๐Ÿ“‹ Logs and Debugging

Output System

  • Output Tab: "PHP Test Collections"
  • Configurable Levels: error | warn | info | debug
  • Real-time Filtering: Only relevant messages displayed
  • Traced Commands with timestamps
  • Detailed Docker errors

Logging Levels

  • ๐Ÿ”ด Error: Critical failures only
  • ๐ŸŸก Warning: + Configuration issues
  • ๐Ÿ”ต Info: + Test execution (default)
  • ๐ŸŸฃ Debug: + Internal operations

Logging Configuration

Control the verbosity of extension output with configurable logging levels:

{
  "phpTestCollections.logLevel": "info"
}
Level Description Output
"error" Critical errors only โŒ Fatal errors, crashes
"warn" Errors + warnings โŒ + โš ๏ธ Configuration issues, missing files
"info" Standard output (default) โŒ + โš ๏ธ + โ„น๏ธ Test execution, cache operations
"debug" Verbose development mode โŒ + โš ๏ธ + โ„น๏ธ + ๐Ÿ” Internal operations, parsing details

Examples:

  • Production: "error" - Only critical issues
  • Development: "debug" - Full diagnostic information
  • CI/CD: "warn" - Balanced output for automation
  • Default: "info" - Perfect for daily usage

Quick Actions

  • Force refresh: ๐Ÿ”„ Button
  • Change log level: VS Code Settings โ†’ "PHP Test Collections"
  • View logs: Output โ†’ "PHP Test Collections"

๐Ÿ› ๏ธ Development

# Clone the repo
git clone [your-repo]
cd Tests-vs-ext

# Install dependencies
npm install

# Compile
npm run compile

# Launch dev mode
F5 (Extension Development Host)

# Create package
vsce package

#Generate your own package
npx @vscode/vsce package

๐ŸŽฏ Use Cases

โœ… PHP Developers working with PHPUnit
โœ… Laravel/Symfony projects with organized tests
โœ… Docker environments for integration
โœ… E2E testing with complex configurations
โœ… Teams needing consistency in test execution

๐Ÿ“ž Support

  • ๐Ÿ“‹ Logs: Output โ†’ "PHP Test Collections"
  • ๐Ÿ” Debugging: Check the usage guide
  • ๐Ÿ› Issues: Create an issue

๐Ÿ—๏ธ Architecture

Modular Design (6 Services)

  • ๐Ÿ“ types/: Centralized TypeScript interfaces
  • ๐Ÿ“ LoggingService: Configurable logging system with 4 levels (113 lines)
  • ๐Ÿ’พ CacheService: JSON cache management (228 lines)
  • ๐Ÿš€ TestRunner: PHPUnit execution engine (492 lines)
  • ๐Ÿ” TestParser: PHP parsing with dual detection (190 lines)
  • ๐Ÿ‘๏ธ FileWatcher: Real-time file monitoring (202 lines)

Performance Metrics

  • Code Reduction: 68% (1877 โ†’ 595 lines in main file)
  • Bundle Size: 85.3 KiB (optimized)
  • Cache System: Workspace-specific JSON persistence
  • Compilation: Zero TypeScript errors

๐Ÿ“š Documentation

๐Ÿ”— Requirements

  • VS Code ^1.105.0
  • PHP project with PHPUnit tests
  • Optional: Docker for containerized execution

๐Ÿš€ Transform your PHP testing workflow with a powerful visual interface!

About

Extension to manage and run test collections

Resources

License

Stars

Watchers

Forks

Packages

No packages published