Home of a Creative Engineer

Test and Mocking Frameworks for Test Driven Development: The Overview


Python comes with a test framework in the standard library. It is simply called unittest. The module unittest.mock also contains a mocking framework. Thus you can start unittesting with Python out of the box.

You can find more information about in the Python documentation. Also, check out my TDD example to see the usage of the unittest framework.


The most popular test framework for Java is JUnit.

JUnit does not come with a mocking framework. There seems to be a multitude of frameworks out there, which cater to different needs. Examples include JMock, Mockito and JMockit. I cannot give a recomendation for any of these, as I have not tried mocking in Java. You have to do your own research to select the framework that best suits your programming style.


Google has released its test framework Google Test as open source. Since then, it has become very popular in the C++ community.

Google Test also comes with its own powerful mocking library, Google Mock.


Visual Studio comes with its own test framework. You can run your tests from Visual Studio, which makes it very comfortable to examine the test results and to re-run failed tests.

If you happen to use Visual Studio Enterprise, you can use Microsoft Fakes to create stub objects.

If you don’t have VS Enterprise or want to create mock objects, there are a number of open source mocking frameworks out there. A very popular one, even recommended by Microsoft developers, is Moq.


As Visual Studio, Apple’s XCode IDE has its own testing framework, which is called XCTest. You can run these test cases from within XCode. With XCTest, not only can you write unit test, but also tests for the GUI of your application.

XCTest does not provide a mocking framework. In fact, there is no pure Swift mocking framework available yet. It seems to be due to the static nature of Swift. Some people have suggested workarounds to create mocks manually, like Mark Spanbroek and Andrew Bancroft. But all these solutions require creating a lot of boilerplace code.

Other Languages

This list is far from complete. For almost every language, there is a multitude of other test and mocking frameworks. And of course, there are also mocking frameworks for languages that are not in this list as well. As a starting point for further research, you can use this list from Wikipedia.

I hope you enjoyed this article. If you have any questions or comments, please contact me.