Shane
Shane

Reputation: 2455

Laravel 5 phpunit is not running tests

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.

Upvotes: 3

Views: 3454

Answers (3)

Dimitri Acosta
Dimitri Acosta

Reputation: 1816

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.

Upvotes: 1

Shane
Shane

Reputation: 2455

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.

Upvotes: 8

Alexander Kerchum
Alexander Kerchum

Reputation: 532

You need to install phpunit globally: composer global require phpunit/phpunit

Then you can run phpunit from your project root.

Upvotes: 2

Related Questions