ferics2
ferics2

Reputation: 5432

Testing an MVVMCross application

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...

Upvotes: 1

Views: 1118

Answers (1)

Stuart
Stuart

Reputation: 66882

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

Upvotes: 3

Related Questions