Your class name needs to end in 'Test'. Try 'UserAddTDDTest'.
Laravel Testing not pickup new test cases.
Hi Guys,
I am pretty new to Laravel testing. I am going to use Laravel testing for both TDD and BDD. I just found a very strange issue that Laravel testing not picking up new test cases. I tried both just run "phpunit" or command "vendor/bin/phpunit"
Please see my source code below:
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions;use App\Repositories\UserRepository;
class UserAddTDD extends TestCase { // Use Database transactions will ensure no database touched. use DatabaseTransactions;
protected $faker;
protected $userRepository;
public function __construct() {
$this->userRepository = new UserRepository();
$this->faker = Faker\Factory::create();
}
/**
* A basic test example.
*
* @return void
*/
public function testUserAdd()
{
$data = array(
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'email' => $this->faker->email,
'password' => str_random(10),
'calendar_color' => $this->faker->hexcolor,
'email_signature' => '<div>als,dfjaslkdf</div>',
'phone' => $this->faker->phoneNumber,
'created_by' => $this->faker->randomDigitNotNull,
'updated_by' => $this->faker->randomDigitNotNull,
);
$user = $this->userRepository->create($data);
$this->assertTrue(isset($user->id));
}
}
If I copy paste to ExampleTest.php and change the class name to ExampleTest.php, it got picked up. Otherwise, this will never be executed.
Anyone can help me with this?
Screenshot: http://grab.by/OyrE http://grab.by/OyrG
We can see only 1 test case got pickup which is ExampleTest.php
Many Thanks,
Please or to participate in this conversation.