Testing at softaware

We at softaware care about our applications. We care about the quality of our applications. So we test them.

Our applications are tested both manually and automatically. We write unit tests for small parts as well as function tests for larger parts of the application. We found function tests to be quite time-consuming and error-prone to write. That’s why we created a tool which eases the pain of writing tests for larger parts of an application and we named it “MvvmTester”.

As the name suggests it is only suitable for applications written with a widely-used presentation pattern called “MVVM”. MVVM separates the UI controls from their state and logic, which increases the testability of an application. The state as well as the logic are encapsulated within an independent component called “View Model”. If a user executes an action via the UI, the UI delegates the action to the View Model. Let me rephrase that: If MVVM is cleanly applied, every action that the user executes is really executed by the View Model.

So if something constantly observes the View Model and records the executed actions, it is able to replay the whole set of actions… over and over again. That’s exactly what “MvvmTester” does. It modifies each View Model, records the executed user actions and stores them permanently. Out of the recorded user actions “MvvmTester” is able to generate code for an automatic test which can be executed repeatedly. The main part of the generated test may look something like this (comments were manually added for clarity):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var mainViewModel = ...;
 
// Navigate to form for adding a new user
mainViewModel.SetVisiblePageCommand.Execute(mainViewModel.EditPerson);

// Fill out form
mainViewModel.EditPerson.Person.FirstName = "Johannes";
mainViewModel.EditPerson.Person.Age = 26;
mainViewModel.EditPerson.Person.BestFriend = mainViewModel.PersonList.Persons.ElementAt(5);

// Save new user
mainViewModel.EditPerson.SaveCommand.Execute(null);

// Navigate to user list
mainViewModel.SetVisiblePageCommand.Execute(mainViewModel.PersonList);

So while “MvvmTester” can help you in generating tests for larger parts of an application we’ve also found some other areas where it can help. With minimal manual effort the recorded actions can also be replayed while the application is running. This may be useful for a presentation of your application, the recorded actions can then automatically guide through the application.