Giter Club home page Giter Club logo

vscode-yet-another-phpunit's Introduction

Build Status Marketplace Version

Yet Another PHPUnit

This extension is an enhanced fork-n-remake of Better PHPUnit. The major part of the code is taken from that repository.

Installation

Download it from the Marketplace or search for Yet Another PHPUnit in your VSCode editor extension panel.

Demo GIF

Features

  • Color output!
  • SSH support
  • Docker support
  • Run individual methods
  • Run a single file
  • Run tests inside a folder
  • Run all the tests
  • Test failures are displayed in the "Problems" panel for quick access
  • CodeLens to run single tests just in one click

Note: this plugin registers "tasks" to run phpunit, not a command like other extensions. This makes it possible to leverage the problem output and color terminal.

Run a test method:

  • Click Run test above the method name
    or
  • Place your cursor on the method name, open the command menu with cmd+shift+p and select Yet PHPUnit: Run

Run a test file:

  • Click Run class tests above the class name
    or
  • Right click on the file in the "Explorer" tab on the left sidebar and select Run File Tests
    or
  • Place your cursor on the class name, open the command menu with cmd+shift+p and select Yet PHPUnit: Run

Run a folder tests:

  • Right click on the folder in the "Explorer" tab on the left sidebar and select Run Tests Inside Folder

Run all the tests:

  • Open the command menu: Cmd+Shift+p
  • Select: Yet PHPUnit: Run All

Re-run last executed test:

  • Open the command menu: Cmd+Shift+p
  • Select: Yet PHPUnit: Re-Run Test

Global configuration variables

Name Type Default Description
yet-phpunit.commandSuffix string null Content (flags, arguments) to be appended to PHPUnit command. For example, if you want to use --testdox this is the correct place.
yet-phpunit.phpunitBinary string null A custom path of PHPUnit binary file. By default it will be auto-discovered from vendor folder.
yet-phpunit.codelens boolean true Set it to false to disable Code Lens, namely the clickable label "Run test" above methods and classes.

How to use these values

Open your settings (or Workspace settings), switch to JSON and put them like this:

{
    "yet-phpunit.commandSuffix": null,
    "yet-phpunit.phpunitBinary": null,
    "yet-phpunit.codelens": true
}

SSH configuration

If you plan to use SSH, take a look also to new VSCode feature: Remote development.

Variables to set up tests over SSH (for VMs like Laravel Homestead):

Name Type Default Description
yet-phpunit.ssh.enable boolean false Set it to true to enable SSH.
yet-phpunit.ssh.binary string ssh Custom SSH agent binary, for example plink.exe (PuTTY ssh).
yet-phpunit.ssh.host string null SSH hostname.
yet-phpunit.ssh.user string null SSH username.
yet-phpunit.ssh.port number 22 SSH port.
yet-phpunit.ssh.options string null Additional SSH options (arguments, flags etc.).
yet-phpunit.ssh.shellAppend string null Stuff to append after the SSH and PHPUnit command. For example, to enable color on Windows this is the right place.
yet-phpunit.ssh.paths object {} The SSH path map. Keys are local (host) paths and values are remote (guest) paths.

Example of configuration

If you use PuTTy, you have to use plink as binary file (it's part of with PuTTy)

{
    "yet-phpunit.ssh.enable": true,
    "yet-phpunit.ssh.binary": "plink.exe",
    "yet-phpunit.ssh.host": "host",
    "yet-phpunit.ssh.user": "user",
    "yet-phpunit.ssh.port": "22",
    "yet-phpunit.ssh.options": null,
    "yet-phpunit.ssh.shellAppend": null,
    "yet-phpunit.ssh.paths": {
        "/your/local/path": "/your/remote/path"
    }
}

Docker

Variables to set up tests in a Docker container:

Name Type Default Description
yet-phpunit.docker.enable boolean false Set it to true to enable Docker support.
yet-phpunit.docker.command string null Command base for Docker, for example docker exec your-container. This is required if you enable Docker.
yet-phpunit.docker.paths object {} The SSH path map. Keys are local (host) paths and values are remote (guest) paths.

Example of configuration

Example of configuration for an already running Container:

{
    "yet-phpunit.docker.enable": true,
    "yet-phpunit.docker.command": "docker exec <container-name>",
    "yet-phpunit.docker.paths": {
        "/your/local/path": "/your/remote/path"
    },
}

Example of configuration to start up a container with Docker Compose and kill it when finished:

{
    "yet-phpunit.docker.enable": true,
    "yet-phpunit.docker.command": "docker-compose run --rm <container-name>",
    "yet-phpunit.docker.paths": {
        "/your/local/path": "/your/remote/path"
    },
}

Tip: if you want to run Docker over a SSH session just should use both options ssh.enable and docker.enable together.

Roadmap: what's next?

This is what I'd love to implement in the future:

  • Run a single suite tests
  • Panel on left sidebar to see suites and available tests
  • Re-run failures

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.