DEV Community

Morcos Gad
Morcos Gad

Posted on

3 1

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.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (1)

Collapse
 
malisoft profile image
malisoft

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

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay