Articles

Let's talk Tech!

Test-Driven Development (TDD) - Software quality assurance

Test-Driven Development (TDD) - Software quality assurance

Test-driven development (TDD) is a software engineering practice that involves two other practices: Writing the tests first (Test First Development) and then creating and modifying the code in successive stages (Refactoring). The purpose of test-driven development is to achieve clean code that works. TDD is a software development process relying on software requirements being converted to test cases before the software is fully developed, and tracking all software development by repeatedly testing the software against all test cases. This is as opposed to software being developed first and test cases being created later.

Most programmers understand the fact that it is a good thing to write tests for the code they develop. Some likely have an idea of why it is essential, and some even know how to do it. However, there is always a group of people where there is a wide gap of understanding between why it is essential to have tests and how to carry out those in real application development. Laravel offers out-of-the-box testing tools such as PHPUnit, Mockery, Faker, and Dusk to narrow down this gap among PHP programmers.

PHPUnit is used for Unit tests development, whereas Mockery is used for mocking a database session object, repository, or just another dependent class, etc. Faker is to create fake data for testing purposes. Dusk is a frontend testing framework used for testing a JavaScript application.

To make things easier, the Laravel application gets pre-packaged with a sample application test that can execute successfully when building the application. This denotes that no additional configuration is expected from the programmers to set up the basic test environment required for your application.