RobertOstermann / vscode-phpunit-extended

A Visual Studio Code extension to provide additional PHPUnit functionality.
https://marketplace.visualstudio.com/items?itemName=RobertOstermann.phpunit-extended-test-explorer
MIT License
4 stars 2 forks source link
phpunit-extension vscode vscode-extension

PHPUnit Extended With Test Explorer for VSCode

VS Marketplace Version VS Marketplace Installs VS Marketplace Rating

test-explorer

Setup

{
    "phpunit.args": [], // Shared arguments between commandLine and testExplorer
    "phpunit.configurationPath": "path/to/phpunit.xml",
    "phpunit.execPath": "path/to/phpunit", // If this value is set to '' it will try to use the composer phpunit installation.
    "phpunit.envVars": {
        // Here you can define the environment variables to be set before executing phpunit
        "XDEBUG_CONFIG": "idekey=VSCODE"
    },
    "phpunit.commandLine.args": [
        "--testdox"
    ],
    "phpunit.commandLine.excludedGroups": [
        // Groups to be excluded when running the TestSuiteWithExclusions command
    ],
    "phpunit.commandLine.scriptsAfterTests": {
        "ok": [
            {
            "command": "some-command-with-args",
            "args": ["-status=ok"]
            },
            "another-command-without-args"
        ],
        "error": []
    },
    "phpunit.commandLine.showOutput": "always",
    "phpunit.testExplorer.fileRegex": ".*(test|tests)\\w*\\.php",
    "phpunit.testExplorer.functionRegex": "(\\/\\*.*?(@test).*?\\*\\/\\s*?)|((public\\s+){0,1}function\\s+(test\\w*))",
    "phpunit.testExplorer.multilineFunctionRegex": true,
    "phpunit.testExplorer.folderPattern": "**/{test,tests,Test,Tests}/**/*.php",
    "phpunit.testExplorer.discoverAllTests": true
}

Settings

Name Description Default
phpunit.args This is useful for setting the configuration settings shared between the command line and the test explorer. {}
phpunit.configurationPath Path to phpunit.xml configuration file (if empty it tries to use find the nearest configuration file). ''
phpunit.envVars Set environment variables before running phpunit {}
phpunit.execPath Path to phpunit executable (if empty it tries to use composer installation). ""
phpunit.workingDirectory This determines the working directory of the process that runs the test commands. Set to Find to find the working directory based upon the phpunit.xml or phpunit.xml.dist path. Set to Parent to use the working directory of the parent process. "Find"
phpunit.commandLine.args This is useful for setting the command line configuration. []
phpunit.commandLine.excludedGroups Groups to be excluded from the tests []
phpunit.commandLine.scriptsAfterTests Scripts to execute after the tests run { "ok": [], "error": []}
phpunit.commandLine.showOutput Show the output console after the tests run (always, error, ok). "always"
phpunit.commandLine.showOutputInTerminal Re-run the test and show the output within a terminal instead of an output channel. This only occurs when the conditions in phpunit.commandLine.showOutput are met. false
phpunit.testExplorer.args This is useful for setting the test explorer configuration. Warning: some arguments, such as --testdox, will not allow the test explorer tests to pass. []
phpunit.testExplorer.discoverAllTests Determines whether to discover all tests immediately or discover them individually once opened in the editor. true
phpunit.testExplorer.fileRegex The regular expression used to determine test files. ".*(test\|tests)\\w\*\\.php"
phpunit.testExplorer.folderPattern A file glob pattern used to determine the folders to watch. Only used when discoverAllTests is set to true. "**/{test,tests,Test,Tests}/**/*.php"
phpunit.testExplorer.functionRegex The regular expression used to determine the functions within a file to test. (\\/\\*.*?(@test).*?\\*\\/\\s*?)\|((public\\s+){0,1}function\\s+(test\\w*))
phpunit.testExplorer.highlightFailureLocation Highlight the line causing the failure in a test. You can edit the theme color with the ID phpunit.failedTestBackground to change the background color. True
phpunit.testExplorer.multilineFunctionRegex Determines if the functionRegex looks at multiple lines. This is useful if the test is defined by an annotation comment. true
phpunit.testExplorer.parallelTests The number of tests to run in parallel in the test explorer. 0
phpunit.testExplorer.showOutput Show the output console after the tests run (always, error, never). "never"
phpunit.testExplorer.showOutputInTerminal Re-run the test and show the output within a terminal instead of an output channel. This only occurs when the conditions in phpunit.testExplorer.showOutput are met. false
phpunit.testExplorer.timeout The time (seconds) to allow a test to run. The default is no timeout. 0
phpunit.testExplorer.verboseTestExplorerOutput Setting to true forces test explorer to run individual tests instead of only running the class test to get output for each test. false

Combined Settings

Command Line Settings

Test Explorer Settings

How to use

Test Explorer

Run using the Testing tab.

test-explorer

Command Line

Run with (Cmd+Shift+P on OSX or Ctrl+Shift+P on Windows and Linux) and execute:

test-nearest

test-file

test-suite

test-pick

test-last

test-cancel

Credits / Links

License

The MIT License (MIT). Please see the license file for more information.