From the course: Test-Driven Development in Django

Functional vs. unit tests

From the course: Test-Driven Development in Django

Start my 1-month free trial

Functional vs. unit tests

- [Instructor] Let's talk about the difference between functional and unit tests. Within the testing world these are the two main areas that your tests are going to fall under. So, functional tests. They deal with the way that a user interacts with your project. You can probably hear this as functionality. So some examples of this would include, a user goes to your homepage and they are going to see your restaurant's logo. The user goes to the order page on your website and they'll be able to order a pizza. If the user wants to change their order they can go in and say, I want olives instead of anchovies. Functional tests are making sure that users can do things with our website. Now this is in contrast to unit tests. Unit tests ensure that a small piece of your project is working as it should. Now these are much more technical. See if you can notice a difference in these examples. So within that same restaurant website that we've been talking about hypothetically an example of a unit test would be the ability to create a pizza object from the pizza class. Another one would be the function pizza_description() will appropriately tell the size and toppings of a pizza, and that if the user goes to a specific URL will have a specific view showing up for that. Not even necessarily the text on that page but that it's loading a particular view file. So if you come back and look at these two differences, functional tests are things that the user would know and care about. Can they order a pizza? A unit test is something probably that the user would no idea about but the developer would. For example, ensuring that the pizza description function is working properly. A good way to gauge this at the end is to say, if the user wouldn't know about it it's a unit test. If the user would know about it, it's a functional test.

Contents