diff options
| author | Francesco Borzì <borzifrancesco@gmail.com> | 2020-12-12 13:48:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-12 13:48:25 +0100 |
| commit | 42d3c4ca365272e4e3d500d15b9110c3a4460f31 (patch) | |
| tree | 5e49151c12f7b4d7e92b92c35cb0e6d4ee00c70e /docs | |
| parent | 5714ab3777d7f866a5eb9aa9b2c6b080262433ea (diff) | |
| download | wiki-42d3c4ca365272e4e3d500d15b9110c3a4460f31.tar.gz wiki-42d3c4ca365272e4e3d500d15b9110c3a4460f31.tar.bz2 wiki-42d3c4ca365272e4e3d500d15b9110c3a4460f31.zip | |
docs(unit-testing): improve testing doc (#304)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/unit-testing.md | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/unit-testing.md b/docs/unit-testing.md index f889213..3242607 100644 --- a/docs/unit-testing.md +++ b/docs/unit-testing.md @@ -29,6 +29,7 @@ We use [googletest](https://github.com/google/googletest) at AzerothCore as our - 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 +- https://github.com/google/googletest/blob/master/googlemock/docs/for_dummies.md 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. @@ -51,4 +52,32 @@ We keep its test at: src/test/server/game/Miscellaneous/FormulasTest.cpp ``` -That's it, happy testing! +### Singleton issues + +We have some legacy code in AzerothCore that is tightly coupled and there are singletons that are impossible to mock without some refactoring. + +Following the [gmock guidelines](https://github.com/google/googletest/blob/master/googlemock/docs/for_dummies.md), to mock a class you should first define its interface. Then you can create mocks and use them when unit testing. + +Examples of refactoring AzerothCore singletons to make them mockable (and improve the software architecture in general) are available: + +- [sLog](https://github.com/azerothcore/azerothcore-wotlk/pull/3801) +- [sWorld](https://github.com/azerothcore/azerothcore-wotlk/pull/3862) + +### Existing unit tests examples in AzerothCore + +- All available in [src/test](https://github.com/azerothcore/azerothcore-wotlk/tree/master/src/test) + +### Run tests in IDEs + +You can also run the tests directly in IDEs such as [CLion](https://github.com/azerothcore/forum/issues/4) + +CLion lets you easily run the tests with debug and with coverage: + + + +then it shows which lines of the code are covered by the tests (green lines) and which ones are still uncovered (red lines): + + + + +Happy testing! |
