laravel fatal error for TestCase not found

前端 未结 8 1911
离开以前
离开以前 2021-02-12 13:26
http://localhost/laravel/app/tests/ExampleTest.php

if i run laravel it shows the following error

Fatal error: Class \'TestCase\' not found in D

8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 13:48

    You haven't really given much information to go on here, but the specific problem is probably that you don't have an autoloader (thus the TestCase class that PHP is expecting isn't actually loaded. The underlying problem in turn is likely that you're trying to run ExampleTest.php directly on the terminal, whereas instead you must bootstrap a test environment correctly through Laravel and PHPUnit.

    You should find a phpunit.xml file in the root of your Laravel install. This file tells PHPUnit how to bootstrap and start executing tests for your application, so you should just be able to run phpunit on the command line in the root of your application and it should work.

    If that's not the issue, please do provide more detail for people to help with.

提交回复
热议问题