You will get an error if you don't write test at the beginning of a function in Laravel and PHPunit
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
⇨ Here is the table of contents for Laravel articles
The error that often occurs is as follows.
No tests found in class "Tests\Feature\PostTest".
As the error message suggests, it means that no tests were found inside the class.
Conclusion
① Add test at the beginning of the function
/**
* A basic feature test example.
*
* @return void
*/
public function test__Article_Posting()
{
// Test description
}
② Write @test above the function
/**
* A basic feature test example.
* @test
* @return void
*/
public function Article_Posting()
{
// Test description
}
I prefer @test.
What about in your workplace?
Related articles
How to Set Up Scheduled Tasks (Scheduler) in Laravel
When to Use the make:command in Laravel?
Summary
That's it.
I haven't been writing many tests lately because I'm mostly working on the frontend and only about 10% on the server side. I encountered (and got stuck on) this error, so I wrote about it.
For feedback or complaints, please contact me via Twitter DM.
That's all!
Popular articles
Deploying a PHP7.4 + Laravel6 Project to AWS EC2
Implementing Breadcrumbs in Laravel with laravel-breadcrumbs