diff options
| author | Francesco Borzì <borzifrancesco@gmail.com> | 2020-08-15 22:34:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-15 22:34:49 +0200 |
| commit | ba32c9c9177b319241ff7061cb41128e51a0eb79 (patch) | |
| tree | 73776a7e3222856b8f4510a9bac85504933c57c0 /docs | |
| parent | b425cf02d25fe8a853aef4ed6f49b1fb6fa25658 (diff) | |
| download | wiki-ba32c9c9177b319241ff7061cb41128e51a0eb79.tar.gz wiki-ba32c9c9177b319241ff7061cb41128e51a0eb79.tar.bz2 wiki-ba32c9c9177b319241ff7061cb41128e51a0eb79.zip | |
doc: create unit-testing (#272)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/unit-testing.md | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/docs/unit-testing.md b/docs/unit-testing.md new file mode 100644 index 0000000..ef28ada --- /dev/null +++ b/docs/unit-testing.md @@ -0,0 +1,54 @@ +# Unit testing at AzerothCore + +## How to compile and run the AC unit tests + +1. You have to compile your core by passing `-DUNIT_TESTS=1` in your `cmake` command. + +For example: + +``` +cd azerothcore +mkdir build +cd build +cmake ../ -DWITH_WARNINGS=1 -DTOOLS=0 -DSCRIPTS=1 -DUNIT_TESTS=1 +make install -j 6 +``` + +2. You can now run the unit tests using: + +``` +./build/src/test/unit_tests +``` + +## How to write unit tests for AzerothCore + +### Googletest Framework + +We use [googletest](https://github.com/google/googletest) at AzerothCore as our testing framework. Some useful references that explain how it works are available at: + +- https://github.com/google/googletest/blob/master/googletest/docs/primer.md +- https://github.com/google/googletest/blob/master/googlemock/README.md +- https://github.com/nordlow/gtest-tutorial + +You can find plenty of other references online that explain how to deal with googletest or unit testing in general. +If you know some other useful resources, feel free to edit this page and add them. + +We recommend to read the googletest docs **before** starting to write unit tests. + +### File structure + +Unit tests are located under `src/test`. To add new tests, just edit the existing files or create new ones. + +We try to follow the same structure of the `src/*` directory, for example in order to test the file located at: + +``` +src/server/game/Miscellaneous/Formulas.h +``` + +We keep its test at: + +``` +src/test/server/game/Miscellaneous/FormulasTest.cpp +``` + +That's it, happy testing! |
