---
title: "Unit Tests"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:cgl-unit-tests@11.5"
source: "CodingGuidelines/CodingBestPractices/UnitTests.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **Attention**
>
> TYPO3 v11 has reached end-of-life as of October 31th 2024 and
> is no longer being maintained. Use the version switcher on the top
> left of this page to select documentation for a supported version of TYPO3.
>
> Need more time before upgrading?
> You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here:
> [TYPO3 ELTS](https://typo3.com/services/extended-support-elts).

# Unit Tests {#cgl-unit-tests}

## Unit test files {#unit-test-files}

Unit test files are located in the "`Tests/Unit/`" folder of the
according extension, within a sub-structure matching the structure in
the `Classes/` folder.

As naming convention, `Test` is appended at the end of the name.
As example, the unit test class file for
`typo3/sysext/core/Classes/Database/PreparedStatement.php` located
at `typo3/sysext/core/Tests/Unit/Database/PreparedStatementTest.php`.

## Using unit tests {#using-unit-tests}

Although the coverage is far from complete, there are already quite a
lot of unit tests for the TYPO3 Core. Anytime something is changed in
the Core, all existing unit tests are run to ensure that nothing
is broken.

## Adding unit tests {#adding-unit-tests}

The use of unit tests is strongly encouraged. Every time a new feature
is introduced or an existing one is modified, a unit test should be
added.

## Conventions for unit tests {#conventions-for-unit-tests}

Unit tests should be as concise as possible. Since the `setUp()`
and `tearDown()` methods always have the same responsibility,
these methods do *not* need a documentation block.

Since unit tests never return anything, they do not need an
`@return` tag.
