wheybags / freeablo

[ARCHIVED] Modern reimplementation of the Diablo 1 game engine
GNU General Public License v3.0
2.16k stars 192 forks source link

Setup Fakeit to support mocking for tests #267

Open Fuco1 opened 7 years ago

Fuco1 commented 7 years ago

https://github.com/eranpeer/FakeIt

Unfortunately my CMake-fu is very low so I have no idea how to pull this into the project. But I wanted to write some tests now just for fun (for the faction PR) and figured C++ tests are unlike anything I've ever worked with :D So yea... /shrug

wheybags commented 7 years ago

We actually have tests already using gtest (not sure if you saw em, they're in the test/ top level directory). Feel free to add in this if you have a test you want to use it for.

Fuco1 commented 7 years ago

I saw them, but gtest doesn't seem to support mocking, without which the system components can hardly be tested, the dependencies are too far-reaching.

For example, how would I instantiate a FAWorld::Monster in a test? I would need to also get the monster instance from the exe, which seems irrelevant for many purposes (like testing if A can attack B or if a monster can move to a given square).

I will have to read some more on C++ testing practices.