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
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
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/"
]
},
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With