Im trying to find a good mocking framework to Unittest my UWP App, bt it seems that all good Mocking infrastructures (MOQ, RhinoMocks etc) understandably rely on Dynamic Proxies which is not supported in UWP.
It looks like MOQ knows of this limitation: https://github.com/Moq/moq4/issues/195
And Microsoft is less than helpful in this situation: https://social.msdn.microsoft.com/Forums/en-US/652b9d16-c4ab-401c-9239-0af01108e460/uwp-is-there-any-indication-that-windows-10-uwp-universal-applications-will-support-code-emitting?forum=wpdevelop
Is there any Mocking infrastructure for unittesting UWP apps? Or any ideas if Dynamic Proxy support is coming anytime in the near future for UWP?
Thanks!
Please run Windows Store Apps troubleshooter from Settings app > Update & security > Troubleshoot. See if it helps you. Hope this helps!
UWP apps use the Windows Runtime, the native API provided by the operating system. This API is implemented in C++ and is supported in C#, Visual Basic, C++, and JavaScript.
Mocking Frameworks (Moq, NSubstitute, Rhino Mocks, FakeItEasy, and NMock3) are used to create fake objects. We can stub, i.e., completely replace the body of member and function. It is used to isolate each dependency and help developers in performing unit testing in a concise, quick, and reliable way.
We (Microsoft BigPark Studio) have just released a mocking framework that is compatible with UWP, .NetCore and .Net Framework (Nuget Etg.SimpleStubs
). The framework uses Roslyn to generate stubs.
To get around the Reflection.Emit
restriction in UWP, the framework generates the stubs at compile time. The stubs are generated and compiled in one step (during the build). If you've ever used VS Fakes, the experience is very similar.
SimpleStubs is opensource and available as a NuGet:
Docs: https://github.com/Microsoft/SimpleStubs
NuGet: https://www.nuget.org/packages/SimpleStubs/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With