how to write unit test for click event for windows 8 app

Category: windows metro apps tools


prasanna lakshmi on Thu, 23 May 2013 12:01:56


Can anyone please help us to write unit test for click event in windows 8 app.

Ex: I have written code for 'Home' button that when it is clicked, should be redirected to Home page. Now I want to test the 'Home' button click event.

Thanks in advance,



Andrei Marukovich on Thu, 23 May 2013 14:53:51

The best testability for your app you can achieve by separating your UI and business logic. One of the ways is to follow MVVM (Model-View-ViewModel) pattern, where UI (View) is separated from UI logic (ViewModel) and business layer (Model) so ViewModel and Model are easily testable.

If you are not familiar with this pattern you can start from reading Using the MVVM Pattern in Windows 8 article.

Berndt Hambo on Thu, 30 May 2013 10:55:57


This msdn entry should get you started: