Test-Driven Development in Django
Test-Driven Development philosophy:
- Don’t write ay code until you have a failing test
- Write code to pass a test
Functional test vs Unit tests
Functional test
Deal with the way a user will interact with your project, also known as functionality
In short, it is:
- Things the user would know and care about
- like find a recipe
eg:
- if the user goes to the homepage of foodiejournals.com, they will see the carousel.
- If the user goes to the login page, they can login.
- a logged in user can post new recipe.
Unit test
Ensure that small pieces of your project are working as they should
In short, it is:
- Things the user would never know about
- like to ensure recipe.description() is working properly
eg:
- the ability to render a specific view with a specific URL call.
- The ability to apply the correct authentication
- the ability to create Recipe object from the model
Functional test
- Tools:
- Selenium is a testing tool to launch a real browser to test your app
- geckodriver is the firefox driver between your browser and selenium
- click here to see the detailed driver required for selenium