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 add a name prefix to all routes in a group?

301 Redirect a single URL in .htaccess to a new location

How to have a whitelist of IP addresses that can access files in .htaccess

How to use subdomains as parameters in your routes (or in your web.php file)

How to disable file hotlinking in Apache with .htaccess

How to set custom HTTP headers in Apache (by editing .htaccess)

How to destroy or remove a cookie in PHP

Push vs Pop vs Shift vs Unshift

How to namespace a Laravel route group?

When is __destruct called in PHP?