3

I create a laravel framework fresh copy from composer and when run on PHP Storm i m facing this error in PHP Storm

Fatal error: Class 'TestCase' not found in C:\xampp\htdocs\testproject\app\tests\ExampleTest.php on line 3

cd C:\xampp\htdocs\testproject Current working directory is 'C:\xampp\htdocs\testproject'.

phpunit

Cannot run program "phpunit" (in directory "C:\xampp\htdocs\testproject"): CreateProcess error=2, The system cannot find the file specified

PravinS
  • 2,640
  • 3
  • 21
  • 25
UMAIR ALI
  • 1,055
  • 5
  • 14
  • 25

3 Answers3

2

I had this problem in the past with Laravel 4 and 5. Turns out I was missing this in my composer.json.

Laravel 5:

"autoload-dev": {
    "classmap": [ "tests/TestCase.php" ]
},

Laravel 4:

"autoload-dev": {
    "classmap": [ "app/tests/TestCase.php" ]
},
Tommy
  • 21
  • 3
0

I think the way laravel is setup you need to be at the root of the specific project, then specify the rest to phpunit.

1.) alias phpunit='vendor/bin/phpunit'

Try changing your path to "C:\xampp\htdocs\testproject" then run "alias phpunit='vendor/bin/phpunit'" then run "phpunit app/tests/ExampleTest.php".

http://culttt.com/2013/05/20/getting-started-with-testing-laravel-4-models/

Tripp
  • 1
0

You have to run the phpunit in the folder where You have your tests.

Run this from the command line, from the root directory of the project:

phpunit app/tests/
Traveller
  • 399
  • 2
  • 20