Jacob
Jacob

Reputation: 78850

TDD for Windows Store app development without mocks

Has anyone come up with a good TDD setup for Windows Store App development? I'm so used to using mocking frameworks, but this is no-longer an option since dynamic assembly generation is missing in WinRT.

I have seen the alpha MoqRT framework, but I am hoping to avoid something in such experimental stages. I have also been so spoiled with using mock objects that I balk at using the stubs or shims offered as an alternative from Microsoft (Microsoft Fakes).

Have any of you successfully figured out good techniques for doing Windows Store App development using DI and properly-isolated TDD-style unit tests? If so, what have you done?

Edit:

I also notice that the "Add Fakes Assembly" option isn't present in my "Windows Store App" unit test project, so that maybe isn't an option.

Upvotes: 5

Views: 1186

Answers (2)

Loul G.
Loul G.

Reputation: 1095

You'll be able to mock in Windows Store App as you are used to by using Telerik JustMock. It's available as a separated installer that delivers a DLL that you import in your test project. It's free, but you must first register.

The syntax is not so different as Moq. Remember to also add the namespace Telerik.JustMock.Helpers to add usefull extensions.

I'm currently using it to develop an Universall App using Prism.StoreApps. With JustMock i'm now able to unit test my ViewModel in isolation. I can now unit test all the layers of my software, i'm no longer forced to create PCL layers. They are now Portable 8.1 projects.

Upvotes: 0

Jacob
Jacob

Reputation: 78850

The approach I'm trying out now is placing the testable code in a regular .NET 4.5 assembly, allowing it to be unit tested with mocks using a normal unit test project. Then, in the Windows Store App project, these same source files are added as links. This is inconvenient since I'm having to duplicate project references between the two platforms, and I have to be careful to ensure the code compiles in both projects, but this approach does allow me to use better unit testing tools.

I'm still eagerly waiting to see if someone comes up with something better.

Upvotes: 3

Related Questions