7 ms·
Googletest is the most widely used test library for C++. Googlemock is the only mocking library available that's reasonably feature complete.
by humanrebar 2y ago
Googletest is the most widely used test library for C++. Googlemock is the only mocking library available that's reasonably feature complete.
- gpderetta 2y agoGoogle test and mock are quite powerful but are a big hit at both compile time and runtime, which matters for quick edit-compile-fix loops. I still go back and forth on whether google test and mock are worth it. Google benchmark is also nice.
- rangestransform 2y ago> big hit at both compile time and runtime, which matters for quick edit-compile-fix loops honestly if you write C++ for work, there's no excuse for your company to not give you the beefiest dev machine that money can reasonably buy. given that rust exists, I think "get a faster computer" is a totally valid answer to build times, especially now that skylake malaise era is over and CPUs are getting faster
- badsectoracula 2y ago> given that rust exists, I think "get a faster computer" is a totally valid answer to build times I find this amusing because one of the main reasons i avoid Rust (in the sense that i prefer to build things written in other languages if possible - i don't mind if someone else uses it and gives me a binary/library i can use - and it never went beyond "i might check this at some point, sometime, maybe" in my mind) is the build times compared to most other compilers :-P. Also, at least personally, if i get a faster computer i want my workflow to be faster.
- tmtvl 2y agoYou may want to add a '/s' at the end of your post there, because sarcasm doesn't really translate on the internet. The only way I can tell it's sarcasm is because nobody would really go 'throw away the old stuff, buy new stuff, waste more, pollute the oceans, consume, CONSUME!!!'.
- rangestransform 2y ago> 640k should be enough for everyone
- jimmaswell 2y agoDoes it not support only running some or no tests? I only run the full test suite rarely, close to releases.
- bluGill 2y agoI you are using googletest, you owe it to yourself to check out catch2 which I find much better and uses modern C++. There are a few other test frameworks in C++ that look better than google test as well, but catch2 is the one I settled on (and seems to be the best supported): feel free to check them out. I've given up on mock frameworks. They make it too easy to make an interface for everything and then test that you are calling functions with the expected parameters instead of the program works as you want. A slight change to how I call some function results in 1000 failed tests and yet I'm confident that I didn't break anything the user could notice (sometimes I'm wrong in this confidence - but none of the failing tests give me any clue that I'm wrong!)
- ehoh 2y agoSounds like the mocks are overused or used inappropriately in your experience (whether by a colleague or yourself). Mocks have their place. A prototypical example is at user-visible endpoints (eg: a mock client).
- player1234 2y agoExactly! This one gets it, real communism has never been tried! On another note I do not think that it is tiresome at all, that any critique of any pattern/teqnique in SWE, always is meet with the "you are holding it wrong" rebutle.
- deleted 2y ago[deleted]
- jodrellblank 2y agoDo you not believe it's possible to hold something wrong? If someone is a skilled and experienced golfer, it's quite believable that they won't automatically be a skilled tennis player after three months of tennis playing. If someone is an experienced race car driver, they won't automatically be a skilled member of a basketball team. "You must be holding it wrong" can sometimes take years of practising holding it right, not just minutes or months. If a team of people who have been SWEs for decades reports that something helped their team, and you try it and it doesn't work, and you have been SWEs for decades, that doesn't automatically mean they are charlatans selling nonsense. They might all be basketball players playing together for 5 years and you might be a team of a baseball player, a racecar driver, a track and field athlete, and a water polo player, trying to play basketball from only reading about it, with nobody who has done it or experienced it, and several people who quietly don't want to be playing it and are just nodding along while hoping it fails. The conclusion that they are liars and it can't possibly work is not a strong conclusion.
- physicsguy 2y agoI used to really like Google Test, and then Google decided in it's infinite wisdom to make the OSS version depend on their C++ shared library replacement Abseil, and not just that but the live at head version. That makes sense internally for Google because they have their massive monorepo, but it sure as hell makes it a pain in the ass to adopt for everyone else.
- jeffbee 2y agoI don't think you're reading those docs correctly. Googletest recommends living at head, but there's no reason you can't pin a release, either a git commit hash or a release label, of which there have been several. Googletest does not depend on the HEAD of abseil-cpp, it actually declares a direct dependency on an older LTS release of absl, but since you are building it from source any later release or commit of absl would work. Google open source libraries are often a mess when you try to include more than one of them in the same project, but googletest isn't an example of the mess. It's actually pretty straightforward.
- james_promoted 2y ago> Google open source libraries are often a mess when you try to include more than one of them in the same project Completely agree. In isolation all of their libs are great, but inevitably I end up having to build Abseil from source, to then build Protobuf off of that, to then build gRPC off of that. If I can include the sanitizers under Google then that also becomes painful because Abseil (at least) will have ABI issues if it isn't built appropriately. Thinking about it I'd really just like a flat_hash_map replacement so I can drop Abseil.
- jeffbee 2y agoFWIW the flat hash map in Boost is now faster. I am not sure if integrating Boost is any easier for you.
- james_promoted 2y ago