Writing the Test

Learn to write tests in test-driven development.

The TDD process consists of the following five steps:

  1. Write the test.
  2. Run the test.
  3. Write the actual code.
  4. Make all tests pass.
  5. Refactor and improve the code.

After we install and configure our Django project, we write the test. We need to do this before we start adding any new feature or code the application However, before we can write the test, we must understand the application as a whole. This includes the requirements, project specifications, and what the feature we’re adding is intended to do. We need this so that the unit test we write captures the needed feature.

Get hands-on with 1200+ tech skills courses.