phpunit command doesn't work for laravel 4 on windows 7

前端 未结 11 1776
南笙
南笙 2020-12-15 06:06

I\'ve recently installed laravel and have written some tests in /tests directory but when I use phpunit at cmd in the same folder that phpunit.xml

相关标签:
11条回答
  • 2020-12-15 06:25

    If it says the following:

    $ phpunit tests/Feature/ExampleTest.php PHPUnit 3.7.21 by Sebastian Bergmann.

    Class 'tests/Feature/ExampleTest' could not be found in 'C:\xampp\htdocs\blog1\tests\Feature\ExampleTest.php'.

    Instead of typing tests/Feature/ExampleTest.php you say tests " \\Feature\\Example.test" because you're using windows, not mac. :) GL & HF

    Using just \ or / will give errors :)

    0 讨论(0)
  • 2020-12-15 06:25

    This working for me

    In double quotes this command in console windows

    "vendor/bin/phpunit"

    0 讨论(0)
  • 2020-12-15 06:26

    As Unnawut said, it doesn't work because vendor/phpunit/phpunit/phpunit is not a native Windows executable. You need a .bat or .cmd file that will basically call 'php phpunit'. There should be one in vendor/bin, but to make life easy, try this - create a file phpunit.bat (or .cmd) at the root of your site, containing this:

    @ECHO OFF
    SET BIN_TARGET=%~dp0/vendor/phpunit/phpunit/phpunit
    php "%BIN_TARGET%" %*
    

    Now you can call phpunit from the command line at the root of the site.

    0 讨论(0)
  • 2020-12-15 06:28

    The solution for me:

    php vendor/phpunit/phpunit/phpunit
    

    This, of course, assumes you've set up a php environment variable in Windows

    0 讨论(0)
  • 2020-12-15 06:35

    The phpunit executable is not in your project root folder, that's why it can't find it.

    Now I assume that you already have phpunit in your composer.json file, something like this:

    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    }
    

    When installed by composer, the package will be installed to vendor/vendor_name/package_name. So to run it at your project root, type this command:

    vendor/phpunit/phpunit/phpunit
    
    0 讨论(0)
提交回复
热议问题