I am working on my first MVVMCross application and I am trying to set up a good testing framework. I have looked at the testing Stuart is doing in his TwitterSearch app but I have found nothing that explains his approach or any other approach to testing MVVMCross. Has anyone come across a good post/tutorial on the proper way to test an MVVMCross application? Other than just code that a newb (like myself) may not completely understand...
1 Answers
I'm not sure what you are asking...
What do you mean by a 'proper way'?
Is this a question about mechanics of "how to write a unit test?" Or a question about "how many unit tests to write; Which components to test; How deep to go; etc?"
For the mechanics:
- I personally use NUnit for testing (from NuGet)
- I include this in a .net4.5 class library project.
- I use Moq for most of my Mocking (from NuGet)
- There are a few MvvmCross objects I manually mock - as shown in that TwitterSearch message
- There's an MvvmCross base test class which provides IoC/ServiceLocation - but I generally only use this when I need to use real MvvmCross classes - e.g. when the class under test inherits from
MvxViewModel
- I only run tests within Resharper in Visual Studio
There are plenty of other approaches, including some people choose to run tests on devices - e.g. using the excellent MonoTouch Nunit test runner.
There are also plenty of people interested in BDD testing - e.g. things like Frank, Calabash (coming in Xamarin Test Cloud) and the Windows Phone Test Framework that I wrote - https://github.com/Expensify/WindowsPhoneTestFramework :)
For the philosophy, I have no strong opinion, but I like this answer:
https://stackoverflow.com/a/153565/373321
I too get paid to write code
-
My main struggles have been when I am trying to test my ViewModels that inherit from MvxView model. It seems that what documentation there is, is a bit out of date (ex: there no longer seems to be an MvxViewDispatcherProvider). Also I am trying to understand what exactly is going on with the ViewDispatcher. – ferics2 May 15 '13 at 14:58
-
If you ask specific questions - e.g. including an example of a test you have failed to build - then I'll try to answer with a specific answer. Please also remember that you can contribute to the project by blogging about what you learn and create. Contributions like that are the driving force currently improving the project and it's documentation. – Stuart May 15 '13 at 15:08
-
I tried to be more specific in my edits. Thanks for any help you can provide! – ferics2 May 20 '13 at 15:04
-
I'd prefer you to rollback those edits and ask a new question. Thanks. – Stuart May 20 '13 at 15:25
-
Done, here is the new question. Thanks for your patience. http://stackoverflow.com/questions/16672122/testing-viewmodels-in-mvvmcorss – ferics2 May 21 '13 at 14:07
-
Thx - think this q&a were already long and confusing enough :) have answered on new question. – Stuart May 21 '13 at 14:20