Can I use TDD for gui application? How to do it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer which has evolved over the last few years is, you don’t apply TDD to the GUI, you design the GUI in such as way that there’s a layer just underneath you can develop with TDD. The Gui is reduced to a trivial mapping of controls to the ViewModel, often with framework bindings, and so is ignored for TDD.
This is known variously as the Presentation Model (Fowler) the Model-View-ViewModel and DataModel-View-ViewModel architecture.
This approach removes the GUI layer from TDD and unit testing. It does not mean the GUI is never tested but just acknowledges that it is not cost effective to pursue automated GUI testing, particularly as part of TDD. Integration and user testing should cover the GUI.
Josh Smith’s 2009 WPF article is a detailed explanation of MVVM with some testing.
More recently, Houssem Dellai’s 2016 video Creating Unit Tests for Xamarin Forms Apps shows a XAML UI with bound ViewModel and walks through creating a unit test project