Mimicc Release 0.11.1-rc1

Version 0.11.1-rc1 of the Mimicc toolchain is now available for download. The corresponding LLVM version is 12.0.1. Artifacts for Windows, Linux, and Mac can be found on the Download page. The User Guide can be found here at mimicc.dev, or as a pdf in the release artifacts.

The changes for this release are as follows:

  • Updated the underlying LLVM/Clang version to 12.0.1.
  • Added support for Windows.

The Windows version has been a very common request since the original launch of Mimicc, and we’re very pleased to be able to announce a fully native x64 build with today’s release. If you’re planning to use the Windows build, we highly recommend you take a look at the updated User Guide, which has some pointers on getting up and running. The fastest way to get started will be to install a recent version of Visual Studio, and run Mimicc from within a Visual Studio native tools command prompt.

If you’re arriving here for the first time, welcome! We recommend you read the introductory notes from the first public release, or my recent post about why Mimicc exists.

Mimicc is a tool for generating mocks from C and C++ source code. It works like a compiler, taking C and C++ declarations as input and producing function definitions as output, either pre-compiled as an object file, or as plain C/C++. For each Mimicc-generated mock, there is also an API which allows you to interact with its functions and methods at runtime for writing unit tests.

Mimicc is distributed as a complete, stand-alone, clang-based toolchain including the compiler runtime and static analyzer.

Mimicc Release 0.11.0-rc1

Version 0.11.0-rc1 of the Mimicc toolchain is now available for download. The corresponding LLVM version is 12.0.0. Artifacts for Mac and Linux can be found on the Download page. The User Guide can be found here at mimicc.dev, or as a pdf in the release artifacts.

The changes for this release are as follows:

  • Added the getImplementation() API endpoint for function pointer mocks.
  • Added support to emit mocks for typedef function pointer declarations (i.e. in addition to function pointer global variables and fields as they exist today).
  • Separated out fatal and non-fatal errors in the mock API and runtime via the mock_fatal() and mock_failure() calls. Previously all errors were handled by mock_failure(). This enables a more seamless integration with GoogleTest among other test frameworks. An example has been added to the User Guide to demonstrate this.
  • A few minor bugfixes.

If you’re arriving here for the first time, welcome! We recommend you read the introductory notes from the first public release, or my recent post about why Mimicc exists.

Mimicc is a tool for generating mocks from C and C++ source code. It works like a compiler, taking C and C++ declarations as input and producing function definitions as output, either pre-compiled as an object file, or as plain C/C++. For each Mimicc-generated mock, there is also an API which allows you to interact with its functions and methods at runtime for writing unit tests.

Mimicc is distributed as a complete, stand-alone, clang-based toolchain including the compiler runtime and static analyzer. Convenience scripts are provided (mimicc-env) for creating a “virtual environment” in your favorite shell (similar to Python’s virtualenv), allowing you to comfortably use the Mimicc toolchain alongside any other compiler installations you already have on your system, including clang.

Mimicc Release 0.10.0-rc1

Version 0.10.0-rc1 of the Mimicc toolchain is now available for download. The corresponding LLVM version is 12.0.0. Artifacts for Mac and Linux can be found on the Download page. The User Guide can be found here at mimicc.dev, or as a pdf in the release artifacts.

This is purely an update to the underlying LLVM/clang compiler engine, there are otherwise no new features in this release.

If you’re arriving here for the first time, welcome! We recommend you read the introductory notes from the first public release, or my recent post about why Mimicc exists.

Mimicc is a tool for generating mocks from C and C++ source code. It works like a compiler, taking C and C++ declarations as input and producing function definitions as output, either pre-compiled as an object file, or as plain C/C++. For each Mimicc-generated mock, there is also an API which allows you to interact with its functions and methods at runtime for writing unit tests.

Mimicc is distributed as a complete, stand-alone, clang-based toolchain including the compiler runtime and static analyzer. Convenience scripts are provided (mimicc-env) for creating a “virtual environment” in your favorite shell (similar to Python’s virtualenv), allowing you to comfortably use the Mimicc toolchain alongside any other compiler installations you already have on your system, including clang.

Driving Development Of Tests

During the development of Mimicc I shared the tool with a colleague of mine who joked that I should post it on Hacker News so we could watch the inevitable flame war that ensues. While he certainly intended that to be hyperbolic, the related topics of unit testing, mocking, and Test-Driven Development have a way of bringing out some very strong feelings from otherwise mild-mannered people. What is, after all, the “right” way to test?

