I have create a test via terminal with command :
php artisan make:test UserTest
Now i want to run the test with the following command :
vendor/bin/UserTest
But it returns
bash: vendor/bin/UserTest: No such file or directory
PHPunit is Installed. I have checked.
Am i missing something ?
Run tests with this command from Laravel root project directory:
vendor/bin/phpunit
If you want to run custom package tests, use:
vendor/bin/phpunit packages/name/package/
Related
I'm running unit test using phpunit on laravel 7
After running command vendor/bin/phpunit then tests/bootstrap.php will be executed.
in that file,we can see event:cache inside the array $commands
$commands = ['event:cache']
The result in the terminal shown as follows
The command "event:cache" does not exist
Has the name of the command changed for Laravel 7?
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 exists, it says 'vendor' is not recognized as an internal or external command I'm using windows 10. what should I do?
This is linux based code..
$ vendor/bin/phpunit
Try this for windows..
vendor\bin\phpunit
Please try this command for windows:
php vendor/phpunit/phpunit/phpunit
Install dependencies via composer
$ composer update
Run tests
$ vendor/bin/phpunit
When Gitlab-ci execute the script : php vendor/phpunit/phpunit --colors --verbose --configuration phpunit.xml
PHPUnit seems to do nothing this is the output from Gitlabci :
$ php vendor/phpunit/phpunit --colors --verbose --configuration phpunit.xml
Job succeeded
I've tried with no option for PHPUnit and it's still the same i don't understand why, it's working properly on my local
I'm working with the framework Laravel
If you installed phpunit with composer and haven't changed the bin-dir configuration, the path to phpunit is vendor/bin/phpunit:
php ./vendor/bin/phpunit
You should also be able to simply call the phpunit script directly:
./vendor/bin/phpunit
Assuming your current working directory is the root of your project.
this is my current status:
I have a running symfony environment, based on a docker image. Everything works fine and from PHPStorm i can execute phpunit tests. But i want to execute them manually from console.
After i started all services by using docker-compose up --build, i login into the phpfpm service by: docker-compose exec -it phpfpm bash
then i move into my symfony project folder that contain all folders and files like "app/, bin/, vendor/, ... composer.json... etc"
I could go by calling vendor/phpunit/phpunit/phpunit but i want to get a shorter way. Is there any chance, maybe calling bin/phpunit or something like this?
Thanks in advance,
Max
PHPUnit has that script in the own composer.json, so bin (or vendor/bin) directory should contains a relevant symlink after running composer install. Also check your composer.json for bin-dir settings.
At least you always can create a symlink:
$ ln -s vendor/phpunit/phpunit/phpunit phpunit
According to the symfony docs the preferable way of using phpunit is by .phar file. In this way you can download phpunit as a .phar file and it will works both outside and inside docker container.
wget https://phar.phpunit.de/phpunit-6.0.phar
php phpunit-6.0.phar --version
Type now php phpunit-6.0.phar to run tests.
I'm new to the Codeception framework and trying to run the unit test scripts from this directory:
tests/codeception/frontend/unit
DB configuration for testing has been done in config-local.php.
Now, my question is how to run the test scripts? I've tried to run the following commands from the terminal:
frontend tests
cd frontend
codecept build
codecept run
But it says Codecept: command not found.
Install Codeception via composer:
$ composer require "codeception/codeception"
From now on Codeception (with installed PHPUnit) can be run as:
$ php vendor/bin/codecept
Next, initialize your testing environment:
$ php vendor/bin/codecept bootstrap
Finally, run the following commands from the yii2 tests/codeception/frontend folder:
$ php vendor/bin/codecept build
$ php vendor/bin/codecept run
Follow this Quickstart Guide to read more about Codeception installation process.
Important note: if you want codecept command to work from the command line:
codecept bootstrap
codecept run
... then you need to configure the $PATH variable properly.
The fallowing examples need installation codecept globally. This method work for the current user and linux systems.
composer global require "codeception/codeception=2.1.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
You can set new path $PATH: in /home/user/.bashrc
export PATH="$PATH:/home/user/.config/composer/vendor/bin"
or set alias in .bashrc
alias codecept="/home/user/.config/composer/vendor/bin/codecept"
Now you can use simply
codecept build
codecept run