What are the differences between MOQ and AutoFixture?

I have a lot of experience using MOQ, while I recently came across AutoFixture. What are the differences between these structures?

+8
unit-testing moq mocking autofixture automocking
source share
1 answer

FAQ explains the difference. In short

AutoFixture uses Reflection to create β€œgood” instances of public types. It automatically generates instances of other types, if necessary, to populate the arguments for the constructor, and also assigns values ​​to the public write capabilities. Essentially, it just uses the requested public API type to create and populate. It does not do anything that you, as a developer, could not do manually - it just does it automatically for you.

Unlike most Dynamic Mock libraries, derived from known types override the behavior of virtual members. Their goal is to test the behavior of the system under test (SUT).

You can combine AutoFixture with Moq to turn it into a container for startup .

+12
source share

All Articles