title: Laravel 5.7 Unable to locate factory with name [default] [App\User]
body: <p>What's going on with Laravel 5.7 Factories? When I run the factory on <code>php artisan tinker</code> it works fine. But when I use it with Unit Tests it throws an error:</p>
  
  <blockquote>
    <p><em><code>Unable to locate factory with name [default] [App\User]</code></em></p>
  </blockquote>
  
  <p>Here's my Unit Test</p>
  
  <pre><code>&lt;?php
  
  namespace Tests\Unit;
  
  use Tests\TestCase;
  use Illuminate\Foundation\Testing\RefreshDatabase;
  use Illuminate\Foundation\Testing\DatabaseTransactions;
  use \App\User;
  
  class UserTest extends TestCase
  {
      use DatabaseTransactions;
  
      public function setUp()
      {
          $this-&gt;user = factory(User::class, 1)-&gt;create()-&gt;first();
      }
  
      /**
       * @test
       */
      public function a_sample_test()
      {
          $this-&gt;assertTrue(!empty($this-&gt;user));
  
      }
  }
  </code></pre>
  
  <p>And <code>UserFactory</code> was generated by running
  <em><code>php artisan make:factory UserFactory --model=User</code></em></p>
  
  <p>This is my factory for User on /database/factories</p>
  
  <pre><code>&lt;?php
  
  use Faker\Generator as Faker;
  
  $factory-&gt;define(\App\User::class, function (Faker $faker) {
      return [
          'name' =&gt; $faker-&gt;name,
          'email' =&gt; $faker-&gt;unique()-&gt;safeEmail,
          'password' =&gt; bcrypt('secret'),
          'remember_token' =&gt; str_random(10),
      ];
  });
  </code></pre>
  
  <p>I've run to similar questions here on SO, but they all seem to have the same answer to use <code>\App\Model::class</code> instead of <code>App\Model::class</code>. </p>