If there are tests for a module you even can build tests specifically for this module:
```bash
make tests-<module>
# e.g.
make tests-core
```
You then can run the tests by calling
```bash
make term
```
or flash them to your board as you would flash any RIOT application to the board (see [[board documentation|RIOT-Platforms]]).
### Other output formats
Other output formats using [*embUnit*](http://embunit.sourceforge.net/)'s ``textui`` library are available by setting the environment variable ``OUTPUT``:
RIOT uses [*embUnit*](http://embunit.sourceforge.net/) for unit testing.
All unit tests are organized in ``tests/unittests`` and can be build module-wise, if needed.
For each module there exists a ``tests-<modulename>/tests-<modulename>.h`` file, at least one C file in ``tests-<modulename>/`` and a ``tests-<modulename>/Makefile``.
It is recommended to add a C file named ``tests-<modulename>/tests-<modulename>-<headername>.c`` for every header file that defines functions (or macros) implemented in the module.
If there is only one such header file ``tests-<modulename>/tests-<modulename>.c`` should suffice.
Each ``*.c`` file should implement a function defined in ``tests-<modulename>/tests-<modulename>.h``, named like
```C
Test *tests_<modulename>_<headername>_tests(void);
/* or respectively */
Test *tests_<modulename>_tests(void);
```
### Testing a module
To write new tests for a module you need to do three things:
1.**[Create a Makefile](#create-a-makefile)**: add a file ``tests-<modulename>/Makefile``
2.**[Define a test header](#define-a-test-header)**: add a file ``tests-<modulename>/tests-<modulename>.h``
3.**[Implement tests](#implement-tests)**: for each header file, that defines a function or macro implemented or related to the module, add a file ``tests-<modulename>/tests-<modulename>-<headername>.c`` or ``tests-<modulename>/tests-<modulename>.c`` if there is only one header.
#### Create a Makefile
The Makefile should have the following content:
```Makefile
include $(RIOTBASE)/Makefile.base
```
#### Define a test header.
The test header ``tests-<modulename>/tests-<module>.h`` of a module you add to ``tests/unittests/`` should have the following structure
```C
/*
* Copyright (C) <year><author>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
*@addtogroup unittests
* @{
*
*@file tests-<module>.h
*@brief Unittests for the ``module`` module
*
*@author<author>
*/
#ifndef __TESTS_<MODULE>_H_
#define __TESTS_<MODULE>_H_
#include "embUnit/embUnit.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
*@brief Generates tests for <header1>.h
*
*@return embUnit tests if successful, NULL if not.
*/
Test *tests_<module>_<header1>_tests(void);
/**
*@brief Generates tests for <header2>.h
*
*@return embUnit tests if successful, NULL if not.
*/
Test *tests_<module>_<header2>_tests(void);
/* ... */
#ifdef __cplusplus
}
#endif
#endif /* __TESTS_<MODULE>_H_ */
/** @} */
```
#### Implement tests
Every ``tests-<modulename>/tests-<module>*.c`` file you add to ``tests/unittests/`` should have the following structure:
```C
/*
* Copyright (C) <year><author>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level