Edit me

Testing Graphical Apps

Part of a good test suite is being able to quickly write tests and run them on a regular basis. Fyne’s API is designed to make testing applications easy. By separating component logic from it’s rendering definition we can load applications without actually displaying them and test the functionality completely.


The fyne repository and it’s examples all have test code at various levels. To show how to test a complete application look at the following code from the calculator example.

package calculator

import (



func TestAdd(t *testing.T) {
	calc := newCalculator()


	assert.Equal(t, "2", calc.output.Text)

Using the “test” package we load a test application, rather than a regular desktop app (test.NewApp() instead of app.New()). Then the test.Tap() function simulates user action and finally we check the text of the output for the correct answer.

A simple go test . will run this as a unit test, loading and testing the application, without ever having to load a window on the screen.