jeroenvanrensen's avatar

Laravel TDD Unit test: Unable to locate factory for [App\Reply]

Hi everyone,

I'm new to Laravel and I'm following this tutorial on Laracasts. I'm trying to run a unit test to see if a Reply belongs to a User, but it fails.

This is my error message:

1) Tests\Unit\ReplyTest::it_has_an_owner
InvalidArgumentException: Unable to locate factory for [App\Reply].

Here's my unit test class:

<?php

namespace Tests\Unit;

use PHPUnit\Framework\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ReplyTest extends TestCase
{
    use RefreshDatabase;

    /** @test */
    public function it_has_an_owner()
    {
        $reply = factory('App\Reply')->create();

        $this->assertInstanceOf('App\User', $reply->owner);
    }
}

I've got no idea what to do, so I hope you can help me. If you need more information, please ask me.

Thanks for reading! Jeroen

0 likes
2 replies
jeroenvanrensen's avatar

Hi Nakov,

Thank you very much for your answer! Now it's working!

Please or to participate in this conversation.