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

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.


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

What are the SPL Iterators in PHP?

How to change the order that migrations happen?

How does PHP compare objects?

How to select what columns to return when calling ::all()

Why should you update APP_URL from from http://localhost?

Set PHP config Variables (like ini_set) with .htaccess

What is the loop variable in a @foreach loop in Blade?

How to eager load multiple levels of relationships in Eloquent?

What is snake case?

How to sort an array of dates and times?