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 find the 2nd most common item in an array?

How to destroy or remove a cookie in PHP

How to check if a object has a static variable defined?

How to get the last character of a string in JS?

What are the SPL Iterators in PHP?

How to undelete a soft deleted Eloquent row?

How to check if a (blade) view file exists

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

What does 'final class' and 'final function' (final method) mean in PHP?

How to find the index of a value in an array in JS?