Mocks or mock objects simulate the behavior of complex, real (nonmock) objects and are therefore useful when a real object is impractical or impossible to incorporate into a unit test. They provide: Default values unless stubbed Can help verify int
Xamarin.Forms.Mocks
在单元测试中运行Xamarin.Forms的库
NuGet
Windows / AppVeyor
OS X / Travis-CI
如果您曾经在Xamarin.Forms视图中编写过任何复杂的逻辑,您很快就会意识到此代码无法轻松进行单元测试。 您的同事会告诉您MVVM的所有内容,但是您无法绕开与Xamarin.Forms本身的交互。 导航,动画,自定义标记扩展等内容可能会变成未经测试的混乱。
如果您决心尝试一下,则可能会执行以下操作,然后放弃: