Mocking framework for use with xamarin android

后端 未结 3 1090
[愿得一人]
[愿得一人] 2020-12-20 04:44

I am trying to find a mocking framework that works with Xamarin Android. So far I have tried Rhino Mocks and Moq but both depend on System.Web.dll which does not seem to be

3条回答
  •  轮回少年
    2020-12-20 05:06

    I've been using a mock generator called PCLMock. I had to fork it to get it working with .netstandard, you can give it a go by cloning it and building it from here: https://github.com/pellet/PCLMock

    It works by generating code before compile time, therefore not needing the reflection apis missing in AOT compiled xamarin projects.

    Otherwise you could always go functional style and pass in your dependencies as delegates/Funcs, this way you don't need to generate mocks for interfaces, you can use a builder class for injecting mocked out lambdas in unit tests.

提交回复
热议问题