gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 21:50:53 26 4
gpt4 key购买 nike

我有相当多的使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com