---
title: "Django におけるテスト"
version: 4.1
locale: ja
source: https://docs.djangoproject.com/ja/4.1/topics/testing/
canonical: https://djangodocs.dev/ja/4.1/topics/testing/
---
# Django におけるテスト

Automated testing is an extremely useful bug-killing tool for the modern
web developer. You can use a collection of tests -- a **test suite** -- to
solve, or avoid, a number of problems:

- 新しいコードを書いている時、テストを使えば、自分が書いたコードが期待通りに動作するかどうか確かめることができる。
- 古いコードのリファクタリングや修正をしている時、テストを使うことで、自分の行った変更が思ってもないような仕方でアプリケーションの動作を変更してしまわないことを保証できる。

Testing a web application is a complex task, because a web application is made
of several layers of logic -- from HTTP-level request handling, to form
validation and processing, to template rendering. With Django's test-execution
framework and assorted utilities, you can simulate requests, insert test data,
inspect your application's output and generally verify your code is doing what
it should be doing.

The preferred way to write tests in Django is using the [`unittest`](https://docs.python.org/3/library/unittest.html#module-unittest) module
built-in to the Python standard library. This is covered in detail in the
[テストを書いて実行する](/ja/4.1/topics/testing/overview/) document.

*その他* どんな Python テストフレームワークでも利用できます。Django は、この種のインテグレーションのためのAPI や各種ツールを提供しているからです。これらについては、 [Advanced testing topics](/ja/4.1/topics/testing/advanced/) の [Using different testing frameworks](/ja/4.1/topics/testing/advanced/#other-testing-frameworks) セクションで説明しています。

- [テストを書いて実行する](/ja/4.1/topics/testing/overview/)
- [テストツール](/ja/4.1/topics/testing/tools/)
- [Advanced testing topics](/ja/4.1/topics/testing/advanced/)
