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 change the order that migrations happen?

How to get a route to directly show a view?

How to eager load multiple levels of relationships in Eloquent?

How to set environmental variables in your .htaccess file

How to create random numbers in JS?

What is the difference between var, let and const in Javascript?

How to sort an array of dates and times?

How to install and use jpegoptim on Linux CentOS

How could you include a custom function for every single time PHP runs?

What are Template literals (Template strings) in JS?