unit-testing - MOQ 和 AutoFixture 之间有什么区别?

标签 unit-testing mocking moq autofixture automocking

我有相当多的使用 MOQ 的经验,而我最近偶然发现了 AutoFixture。这些框架之间有什么区别?

最佳答案

FAQ解释了其中的差异。简而言之

AutoFixture uses Reflection to create 'well-behaved' instances of public types. It auto-generates instances of other types if necessary to fill in arguments for a constructor, and also assigns values to public writable properties. In essence, it simply uses the requested type's public API to instantiate and populate it. It doesn't do anything that you, as a developer, couldn't do manually - it just does it for you automatically.

In contrast, most Dynamic Mock libraries derive from known types to override the behavior of virtual members. Their purpose is to perform Behavior Verification of the System Under Test (SUT).

您可以combine AutoFixture with Moq to turn it into an automocking container .

关于unit-testing - MOQ 和 AutoFixture 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5786628/

相关文章:

c# - 使用 UnityAutoMoqContainer 注册通用接口(interface)

c# - 将同步 Moq 模拟转换为异步

multithreading - 如何编写单元测试来检查方法是否线程安全

php - 如何在 laravel 中模拟 DB 门面?

起订量设置返回 null

具有并行支持的 C# 模拟框架

node.js - 如何用 Jest 模拟函数 .save() sequelize

java - Mockito无法实例化被测类

unit-testing - Spring 和 Mockito - 忽略传递依赖

python - 为什么 PyCharm 单元测试发现不适用于目录?