This short post is not going to attempt to answer that question. In fact, this author questions whether there exists a unified answer to that question at all. Real software is complicated, and when it comes to making design decisions, context trumps dogma most of the time. Does it matter if we’re talking about C++ or some other language? Does it matter how close to the hardware it is? Does it matter how big the team is? What our Devops infrastructure looks like?

At the end of the day what is most important is not how we test, but that we test. Of course that’s not to say that the how question is irrelevant or unimportant, but that the question of how we test must necessarily work in service of the directive that we test. Most engineers reading this will agree with this statement as almost self-evident. So why then don’t we test more? What are the barriers to writing tests?

Of course there are many language, platform, and environment-specific answers to this question, but there’s one that holds true universally: complexity. Complexity is the enemy of testability, and useful software is intrinsically complex.

Mimicc is fundamentally a tool to reduce complexity. In fact this is true of all mocking frameworks. What sets Mimicc apart is:

  1. It’s designed for software written in C and C++
  2. It aims to reduce complexity while simultaneously imposing as little dogma as possible.

Avoiding dogma in this context can be further defined as minimizing what is sometimes called “test-induced damage” to production code. In other words: Mimicc attempts to make your code more testable without you having to change the way you write it. This is particularly relevant in a language like C++, which has a very large toolkit of features to draw from. It’s very easy to write code which is not only extremely complex, but extremely difficult to test. Most professional organizations manage this by reducing the usable feature set available to engineers. Others simply accept that the loss of testability and coverage is a fair trade-off for the power of the language feature in question.

The designers of Mimicc have strived and are continuing to strive to build a tool which injects itself as intelligently as possible into your workflow. This is reflected in the name “Mimicc” which is intended to convey not only that it creates mock code which “mimics” the production code you’re trying to eliminate for complexity control, but it also “mimics” the behavior of your compiler. We believe the end result is something that has the best possible chance at enabling you to write more tests, and spend less time maintaining them.

Martin Fowler writes on the opening of his website that “software development is a young profession, and we are still learning the techniques and building the tools to do it effectively.” This, almost more than anything else, summarizes why Mimicc exists, and why it has to continue to grow and evolve if it’s going to drive the kind of software quality we all want to see in our professional and personal projects.

Mimicc Release 0.9.0-rc3

Version 0.9.0-rc3 of the Mimicc toolchain is now available for download. The corresponding LLVM version is 11.0.1. Artifacts for Mac and Linux can be found on the Download page. The User Guide can be found here at mimicc.dev, or as a pdf in the release artifacts.

If you’ve just arrived here for the first time, welcome! Mimicc is a new tool, and this is its first publicly available release, so it will come as no surprise that you haven’t heard of it. A brief introduction is in order.

Mimicc is a tool for generating mocks from C and C++ source code. It works like a compiler, taking C and C++ declarations as input and producing function definitions as output, either pre-compiled as an object file, or as plain C/C++. For each Mimicc-generated mock, there is also an API which allows you to interact with its functions and methods at runtime for writing unit tests.

Mimicc is distributed as a complete, stand-alone, clang-based toolchain including the compiler runtime and static analyzer. Convenience scripts are provided (mimicc-env) for creating a “virtual environment” in your favorite shell (similar to Python’s virtualenv), allowing you to comfortably use the Mimicc toolchain alongside any other compiler installations you already have on your system, including clang.

Since this is the first time Mimicc is being openly distributed, your use of the tool certainly qualifies you as an “early adopter”. We really want this tool to be as useful to you as it is to us, so please do let us know what you think. We’ve done our best with the resources we have to make sure things work as expected, but as veterans of software development ourselves, we know and expect that issues come up when larger numbers of people start using something new. This is also reflected in the chosen version number for this release. We consider this a “beta-quality” release, and we’ll be incorporating your feedback to drive towards something with a quality worthy of the magic “1.0” release number. You can expect regular updates as issues are found and fixed.

Mimicc is not the only tool available for building mocks for C and C++, but we believe it’s special for a few reasons that we’ll elaborate on in future posts. In the mean time, we strongly recommend you check out the User Guide. It’s long and detailed, but we included a Quick Start guide that pretty well summarizes how you can use the tool in practice.