<commit_before># Unit Tests

Codeception uses PHPUnit as a backend for running its tests. Thus, any PHPUnit test can be added to a Codeception test suite
and then executed. If you ever wrote a PHPUnit test then do it just as you did before.
Codeception adds some nice helpers to simplify common tasks.

The basics of unit tests are skipped here, instead you will get a basic knowledge of which features Codeception adds
to unit tests.

__To say it again: you don't need to install PHPUnit to run its tests. Codeception can run them too.__

## Creating Test

Create a test using `generate:test` command with a suite and test names as parameters: 

```bash
php codecept generate:test unit Example
```

It create a new `ExampleTest` file located in the `tests/unit` directory.

As always, you can run the newly created test with this command:

```bash
php codecept run unit ExampleTest
```

Or simply run the whole set of unit tests with:

```bash
php codecept run unit
```

A test created by the `generate:test` command will look like this:<commit_msg>Update 05-UnitTests.md (#4397)<commit_after># Unit Tests

Codeception uses PHPUnit as a backend for running its tests. Thus, any PHPUnit test can be added to a Codeception test suite
and then executed. If you ever wrote a PHPUnit test then do it just as you did before.
Codeception adds some nice helpers to simplify common tasks.

The basics of unit tests are skipped here, instead you will get a basic knowledge of which features Codeception adds
to unit tests.

__To say it again: you don't need to install PHPUnit to run its tests. Codeception can run them too.__

## Creating Test

Create a test using `generate:test` command with a suite and test names as parameters: 

```bash
php codecept generate:test unit Example
```

It creates a new `ExampleTest` file located in the `tests/unit` directory.

As always, you can run the newly created test with this command:

```bash
php codecept run unit ExampleTest
```

Or simply run the whole set of unit tests with:

```bash
php codecept run unit
```

A test created by the `generate:test` command will look like this:
{'fraction_non_alphanumeric': 0.05240793201133145, 'fraction_numerical': 0.0028328611898017, 'mean_word_length': 4.337531486146096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5069673', 'n_tokens_mistral': 582, 'n_tokens_neox': 545, 'n_words': 343}