liveBook · Manning

Integration test

As explained in Django in Action

An integration test is an automated test that verifies interactions between multiple software components or systems.

An integration test checks whether several software units work together and still produce the desired result. Unlike a unit test, which usually targets one function or method, it crosses component boundaries. In a web application, this usually means testing business logic or server behavior rather than clicking through the graphical interface. section 8.1.1

Figure 8.1 Hierarchy of testing categories
figure

Use the testing pyramid to place integration tests between isolated unit tests and slower, broader behavioral or UI tests. section 8.1.1

A Django integration test commonly involves:

  • Running several units together instead of isolating a single function. section 8.1.1
  • Using Django's test database and ORM support; populate model objects because the test database starts empty. section 8.10
  • Writing assertions such as assertEqual() and allowing each test's database transaction to roll back afterward. section 8.10
  • Executing tests through Django's test runner, which discovers TestCase classes and methods beginning with test_. section 8.10

Integration tests sit above unit tests because they cover cooperation between components, but below UI tests because they avoid simulating a person operating the interface. That makes them broader than unit tests without requiring the full, slower application stack. section 8.1.1 section 8.10

How Django in Action covers it

How deep it goes
Defines the category, Django database support, assertions, discovery, and cleanup, but stops short of UI interaction.
Examples
Uses populated model objects, Django's test database, assertEqual(), and test methods discovered by the test runner.
What it assumes
Builds upward from unit-test concepts while supplying Django's TestCase, ORM, test database, and assertion support.
What you can do after
Apply it via Django's test runner to verify interactions across several units with isolated database state.
How it connects
Connects unit tests, behavioral tests, acceptance tests, UI tests, Django TestCase, ORM, and database transactions.

Also explained in

Compare how 31 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.