Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel fatal error for TestCase not found

Tags:

php

laravel

http://localhost/laravel/app/tests/ExampleTest.php

if i run laravel it shows the following error

Fatal error: Class 'TestCase' not found in D:\xampp\htdocs\laravel\app\tests\ExampleTest.php on line 3 , any idea

like image 897
Steve Bals Avatar asked Feb 12 '14 11:02

Steve Bals


3 Answers

Run following command in your project's root directory

phpunit app/tests/

Update:

You can also run with the following command if phpunit is not installed on your machine. Which is also better to avoid version differences between team mates.

vendor/bin/phpunit

enter image description here

like image 145
Farid Movsumov Avatar answered Nov 01 '22 23:11

Farid Movsumov


Check if your tests directory is listed on the classmap property of your composer.json file.

If not add it and run composer dump-autoload.

"autoload-dev": {
    "classmap": [
        "tests",
        "database/"
    ]
},
like image 14
Álvaro Guimarães Avatar answered Nov 01 '22 22:11

Álvaro Guimarães


In my case, i noticed that my root folder not contained the phpunit.xml file.

Solve it including the following code in phpunit.xml at the root folder:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="bootstrap/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
>
    <testsuites>
        <testsuite name="Application Test Suite">
            <directory>./app/tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>
like image 6
Wallace Maxters Avatar answered Nov 01 '22 23:11

Wallace Maxters