What is the difference between integration and unit tests?

General Webdev and Programming Stuff: What is the difference between integration and unit tests?

Unit tests are designed to test a small part (often a function or method) of a system, in isolation (for example, testing a single method in a model class). Integration tests are more of a real-life test - for example, simulating a user visiting a URL and testing that it works as expected.

Unit tests are often simpler to write, and easier to debug. However, even if you know that a dozen well tested methods pass all of their tests, it does not mean that they will all work together, as they should, in the system as a whole.

That is why you also have integration tests, to test features as if you were a real user.

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about What is the difference between integration and unit tests?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the General Webdev and Programming Stuff language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to namespace a Laravel route group?

How to show a specific view file for certain error codes?

How to find the 2nd most common item in an array?

How to round a number in JS?

How to return JSON data to the user in Laravel?

How to set the Expires header in .htaccess

How to show (or log) all SQL queries executed by Laravel

How to get the type of a variable in JS?

How to pick what array_intersect function to use in PHP?

How to add a name prefix to all routes in a group?