« BackFakeIt: C++ Mocking Made Easygithub.comSubmitted by klaussilveira 4 days ago
  • pjmlp 38 minutes ago

    It has a overlapping name with a Microsoft framework,

    https://learn.microsoft.com/en-us/visualstudio/test/isolatin...

    • monkeyelite an hour ago

      Writing the actual code to implement the interface would be less code than the example using this library.

      • vhantz 7 hours ago

        I can not imagine when this type of library becomes useful. What's a usage example for this? What do you gain over rolling your own?

        • bluGill 6 hours ago

          It is / or should be less tedious than a writting a custom class with the return values you need for everything.

          I still recomend hand written fakes - but only because and if they model real behavior without the unwanted effects. I find my handwritten cods often has more lines of test code to ensure it works than the real implementation.

          • vhantz an hour ago

            > model real behavior without the unwanted effects.

            That's how I was looking at this since that's the experience I've had with mocks. For example, mocking an API to test a library that uses that API without incurring the real usage costs everytime the tests are ran. Going back over the github again, I can see this being useful if you have to fake a lot of APIs. Though my personal preference would always be to limit mocks as much as possible even with that framework available.

        • bluGill 6 hours ago

          I like that they have the verify as a separare / latter step. Most users of google mock see a mock call and assume that they need to force the call - thus if you change the implementation you are breaking tests but the real code still works because that should be an implementation detail.

          • drysine 21 hours ago

            "On GCC, optimization flag O2 and O3 are not supported. You must compile the test project with -O1 or -O0."

            Sounds like they are patching objects in memory. Trompeloeil, for example, doesn't do that.

            • thrtythreeforty 5 hours ago

              Yikes. "Broken with optimizations" means "broken" to me. Don't screw around with undefined behavior; either you had better avoid it, or your circumvention of the compiler had better be so airtight that it still works with optimizations.

              • spookie 4 hours ago

                Those are not, in general terms, words to live by. In video games, of all things, it is usual to prevent certain code paths from being optimized for actual enforcement of security measures. Compilers are the ones taking optimizations a bit too far.

            • ch33zer 7 hours ago

              Seems very inspired by gmock. Wondering if there's a comparison somewhere?