# Testing With Codeception

Elentra uses [Codeception](https://codeception.com/) as its integrated testing environment. It allows you to create and run unit tests, integration tests, and functional tests separately or together.

**Unit tests** are designed to run quickly and test small portions of code that have no external dependencies. For example, testing a function that takes a `Models_User` object and returns an array with the name, address, and email.

**Integrations tests** are for testing multiple units that work together. An example would be an API call to get a list of a given Learner's courses.

**Functional tests** will test the interaction of code that is in multiple integration tests, like a Learner's dashboard page that contains a list of courses, Message Centre, Assessments, etc.

Codeception test files are found in the `/developers/tests` section of your Elentra ME development environment, and basic configuration is in `/developers/codeception.yml`. Configuration for the individual kinds of tests can be found in `/developers/tests/*.suite.yml`

### The Difference Between Unit and Integration Testing <a href="#user-content-the-difference-between-unit-and-integration-testing" id="user-content-the-difference-between-unit-and-integration-testing"></a>

<table><thead><tr><th width="359.8561019172851">Unit Testing</th><th>Integration Testing</th></tr></thead><tbody><tr><td>Unit tests mock interactions with external dependencies (database, IO, etc.)</td><td>Integration tests use the real dependencies</td></tr><tr><td>Developers write unit tests</td><td>Testers or other QA professionals usually write integration tests</td></tr><tr><td>Unit tests provide precise feedback</td><td>Integration tests provide less precise feedback</td></tr><tr><td>It tests a unit without the need for other units to be complete</td><td>The units must all be complete</td></tr><tr><td>Developers run unit tests on their machines frequently</td><td>Developers run integration tests on their machines less frequently, or not at all</td></tr><tr><td>The CI server runs the unit test suite at each commit to the main branch or check-in</td><td>The CI server might run integration tests less often, as they need a more involving setup process and are slower to run</td></tr><tr><td>Unit tests are easier to write</td><td>Integration tests are harder to write</td></tr><tr><td>Unit tests can be run in any order, or even simultaneously</td><td>Integration tests usually required a strict order and can’t be run simultaneously</td></tr><tr><td>Unit tests are stable</td><td>Integration tests can experience instability due to reliance on remote resources and potential network conditions</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.elentra.org/technical/developers/troubleshooting/testing-with-codeception.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
