DEV Community

Morcos Gad
Morcos Gad

Posted on

Testing in Laravel

Great news, I found this article https://laravel-news.com/how-to-start-testing that explains simple steps for everyone who wants to enter the world of Testing in Laravel by PHPUnit and PEST and delve deeper into it, and this article will only put you on the first path and I will not talk much about the importance of Testing.

  • PEST: New Popular Alternative to PHPUnit
namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    public function test_the_application_returns_a_successful_response()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}
Enter fullscreen mode Exit fullscreen mode

Do you know how the same test would look with PEST

test('the application returns a successful response')->get('/')->assertStatus(200);
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.

Top comments (1)

Collapse
 
malisoft profile image
malisoft

are there a command to execute only a specific test file? pleace