Laravel

Testing & PHPUnit

PHPUnit basics, Unit vs Feature tests, Database testing, HTTP assertions, Mocking & faking, Test organization

24 pertanyaan wawancaraยท
Mid-Level
1

What is PHPUnit in the context of Laravel?

Jawaban

PHPUnit is the standard unit testing framework for PHP, natively integrated into Laravel. It provides the assertions, annotations, and structure needed to write and run automated tests. Laravel extends PHPUnit with additional features like HTTP helpers, database traits, and framework-specific test methods to facilitate testing web applications.

2

Which Artisan command runs all tests in a Laravel application?

Jawaban

The php artisan test command runs all PHPUnit tests in the Laravel application. This command internally uses PHPUnit but offers more readable output and additional Laravel-specific options. It is also possible to directly use the vendor/bin/phpunit command for more granular control over test execution.

3

In which directory are tests located by default in a Laravel application?

Jawaban

Tests are located in the tests directory at the root of the Laravel project. This directory contains two main subdirectories: Feature for functional tests that test complete behaviors, and Unit for unit tests that test isolated classes or methods. This organization clearly separates different test types and facilitates maintenance.

4

What is the difference between a Unit test and a Feature test in Laravel?

5

Which Artisan command creates a new Feature test in Laravel?

+21 pertanyaan wawancara

Kuasai Laravel untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis