I have installed PHP Unit and done everything the instructions tell me.
I'm told that I can just run:
$ phpunit
...and it will work. I may need to specify the config file and I can do that.
I have changed the directory to the PHP Unit folder, but nothing.
I am using Mac's Terminal if this means anything.
I have tried (with the error shown):
$ phpunit - $: command not found
phpunit - phpunit: command not found
php phpunit - ...doesn't return an error, but doesn't do return anything
% phpunit - fg: %: no such job
Also, the folder structure is like this:
- phpunit
- php-code-coverage
- php-file-iterator
- php-text-template
- php-timer
- php-token-stream
- phpunit
- phpunit-mock-objects
phpunit.php
- PHPUnit (folder)
- various things inside
... what am I actually running? The outer folder, inner folder or the phpunit.php file?
I must be doing something wrong?
My question: How'd you install PHPUnit? By "hand" (download it and just unzip it), via PEAR, ...?
Try executing (inside the phpunit folder):
./phpunit
Make sure the path where the phpunit executable lies is added to your $PATH variable.
A similiar question on SO on how to install phpunit can be found here, general installation instructions here.
Related
I'm trying to run phpspec but when I do a command phpspec run inside root project folder it just prints:
-bash: phpspec: command not found
But when I do composer show -i it shows it's installed (because it's in package.json):
phpspec/php-diff v1.0.2 A comprehensive li...
phpspec/phpspec 2.5.3 Specification-orie...
phpspec/prophecy v1.6.1 Highly opinionated...
What's wrong?
You probably need to add the path to the executable to your $PATH or, when you call it...call it by the full path to phpspec (something like ./vendor/bin/phpspec run)
I'm new to Lumen (and Laravel). I've created a project with Composer and now I'm trying to get PHPUnit to work.
I'm following a book, where it should be possible to run a default passing test by typing vendor/bin/phpunit in the terminal, but it gives the error:
'vendor' is not recognized as an internal or external command,
operable program or batch file
I've checked that the phpunit file is actually there and that phpunit is added as dependency in my composer.json file. I've also tried ./vendor/bin/phpunit and vendor/bin/phpunit/phpunit, but with the same result.
I've searched Google to find a solution, but everyone else seem to have issues when running phpunit (wihout vendor/bin) and the solution is to use the full path vendor/bin/phpunit, but since I'm already doing that, it does not fix my problem.
I'm using PHPStorm on a Windows machine and running the PHP server via PHPStorm. I've not modified the default Lumen project.
Any help is greatly appreciated!
UPDATE:
Trying php vendor/bin/phpunit gives the following error:
You need to set up the project dependencies using the following
commands:
wget http://getcomposer.org/composer.phar
php composer.phar install
I'm not sure what that means, since I've already installed Composer. I used Composer to create the project and I haven't changed the dependencies from the default.
I had the same problem, for Windows it's vendor\bin\phpunit ;)
It turned out that some symlinks and permissions were not installed properly in the default project. I tried deleting the entire vendor/ directory and run composer install.
Now I can run phpunit with the command vendor\bin\phpunit (because I'm running on Windows - thanks Nizarii)
try this:
php vendor/bin/phpunit
Try putting php in front of the phpunit path like so:
php vendor/bin/phpunit
I'm been at this for days with no success. Running Laravel 5.1.
As I understand according to the Laravel doc.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit. Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. Its does not actually run any tests.
I searched more and came across a post that mentioned it could be a symlink issue. I followed the instructions in the post with no success. From memory I installed Laravel from composer so the symlink should not be an issue anyway.
These instructions involved deleting various files. I did notice that composer was pulling files from its cache when updating. So I cleared its cache and followed the process again. Still no success.
What are the tests not running? I'm at my wits end. Especially since its is supposed to run easily out the box.
In the end I was not calling the bat file correctly. I was running
C:\localhost\myProject\vendor\bin> phpunit
Instead I needed to run
C:\localhost\myproject> call vendor\bin\phpunit
Hence it now is referencing the phpunit.xml file with the test location information.
You need to install phpunit globally:
composer global require phpunit/phpunit
Then you can run phpunit from your project root.
You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit, that way the tests will execute the way they should be and you could get feedback in case it fails.
For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests.
I have installed PHPunit using composer. The application has unit test cases. from my project folder when i do a "phpunit" it gives me an error saying phpunit not found..but if i do a "./vendor/bin/phpunit" it will work. Any idea how to fix this ?
You need to add PHPUnit to your path. Include the ./vendor/bin/phpunit into your PATH environment (to be searched when looking for programs) in your OS.
I had the same problem and got tired of fiddling with PATHs on all my machines, so I wrote a small tool that makes composer behave a bit more like PEAR did:
https://github.com/flack/poser
You can use it to install Composer packages globally by running:
poser require phpunit/phpunit
Afterwards, calling phpunit on the shell will work as expected.
After a fresh symfony2 install i can run phpunit -c app/ and phpunit tests the included demo application: OK (1 test, 1 assertion).
But i receive no output (even with verbosity) when i run phpunit -c vendor/symfony/ as described here: http://symfony.com/doc/2.0/contributing/code/tests.html.
Does anyone know how to make this work?
PHPUnit: 3.6.2
PHP: 5.3.8
Symfony: 2.0.5
Testing twig, doctrine and other plugins works as expected (although doctrine tests fail for some reason).
If you have no output it's maybe because you configured php not to display errors.
You must install the vendors using the vendors.php script before lauching the Symfony test suite:
$ php vendor/symfony/vendors.php
Are you running the tests using the provided phpunit.xml.dist configuration file?
From your projects root directory:
$ phpunit --configuration app/phpunit.xml.dist vendor/symfony/tests
That should add an autoloader for vendors.