-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to locate factory with name [default] #28378
Comments
Ensure your |
It's working fine. namespace given properly. when I execute
It's working fine. and store data in database. |
Can you paste your |
|
Hey, how have you solved it??? |
Same problem here! |
this most likely looks like a userland error, not a framework bug. the problem is most likely in your StockFactory class. please move this conversation over to: Laravel Slack (https://larachat.co/) Thanks! |
I had this issue during develop artisan console command trying to pass model class full name with namespace as command option. So I found out that the class path must start with back slash |
In my case it was because unit tests stubs in late laravel versions are extending The solution for me was to make my test extend the laravel TestCase class instead of phpunit TestCase. Something like this:
|
I faced exactly the similar issue. But is there anyway we can solve it by keeping It seems that we won't be able to make use of Laravel Model Factories in the Unit tests out of the box. |
@mitesh1409 the class So, if you want to use the framework features like factories on your Unit Tests, you should use
About that: as you can see here they changed the Unit tests
Well i think you could create your own base TestCase class which extends |
@wdarking So I believe if we want to make use of Model Factory feature in unit tests, then importing Thanks again :) |
- This ensures a factory can be used with tests. PHPUnit doesn't understand/use factories. See: laravel/framework#28378
Description:
As I defined an
App\Http\Models\Stock
model and it's working properly, But not working infactory
method.Steps To Reproduce:
The text was updated successfully, but these errors were encountered: