eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.22k stars 170 forks source link

FakeIt and CppUTest #323

Open jwgrenning opened 10 months ago

jwgrenning commented 10 months ago

Hi

I am experimenting FakeIt with CppUTest and the stand-alone single header for use in a training exercise. It works nicely and I had no problem getting it working with CppUTest, but the 10,000 line single header adds a second to test build on my linux box.

I have a cloud server I use with cyber-dojo as a training exercise server. This environment is shared by people doing training exercises. For simple test-runners that include fakeit.h, there is a 20-second build time on my dev server.

Is there are non-single header way of using FakeIt? You know, separating interface from implementation?

Thanks, James

malcolmdavey commented 10 months ago

My assumption based on the amount of templating is that it needs to be header only.

I know windows Visual Studio allows precompiled headers so in effect it can be optimised to only compile it once, instead of for every source file with tests. Haven't tried it on linux/gcc etc, and not sure if this would help your scenario.

jwgrenning commented 10 months ago

Hi, Thanks for the reply. I tried the GCC pre-compiled header but could not get it to do anything useful for me.

Do any people find the performance a problem? It seems like it would add the better part of a second to the build for each file that uses fakeit.

FranckRJ commented 2 months ago

I've never really tested compilation time so I don't know how much impact the library has. I haven't looked into importing headers individually either, instead of importing the single-header only. Maybe it could help but I don't know if the includes are "clean" in the sense that they only include necessary headers themselves. I should probably look that one day.